我无法比较hbase表的某个列值中的长值。我正在使用javaapi。下面是代码片段。我清楚地看到表中有一个值满足过滤器的要求。
我也想知道什么是词典比较,我将如何执行长期比较。
这方面的任何指导都非常有用。
提前谢谢
FilterList list = new FilterList(FilterList.Operator.MUST_PASS_ALL);
SingleColumnValueFilter fil = new SingleColumnValueFilter(CF1_BYTE, VALUE_BYTE, CompareOp.LESS,new BinaryComparator(Bytes.toBytes(50)));
Scan scan = new Scan();
scan.addColumn(Bytes.toBytes("C1"),Bytes.toBytes("VALUE"));
list.addFilter(fil);
scan.setFilter(list);
try {
ResultScanner scanner = table.getScanner(scan);
for(Result r : scanner){
String VAL = Bytes.toString(r.getValue(Bytes.toBytes("C1"),Bytes.toBytes("VALUE")));
count ++;
if(count == 1000){
break;
}
System.out.println(count +" "+Bytes.toString(r.getRow()) + " "+VAL );
}
scanner.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
table.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
1条答案
按热度按时间toe950271#
根据doc,您必须提供自己的比较器,它将反序列化字节数组中的长值。据我所知,默认比较是按词典编纂的。关于词典比较,你会发现这篇文章很有用。这篇文章提供了如何编写相应的比较器的线索。
更新:
我建议使用hbase utils而不是guava,因为它可能与hbase guava依赖性冲突。