1
votes

Version: HBase Cloudera CDH3U2.

I Have inserted a long datatype value into HBase using Java API.

    Get get = new Get(Bytes.toBytes("111"));

    FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);

 singleColumnValueFilter = new SingleColumnValueFilter(columnFamily,columnName , CompareOp.GREATER_OR_EQUAL, Bytes.toBytes(2));

    filterList.addFilter(singleColumnValueFilter);

    get.setFilter(filterList);
    get.setMaxVersions(10);

    Result result = hTable.get(get);

    List keyValueList = result.getColumn(columnFamily, columnName);

Here I m getting the keyValueList.size() is zero, and if I m not applying any filters, I m getting keyValueList.size() is 3, and the values are (1,5,7).

I want the result of 5 and 7.

Help me to do this.

Thanks in advance

3

3 Answers

0
votes

How do you store values? Do you store them using Bytes.toBytes("2") or Bytes.toBytes(2) ? You have to use the same thing here. The default comparator is BinaryComparator, which compares the Byte-converted value lexicographically, but the conversion method is different for strings and ints. So either you use ints while inserting as well as comparing, or you use strings in both cases.

Try using Bytes.toBytes("2") instead.

0
votes

You said you were trying to store Long values? Then shouldn't you have put Bytes.toBytes(2L)?

0
votes
FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ALL);

Must_Pass_All Operator is a lazy operation i.e. if it doesn't find any value for a filter within filterlist, it will stop the execution.

Try:

FilterList filterList = new FilterList(FilterList.Operator.MUST_PASS_ONE);

Moreover, you have only one filter set, so its good not to use any filterlist. Use it only when you want to have more than one filter to be applied on the table.