Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Accumulo, mail # user - Common scanner base


Copy link to this message
-
Re: Common scanner base
William Slacum 2012-05-10, 15:58
You forgot to call close() on the BatchScanner, which is one of the issues
I've found when trying to write implementation-agnostic code for scanning.
ScannerBase doesn't care about it, so something outside of your reader will
have to manage the lifetime of the BatchScanner or you'll have to do an
instanceof check.

On Thu, May 10, 2012 at 6:17 AM, John Vines <[EMAIL PROTECTED]> wrote:

> 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!
>