【发布时间】:2015-12-23 16:23:42
【问题描述】:
我正在使用 Spark 将 Hbase 数据加载到 JavaPairRDD。现在,我想知道是否可以将最新的 100 行加载到 Spark 中,而不是从 Hbase 加载所有行。 1)我尝试了scan.setCaching(100),但它仍然返回了所有行。是否为了限制我从 Hbase 加载的行? 2) 我怎样才能确保它是最新的 100 行
有什么想法吗?非常感谢。
Scan scan = new Scan();
scan.setFilter(A list of filters);
scan.setCaching(100);
ClientProtos.Scan proto = ProtobufUtil.toScan(scan);
String scanStr = Base64.encodeBytes(proto.toByteArray());
hbaseConfig.set(TableInputFormat.INPUT_TABLE, tableName);
hbaseConfig.set(TableInputFormat.SCAN,scanStr);
JavaPairRDD<ImmutableBytesWritable, Result> hBaseRDD =
javaSparkContext.newAPIHadoopRDD(hbaseConfig, TableInputFormat.class, ImmutableBytesWritable.class, Result.class).cache();
【问题讨论】:
标签: java apache-spark hbase