Bin Shi created PHOENIX-5176:
--------------------------------
Summary: KeyRange.compareUpperRange(KeyRang 1, KeyRang 2) returns
wrong result when two key ranges have the same upper bound values but one is
inclusive and another is exclusive
Key: PHOENIX-5176
URL: https://issues.apache.org/jira/browse/PHOENIX-5176
Project: Phoenix
Issue Type: Bug
Reporter: Bin Shi
In KeyRange.java,
{color:#262626} public static int compareUpperRange(KeyRange rowKeyRange1,
KeyRange rowKeyRange2) {{color}
{color:#262626} int result =
Boolean.compare(rowKeyRange1.upperUnbound(),
rowKeyRange2.upperUnbound());{color}
{color:#262626} if (result != 0) {{color}
{color:#262626} return result;{color}
{color:#262626} }{color}
{color:#262626} result =
Bytes.BYTES_COMPARATOR.compare(rowKeyRange1.getUpperRange(),
rowKeyRange2.getUpperRange());{color}
{color:#262626} if (result != 0) {{color}
{color:#262626} return result;{color}
{color:#262626} }{color}
{color:#262626} return
Boolean.compare(*rowKeyRange2*.isUpperInclusive(),
*rowKeyRange1*.isUpperInclusive());{color}
{color:#262626} }{color}
{color:#262626} {color}
{color:#262626}The last line in yellow color should be "{color}return
Boolean.compare(*rowKeyRange1*.isUpperInclusive(),
*rowKeyRange2*.isUpperInclusive());". Given rowKeyRange1 [3, 5) and
rowKeyRange2 [3, 5], the function should return -1, but now it returns 1 due to
the bug I mentioned.
The KeyRange.compareUpperRange is only used in
KeyRange.intersect(List<KeyRange> rowKeyRanges1, List<KeyRange> rowKeyRanges2).
Given rowKeyRanges1 \{[3, 5), [5, 6)} and rowKeyRanges2\{[3, 5], [6, 7]}, the
function should return \{[3, 5), [5, 5]}, i.e., \{[3, 5]}, but it seems that
now it returns \{[3,5)} due to the bug.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)