I think BinaryComparator will not give any help to achieve that goal(Because it's not a number comparison). You can try to customize your own comparator(Extend the class of WritableByteArrayComparable), and write the rules of how to do that comparison. And then using this comparator to do the scanning.
Jieshan -----Original Message----- From: Yifeng Jiang [mailto:[email protected]] Sent: Monday, May 07, 2012 7:37 PM To: [email protected] Subject: Re: HBase Between Filters Can you try adding this to your code: scan.addColumn(Bytes.toBytes("TRAN"), Bytes.toBytes("TRAN_ID")) -Yifeng On May 4, 2012, at 10:04 PM, sanky999 wrote: > I'm trying to retrieve rows with in range, using Filter List but I'm not > successful. Below is my code snippet. > > I want to retrieve data between 1000 and 2000. > > HTable table = new HTable(conf, "TRAN_DATA"); > > List<Filter> filters = new ArrayList<Filter>(); > > SingleColumnValueFilter filter1 = new > SingleColumnValueFilter(Bytes.toBytes("TRAN"), > Bytes.toBytes("TRAN_ID"), > CompareFilter.CompareOp.GREATER, new > BinaryComparator(Bytes.toBytes("1000"))); > filter1.setFilterIfMissing(true); > filters.add(filter1); > > SingleColumnValueFilter filter2 = new > SingleColumnValueFilter(Bytes.toBytes("TRAN"), > Bytes.toBytes("TRAN_ID"), > CompareFilter.CompareOp.LESS,new > BinaryComparator(Bytes.toBytes("2000"))); > > filters.add(filter2); > > FilterList filterList = new FilterList(filters); > > Scan scan = new Scan(); > scan.setFilter(filterList); > ResultScanner scanner1 = table.getScanner(scan); > > System.out.println("Results of scan #1 - MUST_PASS_ALL:"); > int n = 0; > > for (Result result : scanner1) { > for (KeyValue kv : result.raw()) { > System.out.println("KV: " + kv + ", Value: " > + Bytes.toString(kv.getValue())); > { > n++; > > } > } > scanner1.close(); > > > > Tried with all possible ways using > 1. SingleColumnValueFilter filter2 = new > SingleColumnValueFilter(Bytes.toBytes("TRANSACTIONS"), > Bytes.toBytes("TRANS_ID"), CompareFilter.CompareOp.LESS, new > SubstringComparator("5000")); > > SingleColumnValueFilter filter2 = new > SingleColumnValueFilter(Bytes.toBytes("TRANSACTIONS"), > Bytes.toBytes("TRANS_ID"), CompareFilter.CompareOp.LESS, > Bytes.toBytes("5000")); None of above approaches work :( > > -- > View this message in context: > http://apache-hbase.679495.n3.nabble.com/HBase-Between-Filters-tp3962242.html > Sent from the HBase - Developer mailing list archive at Nabble.com.
