简体   繁体   中英

Accumulo table scanner failing silently in Java

I am attempting to scan an entire Accumulo table with the Java API. I have verified that the meta info is all correct (credentials, ZooKeeper server, Accumlo Instance ID, table name). At this point I'm at a dead end so any suggestion is appreciated.

Accumulo Version

1.6.2

The code

Borrowed from accumulo read client .

// scan the whole table
System.out.println("=== whole table ===");
Scanner tableScanner;
try {
  tableScanner = conn.createScanner("geomesa3_records", new Authorizations());
  // conn is of type Connector
  // Connector and Scanner are implemented in org.apache.accumulo.core.client
  // See links below for additional info
} catch (TableNotFoundException ex) {
  throw new RuntimeException("table not found - was SimpleIngestClient run?");
}
System.out.println("-------------------------------------");

for(Map.Entry<Key, Value> kv : tableScanner) { // seemingly freezes here
  System.out.println("----------------- new row ---------------");
  System.out.println(kv.getKey().getRow() + " "
      + kv.getKey().getColumnFamily() + " "
      + kv.getKey().getColumnQualifier() + ": "
      + new String(kv.getValue().get()));
}
tableScanner.close();
System.out.println("-------------------------------------");
System.out.println("=== end table ===");

Intended results

=== whole table ===
-------------------------------------
----------------- new row ---------------
// table data
----------------- new row ---------------
// table data
----------------- new row ---------------
// table data
-------------------------------------
=== end table ===

Actual results

=== whole table ===
-------------------------------------

Relevant Accumulo Links

Scanner API

Connector API used for createScanner

Scanner interface

I think you might need to set a range on the scanner. To scan and entire table, just set the range like so:

scanner.setRange(new Range());

This range will match everything. Specifically, this range "goes from negative infinity to positive infinity". Basically it matches all possible Keys.

I use a similar strategy for a fetch all operation on one of my tables.

Also, just be aware that this sort of thing can definitely cause issues. If the table gets large, this could take a very long time to run. In my case I never expect the table to grow above a few hundred logical rows, so I consider it safe.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM