hbase适用大量批量读写场景吗

发布网友

我来回答

1个回答

热心网友

Configuration conf = HBaseConfiguration.create();
String tableName = "testTable";
Scan scan = new Scan();
scan.setCaching(10000);
scan.setCacheBlocks(false);
conf.set(TableInputFormat.INPUT_TABLE, tableName);
ClientProtos.Scan proto = ProtobufUtil.toScan(scan);
String ScanToString = Base.encodeBytes(proto.toByteArray());
conf.set(TableInputFormat.SCAN, ScanToString);
JavaPairRDD<ImmutableBytesWritable, Result> myRDD = sc
.newAPIHadoopRDD(conf, TableInputFormat.class,
ImmutableBytesWritable.class, Result.class);
在Spark使用如上Hadoop提供的标准接口读取HBase表数据(全表读),读取5亿左右数据,要20M+,而同样的数据保存在Hive中,读取却只需要1M以内,性能差别非常大。
转载,仅供参考。

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com