Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save zznate/393142 to your computer and use it in GitHub Desktop.
Save zznate/393142 to your computer and use it in GitHub Desktop.
Given Keyspace ks, and an optional startOnKey string, the following snippet returns a Set of 100 keys without de-serializing the underlying columns. The tradeoff is that you have no local check on tombstones. Pass the last key retrieved as startOnKey to page.
ColumnParent clp = new ColumnParent(columnFamilyName);
SlicePredicate sp = new SlicePredicate();
sp.setColumn_names(new ArrayList<byte[]>());
KeyRange keyRange = new KeyRange();
keyRange.setCount(100);
if ( StringUtils.isBlank(startOnKey)) {
keyRange.setStart_key("");
} else {
keyRange.setStart_key(startOnKey);
}
keyRange.setEnd_key("");
return ks.getRangeSlices(clp, sp, keyRange).keySet();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment