サンプルコード
@Grab(group='org.apache.hbase', module='hbase-client', version='0.98.5-hadoop2') @Grab(group='org.apache.hbase', module='hbase-common', version='0.98.5-hadoop2') @Grab(group='org.apache.hadoop', module='hadoop-client', version='2.5.0') import org.apache.hadoop.hbase.* import org.apache.hadoop.hbase.client.* import org.apache.hadoop.hbase.util.* def config = HBaseConfiguration.create() config.set(HConstants.ZOOKEEPER_QUORUM, "localhost") config.set(HConstants.ZOOKEEPER_CLIENT_PORT, "2181") def table = new HTable(config, "test") table.withCloseable { def rscanner = table.getScanner(Bytes.toBytes("cf1")) while((row = rscanner.next()) != null){ def cscanner = row.cellScanner() while(cscanner.advance()){ def cell = cscanner.current() println Bytes.toString(row.getRow()) println Bytes.toString(CellUtil.cloneFamily(cell)) println Bytes.toString(CellUtil.cloneQualifier(cell)) println Bytes.toString(CellUtil.cloneValue(cell)) } } }動作環境
groovy 2.3.6, JDK 7 Update 65, Hadoop 2.5.0, zookeeper 3.4.6, HBase0.98.5
0 件のコメント:
コメントを投稿