【发布时间】:2015-08-04 17:52:58
【问题描述】:
我正在尝试使用 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 ===
-------------------------------------
相关的 Accumulo 链接
【问题讨论】:
-
要么你的代码不能编译,要么你应该添加你的类
Scanner的实现。 -
@Tom 这是个问题吗?如果是这样,是的,代码编译(并执行)并通过
org.apache.accumulo.core.client.Scanner导入Scanner -
不,这是一个声明。如果您的代码编译,那么您没有使用
java.util.Scanner,因此应该将Scanner代码添加到问题中。 -
@Tom 当然,我会把它添加到问题中。
-
尝试将 log4j 的详细程度提高到 DEBUG 并观察来自 org.apache.accumulo.core.client 下的类的消息。您可以在 shell 中读取数据但不能在客户端中读取数据这一事实令人惊讶。您在这两种情况下都以同一用户身份登录吗?