我每个月创建的表结构相同,其中包含tweet id作为行键。我需要从每个表中检索600条随机推文。有趣的是,它仅返回某些表的结果。如果我在hbase shell中进行表扫描,则可以看到结果。我想知道这种行为的原因可能是什么。
HTable indexTable = (HTable) connection.getTable(TableName.valueOf(indexTableName));
Scan scan = new Scan();
RandomRowFilter filter1 = new RandomRowFilter(1);
PageFilter filter2 = new PageFilter(getNtweetsPerMonth());
FilterList orFilter = new FilterList();
orFilter.addFilter(filter1);
orFilter.addFilter(filter2);
scan.setFilter(orFilter);
scan.setMaxResultSize(getNtweetsPerMonth());
if (tsStart >= 0 && tsEnd >= 0) {
if (tsEnd < Long.MAX_VALUE) {
scan.setTimeRange(tsStart, tsEnd + 1);
} else {
scan.setTimeRange(tsStart, tsEnd);
}
}
ResultScanner rs = indexTable.getScanner(scan);
Result r = rs.next();
while (r != null) {
String tweetIdString = TruthyHelpers.getTweetIDStrFromBigIntBytes(r.getRow());
BytesWritable tweetIdBytes = new BytesWritable(Bytes.toBytes(tweetIdString));
contentResults.add(tweetIdBytes);
r = rs.next();
}
rs.close();
indexTable.close();
connection.close();
return contentResults;