accumulo-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From John Armstrong <j...@ccri.com>
Subject Scanner and BatchScanner on equal footing.
Date Thu, 17 May 2012 14:22:34 GMT
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.

Mime
View raw message