[
https://issues.apache.org/jira/browse/HBASE-5950?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14541953#comment-14541953
]
Bhupendra Kumar Jain commented on HBASE-5950:
---------------------------------------------
I think, For Numeric comparison of positive and negative value, Binary
comparator will not be sufficient enough. Consider below scenarios
{Quote}
// Scenario 1 : Compare Negative double value with Negative double value
using Binary Comparator
double d1 = -4.0d;
double d2 = -5.0d;
BinaryComparator cp = new BinaryComparator(Bytes.toBytes(d1));
assertEquals(1, cp.compareTo(Bytes.toBytes(d2))); //FAIL
// Scenario 2 : Compare Negative long value with Negative long value using
Binary Comparator
long l1 = -4L;
long l2 = -5L;
BinaryComparator cp1 = new BinaryComparator(Bytes.toBytes(l1));
assertEquals(1, cp1.compareTo(Bytes.toBytes(l2))); //PASS
// Scenario 3 : Compare positive long value with Negative long value using
Binary Comparator
long l3 = 4L;
long l4 = -5L;
BinaryComparator cp2 = new BinaryComparator(Bytes.toBytes(l3));
assertEquals(1, cp2.compareTo(Bytes.toBytes(l4))); //FAIL
// Scenario 4 : Compare positive long value with Negative long value using
Long Comparator
long l5 = 4L;
long l6 = -5L;
LongComparator cp3 = new LongComparator(l5);
assertEquals(1, cp3.compareTo(Bytes.toBytes(l6))); //PASS
{Quote}
To compare the Non decimal values, LongComparator is sufficient. Similar way to
compare the Decimal Values , DecimalComparator will be required.
May be there is some other better way which I am not aware .... Am I missing
something ?
> Add a decimal comparator for Filter
> -----------------------------------
>
> Key: HBASE-5950
> URL: https://issues.apache.org/jira/browse/HBASE-5950
> Project: HBase
> Issue Type: New Feature
> Components: Filters
> Affects Versions: 0.94.0, 0.95.2
> Reporter: Jieshan Bean
> Assignee: Jieshan Bean
>
> Suppose we have a requirement like below:
> we want to get the rows with one specified column value larger than A and
> less than B.
> (They are all decimals or integers)
> namely:
> A < Integer.valueof(column) < B
> Use BinaryComparator will not help us to archive that goal:
> e.g. suppose A = 100, B = 200, one column value is 110000.
> So it can satisfy that condition, but it's not the row we wanted.
>
> So I suggest to add one comparator to help implementing this.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)