hbase GREATER_OR_EQAUL操作符不能正常工作



我在hbase表中有这样一行:{rowkey: 1 _1611646861574/cf:价值/1611646776287/把/vlen = 8/seqid = 0}现在我想做一个简单的扫描,找出列值大于"1611388300000"的行。但是它不返回任何记录;但是,当我使用LESS_OR_EQUAL大于1611647500000时,它返回此记录。奇怪的是,我可以从apache phoenix SQL查询得到这个记录:select * from my_table where value>=1611388300000.

所以number明显大于column value, apache phoenix返回它;为什么hbase比较操作符没有?

下面是我的代码:
Table table = con.getTable(TableName.valueOf("my_table"));
Scan scan = new Scan();
scan.addColumn(Bytes.toBytes("cf"), Bytes.toBytes("value"));
FilterList flist = new FilterList(FilterList.Operator.MUST_PASS_ALL);
flist.addFilter(new PrefixFilter(Bytes.toBytes("1")));
flist.addFilter(new SingleColumnValueFilter(
Bytes.toBytes("cf"), Bytes.toBytes("value"), CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("1611388300000"))));
scan.setFilter(flist);
ResultScanner scanner = table.getScanner(scan);
for (Result result = scanner.next(); result != null; result = scanner.next())
System.out.println("Found row : " + result);
scanner.close();

我不知道为什么,但LESS_OR_EQUAL与string:

new SingleColumnValueFilter(
Bytes.toBytes("cf"), Bytes.toBytes("value"), CompareOperator.LESS_OR_EQUAL,
new BinaryComparator(Bytes.toBytes("1611647500000")))

但是当我使用引号时,GREATER_OR_EQUAL不起作用,所以我不得不使用number(添加L来指定Long)

new SingleColumnValueFilter(
Bytes.toBytes("ui"), Bytes.toBytes("C"), CompareOperator.GREATER_OR_EQUAL,
new BinaryComparator(Bytes.toBytes(1611388300000L)))

因为你比较长,你应该使用LongComparator而不是BinaryComparator:https://hbase.apache.org/apidocs/org/apache/hadoop/hbase/filter/LongComparator.html

最新更新