本文介绍了当在HBase中反转扫描,这是startKey,哪个是stopKey?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用HBase 0.98,它允许以相反顺序扫描。



这是我的代码:

  scan = new Scan(eventTimeKey,nowKey); 
scan.setCaching(1); //设置为1,因为我只想要第一个结果
scan.setMaxResultSize(1L);
scan.addColumn(dataBytes,readingBytes);
scan.setReversed(true);
尝试{
scanner = getTable()。getScanner(scan);
result = scanner.next();
} finally {
if(scanner!= null)
scanner.close();
}
if(result!= null&&& valueIsZero(result))
return true;

我的问题是,Scan构造函数的参数应该以什么顺序? startKey应该是'aaa',endKey应该'zzz'还是其他方式?或者它有什么关系?

更新:事实证明,我们在服务器端有HBase 0.96,所以反向扫描显然不会工作。我认为这解释了我所遇到的困惑。在我们升级之前,我的测试无法回答这个问题,所以我会在别人感兴趣的情况下将其打开。

在HBase 0.98之后的反向扫描中,开始键和结束键被颠倒过来。



文档链接解释了这一点:


I'm using HBase 0.98 which allows scans in reverse order.

Here is my code:

    scan = new Scan(eventTimeKey, nowKey);
    scan.setCaching(1); // setting this to 1 since I only want the first result
    scan.setMaxResultSize(1L);
    scan.addColumn(dataBytes, readingBytes);
    scan.setReversed(true);
    try {
        scanner = getTable().getScanner(scan);
        result = scanner.next();
    } finally {
        if (scanner != null)
            scanner.close();
    }
    if (result != null && valueIsZero(result))
        return true;

My question is, what order should the arguments to the Scan constructor be in? Should startKey be 'aaa' and endKey be 'zzz' or the other way around? Or does it matter?

Update: turns out, we have HBase 0.96 on the server side so reverse scans are, apparently, not going to work. I think this explains the confusion I was having. Until we upgrade, my tests are not going to be able to answer this question so I'll leave this open in case someone else is interested.

解决方案

In case of reversed scan in HBase 0.98 onwards start key and end key are reversed.

Documentation Link explains this: Doc Link

这篇关于当在HBase中反转扫描,这是startKey,哪个是stopKey?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-14 01:43