HBase Multiple PrefixFilters + setLimit

时间:2018-05-07 06:38:09

标签: scala apache-spark hadoop hbase cloudera-cdh

我有一个行前缀列表。我想为每个前缀查询N行。

我无法使用MultiRowRangeFilter,因为我不知道该范围的结束rowkey前缀是什么。我也不能使用scan.setLimit(N),因为我认为它会将行查询的行数限制为N(我想要的是每个前缀到有N行)。

我目前的设置:

val hbaseConf = HBaseConfiguration.create()
// set zookeeper quorum properties in hbaseConf

val hbaseContext = new HBaseContext(sc, hbaseConf)

val rowPrefixes = Array("a", "b", "c")
val filterList = new FilterList()

rowPrefixes.foreach { x => filterList.addFilter(new PrefixFilter(Bytes.toBytes(x))) }

var scan = new Scan()  

scan.setFilter(filterList)
scan.addFamily(Bytes.toBytes("myCF"));

val rdd = hbaseContext.hbaseRDD(TableName.valueOf("tableName"), scan)
rdd.mapPartitions(populateCaseClass)

我不确定应该使用哪个过滤器来为每个rowkey实现这个多个rowkey前缀+ setLimit ...

0 个答案:

没有答案