【问题标题】:HBase read performance based on row key基于行键的 HBase 读取性能
【发布时间】:2014-04-09 21:11:27
【问题描述】:

我已将 1M 行数据插入到 hbase 表中。然后我正在编写一个java程序来测试基于行键的HBase的读取性能。

//create a list which contains 10,000 row keys 
for(int i=0; i<10000; i++)
{
   list.add(rowkey);
}

//go through the list and check the rowkey exists in HBase or not
for(int i=0; i<list.size(); i++)
{
    Get g = new Get(list.get(i));
    g.setFilter(new KeyOnlyFilter());
    Result r = table.get(g);
    // ...

}

行键格式,如“12345_54321”。测试我的程序后,加载所有 10,000 个行键以检查它是否存在大约需要 50 秒,因此每 200/s。

这个读取性能太慢了,我还在Get对象中添加了过滤器。有没有其他方法可以提高上述性能?还是我的程序有问题?

【问题讨论】:

    标签: java hbase


    【解决方案1】:

    较低的性能主要是因为您在每次迭代中执行比较并触发 get,我认为这显然需要一些时间,hbase 并非旨在为您提供实时性能。

    【讨论】:

      【解决方案2】:

      您可以使用 exists() API 来执行此操作。举个例子,希望对你有帮助。

              List<Get> gets = new ArrayList<Get>();
              for (String rowKey : rowKeys) {
                  Get get = new Get(Bytes.toBytes(rowKey));
                  gets.add(get);
              }
      
              Set<String> newRows = new HashSet<String>();
              Boolean[] results;
              HTableInterface table = getHTableInterface(tableName);
              results = table.exists(gets);    
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-08-02
        • 1970-01-01
        • 2012-05-31
        • 2022-01-20
        • 1970-01-01
        • 2016-08-16
        相关资源
        最近更新 更多