1

我是 HBase 的新手,从表中逐行检索结果的最佳方法是什么?我想读取表中的全部数据。我的表有两个列族,分别是 col1 和 col2。

4

4 回答 4

0

I think here is what you need: both through HBase shell and Java API: http://cook.coredump.me/post/19672191046/hbase-client-example

However you should understand hbase shell 'scan' is very slow (it is not cached). But it is intended only for debug purpose.

Another useful part of information for you is here: http://hbase.apache.org/book/perf.reading.html This chapter is right about reading from HBase but is is somewhat harder to understand because it assumes some level of familiarity and contains more advanced advices. I'd recommend to you this guide starting from the beginning.

于 2013-05-19T16:50:06.397 回答
0

使用 Hbase 的 Scan api,您可以在其中指定起始行和结束行,并可以从表中检索数据。

这是一个例子:

http://eternaltechnology.blogspot.in/2013/05/hbase-scanner-example-scanning.html

于 2013-05-20T05:57:29.057 回答
0

在 Hbase shell 中,您可以使用scan命令列出表中的数据,或get检索记录。参考这里

于 2013-05-19T16:30:42.597 回答
0

我一直在寻找这样的东西!

地图功能

public void map(ImmutableBytesWritable row, Result value, Context context) throws InterruptedException, IOException {

            String x1 = new String(value.getValue(Bytes.toBytes("ColumnFamily"), Bytes.toBytes("X1")));
            String x2 = new String(value.getValue(Bytes.toBytes("ColumnFamily"), Bytes.toBytes("X2")));


}

驱动文件:

Configuration config2 = new Configuration();
            Job job2 = new Job(config1, "kmeans2");
            //Configuration for job2

            job2.setJarByClass(Converge.class);
            job2.setMapperClass(Converge.Map.class);
            job2.setReducerClass(Converge.Reduce.class);
            job2.setInputFormatClass(TableInputFormat.class);
            job2.setOutputFormatClass(NullOutputFormat.class);
            job2.setOutputKeyClass(Text.class);
            job2.setOutputValueClass(Text.class);
            job2.getConfiguration().set(TableInputFormat.INPUT_TABLE, "tablename");                   
于 2013-05-21T23:53:38.580 回答