This came up at the meetup last night, figured I would throw this up here
just in case anyone else is interested.
The case was a user wanted a method for manipulating scan results, whether
they be standard scanner or batch scanner. Turns out, it is pretty easy to
have a common base, at least as of Accumulo 1.4.1.
public class Scratch {
public static void main(String[] args) throws AccumuloException,
AccumuloSecurityException, TableNotFoundException {
Instance instance = new ZooKeeperInstance("test", "localhost:2181");
Connector conn = instance.getConnector("root", "secret".getBytes());
Scanner scan = conn.createScanner("test", new Authorizations());
dumpScan(scan);
BatchScanner bs = conn.createBatchScanner("test", new Authorizations(),
3);
bs.setRanges(Arrays.asList(new Range()));
dumpScan(bs);
}
/**
* @param scan
*/
private static void dumpScan(Iterable<Entry<Key,Value>> scan) {
for (Entry<Key,Value> e : scan)
System.out.println(e.getKey());
}
}
Don't want it as generic (and ugly) as Iterable<Entry<Key,Value>>? You can
also use ScannerOptions or ScannerBase!