有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java从HBase读取数据

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


共 (4) 个答案

  1. # 2 楼答案

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

  2. # 3 楼答案

    我在找这样的东西

    地图功能

    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");                   
    
  3. # 4 楼答案

    我认为您需要的是:通过HBase shell和Java API:http://cook.coredump.me/post/19672191046/hbase-client-example

    不过,您应该了解hbase外壳的“扫描”速度非常慢(未缓存)。但它仅用于调试目的

    另一个有用的信息是:http://hbase.apache.org/book/perf.reading.html 本章关于阅读HBase的内容是正确的,但却有点难以理解,因为它假定读者对HBase有一定程度的熟悉,并包含更高级的建议。我会从一开始就向你推荐这本指南