phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] karanmehta93 commented on a change in pull request #471: PHOENIX-5176 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
Date Tue, 19 Mar 2019 22:00:12 GMT
karanmehta93 commented on a change in pull request #471: PHOENIX-5176 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
URL: https://github.com/apache/phoenix/pull/471#discussion_r267115432
 
 

 ##########
 File path: phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeMoreTest.java
 ##########
 @@ -192,64 +193,78 @@ public void testListIntersectForBoundary() throws Exception {
 
         listIntersectAndAssert(Arrays.asList(KeyRange.EMPTY_RANGE),Arrays.asList(KeyRange.EVERYTHING_RANGE),Arrays.asList(KeyRange.EMPTY_RANGE));
 
-        rowKeyRanges1=Arrays.asList(
-                PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(2),
-                            true,
-                            PInteger.INSTANCE.toBytes(5),
-                            true),
-                PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(8),
-                            true,
-                            KeyRange.UNBOUND,
-                            false));
-        rowKeyRanges2=Arrays.asList(
-                PInteger.INSTANCE.getKeyRange(
-                        KeyRange.UNBOUND,
-                        false,
-                        PInteger.INSTANCE.toBytes(4),
-                        true),
-                PInteger.INSTANCE.getKeyRange(
-                        PInteger.INSTANCE.toBytes(7),
-                        true,
-                        PInteger.INSTANCE.toBytes(10),
-                        true),
-                PInteger.INSTANCE.getKeyRange(
-                    PInteger.INSTANCE.toBytes(13),
-                    true,
-                    PInteger.INSTANCE.toBytes(14),
-                    true),
-                PInteger.INSTANCE.getKeyRange(
-                    PInteger.INSTANCE.toBytes(19),
-                    true,
-                    KeyRange.UNBOUND,
-                    false)
-                );
-        expected=Arrays.asList(
-                PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(2),
-                            true,
-                            PInteger.INSTANCE.toBytes(4),
-                            true),
-                    PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(8),
-                            true,
-                            PInteger.INSTANCE.toBytes(10),
-                            true),
-                    PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(13),
-                            true,
-                            PInteger.INSTANCE.toBytes(14),
-                            true),
-                    PInteger.INSTANCE.getKeyRange(
-                            PInteger.INSTANCE.toBytes(19),
-                            true,
-                            KeyRange.UNBOUND,
-                            false)
-                );
+        rowKeyRanges1 = CreateKeyRangeList(
+                Arrays.asList(2, 5, 8, Integer.MAX_VALUE),
+                Arrays.asList(true, true, true, false));
+        rowKeyRanges2 = CreateKeyRangeList(
+                Arrays.asList(Integer.MIN_VALUE, 4, 7, 10, 13, 14, 19, Integer.MAX_VALUE),
+                Arrays.asList(false, true, true, true, true, true, true, false));
+        expected = CreateKeyRangeList(
+                Arrays.asList(2, 4, 8, 10, 13, 14, 19, Integer.MAX_VALUE),
+                Arrays.asList(true, true, true, true, true, true, true, false));
+        listIntersectAndAssert(rowKeyRanges1, rowKeyRanges2, expected);
+
+        rowKeyRanges1 = CreateKeyRangeList(
+                Arrays.asList(3, 5, 5, 6),
+                Arrays.asList(true, false, true, false));
+        rowKeyRanges2 = CreateKeyRangeList(
+                Arrays.asList(3, 5, 6, 7),
+                Arrays.asList(true, true, true, true));
+        expected = CreateKeyRangeList(
+                Arrays.asList(3, 5),
+                Arrays.asList(true, true));
         listIntersectAndAssert(rowKeyRanges1, rowKeyRanges2, expected);
     }
 
+    @Test
+    public void testKeyRangeCompareUpperRange() throws Exception {
+        List<KeyRange> rowKeyRanges1 = CreateKeyRangeListWithFixedLowerRange(
+                Arrays.asList(Integer.MAX_VALUE, Integer.MAX_VALUE, 10000, 1001, 1000, 1000,
1000, 1000),
+                Arrays.asList(false, false, true, true, true, true, false, true));
+        List<KeyRange> rowKeyRanges2 = CreateKeyRangeListWithFixedLowerRange(
+                Arrays.asList(Integer.MAX_VALUE, 10000, Integer.MAX_VALUE, 1000, 1001, 1000,
1000, 1000),
+                Arrays.asList(false, false, false, true, true, true, false, false));
+        List<Integer> expectedResults = Arrays.asList(0, 1, -1, 1, -1, 0, 0, 1);
+        assertEquals(rowKeyRanges1.size(), rowKeyRanges2.size());
+        assertEquals(rowKeyRanges1.size(), expectedResults.size());
+
+        for (int i = 0; i < expectedResults.size(); i++) {
+            int compareResult = KeyRange.compareUpperRange(rowKeyRanges1.get(i), rowKeyRanges2.get(i));
+            assertEquals(expectedResults.get(i).intValue(), compareResult);
+        }
+    }
+
+    private static List<KeyRange> CreateKeyRangeListWithFixedLowerRange(List<Integer>
keys, List<Boolean> boundaryConditions) {
 
 Review comment:
   nit: function names start with lowercase letters.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message