Accumulo表扫描程序在Java中无声地失败

时间:2015-08-04 17:52:58

标签: java accumulo

我正在尝试使用Java API扫描整个Accumulo表。我已经验证元信息是正确的(凭证,ZooKeeper服务器,Accumlo实例ID,表名)。在这一点上,我处于死胡同,所以任何建议都表示赞赏。

Accumulo版本

1.6.2

代码

借鉴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 ===");

预期结果

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

实际结果

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

相关的Accumulo链接

Scanner API

Connector API used for createScanner

Scanner interface

1 个答案:

答案 0 :(得分:1)

我认为您可能需要在扫描仪上设置范围。要扫描整个表格,只需设置范围:

scanner.setRange(new Range());

此范围将匹配所有内容。具体来说,这个范围从负无穷大变为正无穷大&#34;。基本上它匹配所有可能的键。

我在其中一个表上使用类似的策略来获取所有操作。

另外,请注意这种事情肯定会导致问题。如果表变大,这可能需要很长时间才能运行。在我的情况下,我从不指望表格会超过几百个逻辑行,所以我认为它是安全的。