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 = Base64.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以內,性能差別非常大。
現在專案已基本選型要使用HBase作為大資料的存盤,而Spark讀取HBase資料的性能卻如此慢,已經償試了直接讀取HFile,但只讀取決議一片HFile檔案的性能也很慢(400M資料大約需90s),還有沒有其它的解決辦法?難道Spark就不能以Hbase作為基礎存盤了嗎?
uj5u.com熱心網友回復:
請問樓主您的問題解決了嗎?可以分享下經驗嗎?uj5u.com熱心網友回復:
最新的hbase已經提供了spark介面uj5u.com熱心網友回復:
看看這個HBase Doc轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/77310.html
標籤:Spark
上一篇:windows 集群驗證過不
