accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Adam Fuchs <>
Subject Re: Scanner and BatchScanner on equal footing.
Date Thu, 17 May 2012 14:39:08 GMT

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!


On Thu, May 17, 2012 at 10:23 AM, John Armstrong <> 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.

View raw message