【发布时间】:2014-12-04 22:33:07
【问题描述】:
我正在尝试将大型 Hbase 表加载到 SPARK RDD 中以在实体上运行 SparkSQL 查询。对于大约 600 万行的实体,将其加载到 RDD 大约需要 35 秒。是预期的吗?有什么办法可以缩短加载过程吗?我从http://hbase.apache.org/book/perf.reading.html 那里得到了一些提示来加快这个过程,例如, scan.setCaching(cacheSize) 并且只添加必要的属性/列进行扫描。 我只是想知道是否有其他方法可以提高速度?
这里是sn-p的代码:
SparkConf sparkConf = new SparkConf().setMaster("spark://url").setAppName("SparkSQLTest");
JavaSparkContext jsc = new JavaSparkContext(sparkConf);
Configuration hbase_conf = HBaseConfiguration.create();
hbase_conf.set("hbase.zookeeper.quorum","url");
hbase_conf.set("hbase.regionserver.port", "60020");
hbase_conf.set("hbase.master", "url");
hbase_conf.set(TableInputFormat.INPUT_TABLE, entityName);
Scan scan = new Scan();
scan.addColumn(Bytes.toBytes("MetaInfo"), Bytes.toBytes("col1"));
scan.addColumn(Bytes.toBytes("MetaInfo"), Bytes.toBytes("col2"));
scan.addColumn(Bytes.toBytes("MetaInfo"), Bytes.toBytes("col3"));
scan.setCaching(this.cacheSize);
hbase_conf.set(TableInputFormat.SCAN, convertScanToString(scan));
JavaPairRDD<ImmutableBytesWritable, Result> hBaseRDD
= jsc.newAPIHadoopRDD(hbase_conf,
TableInputFormat.class, ImmutableBytesWritable.class,
Result.class);
logger.info("count is " + hBaseRDD.cache().count());
【问题讨论】:
标签: hbase apache-spark apache-spark-sql