【问题标题】:Count the number of rows returned by an Accumulo batch scanner计算 Accumulo 批处理扫描仪返回的行数
【发布时间】:2019-04-05 12:01:06
【问题描述】:

我想知道是否有一种有效的方法来计算 Accumulo 中的批处理扫描仪返回的行数,而无需手动遍历所有返回的行。

我现在的东西是这样的

Connector connector = // Created a new connector
BatchScanner bsc = connector.createBatchScanner(tableName, Authorizations.EMPTY, numThreads);
/*
... applying filters
*/

Iterator<Map.Entry<Key, Value>> e = bsc.iterator();
long cnt = 0;

while(e.hasNext()) {
     cnt++;
}

return cnt;

我正在遍历批处理扫描器返回的每一行并计算我遇到的每一行。我想知道是否有更好的方法来做到这一点?

【问题讨论】:

    标签: counting accumulo


    【解决方案1】:

    通常 (What is the best way to get the count/length/size of an iterator?) 您将无法更快地执行此操作,因为您的过滤器可以是任何东西,因此您将不得不在某个地方进行一些计数。

    您可以通过其他方式 (Maintain statistics across rows in accumulo) 跟踪计数,但它们可能会给您带来新的麻烦。

    【讨论】:

    • 可以分发这个任务吗?也许将迭代器提供给可以进行计数的 Spark 流作业或 map-reduce 作业?
    • 您可以创建自己的组合迭代器stackoverflow.com/questions/19048613/…,然后在客户端求和。至少在那个时候,您将计算分布在整个集群中,并且减少了遍历网络的数据量。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-08-13
    • 2012-05-21
    • 1970-01-01
    • 1970-01-01
    • 2014-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多