John, As of Accumulo 1.4.0, ScannerBase implements Iterable<Entry<Key,Value>>. 1.3.x and earlier did not. However, I'm glad to hear that my java generics hack worked!
Cheers, Adam On Thu, May 17, 2012 at 10:23 AM, John Armstrong <[email protected]> wrote: > Hi, everybody! > > As I mentioned to a few people at the meeting last Wednesday, I've been > wondering why Scanner and BatchScanner have no common Iterable parent. The > use case is one where I have a method that I give a Scanner or a > BatchScanner, twiddle some of the scan settings, then use in a foreach loop > or something to get data out. Sometimes I want to use a Scanner, and > sometimes I want to use a BatchScanner, depending on the size of the data, > but I'm writing the exact same code for each. > > Adam's suggestion for this use of Java generics does work: > > public <SCANNER extends ScannerBase & Iterable<Map.Entry<Key, Value>>> > ReturnType doStuffWithScanner(SCANNER scanner, OtherArgsType otherArgs) > > but it still feels sort of hacky. > > A common abstract parent below ScannerBase and above both Scanner and > BatchScanner which declared itself to implement Iterable<Map.Entry<Key, > Value>> would fix this without having to write a single line of actual > code. Not a big deal, but makes the client code look nicer. >
