我正在尝试使用 Java API 扫描整个 Accumulo 表。我已验证元信息全部正确(凭据、ZooKeeper 服务器、Accumlo 实例 ID、表名称)。此时我已经陷入了困境,所以任何建议都会受到赞赏。
累积版本
1.6.2
代码
// 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 ===
-------------------------------------
相关累积链接
最佳答案
我认为您可能需要在扫描仪上设置一个范围。要扫描整个表格,只需设置范围,如下所示:
scanner.setRange(new Range());
这个范围将匹配所有内容。具体来说,这个范围“从负无穷大到正无穷大”。基本上它匹配所有可能的键。
我使用类似的策略对我的一个表进行全部获取操作。
此外,请注意这种事情肯定会导致问题。如果表变大,则可能需要很长时间才能运行。就我而言,我从不期望表增长到超过几百个逻辑行,所以我认为它是安全的。
关于java - Accumulo 表扫描器在 Java 中静默失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31816012/