批处理扫描仪,每个范围都有限制



有没有办法使用BatchScanner为每个范围获取前n整行。

我想为多个用户提取最新的用户活动,每个用户最多 100 行。行键以用户 ID 开头,后跟时间戳。

谢谢

德扬

Dejan -- 看看 WholeRowIterator。下面是有关如何使用它的一些示例代码。

Connector conn = getConnector();
BatchScanner bs = conn.createBatchScanner("mytable", new Authorizations(), 4);
IteratorSetting iterator = new IteratorSetting(100, WholeRowIterator.class);
bs.addScanIterator(iterator);
for (Entry<Key,Value> entry : bs) {
  SortedMap<Key,Value> row = WholeRowIterator.decodeRow(entry.getKey(), entry.getValue());
}

最新更新