[英]Accumulo table scanner failing silently in Java
我正在嘗試使用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());
此范圍將匹配所有內容。 具體地,該范圍“從負無窮大到正無窮大”。 基本上,它匹配所有可能的鍵。
我使用類似的策略對我的一張桌子進行所有操作。
另外,請注意,這種事情肯定會引起問題。 如果表變大,則可能需要很長時間才能運行。 就我而言,我從不希望該表增長到幾百個邏輯行以上,因此我認為它是安全的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.