phoenix-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [phoenix] dbwong commented on a change in pull request #485: Add common utility function ScanUtil.splityKeyRangesByBoundaries()
Date Wed, 17 Apr 2019 01:13:10 GMT
dbwong commented on a change in pull request #485: Add common utility function ScanUtil.splityKeyRangesByBoundaries()
URL: https://github.com/apache/phoenix/pull/485#discussion_r276047907
 
 

 ##########
 File path: phoenix-core/src/test/java/org/apache/phoenix/query/SplitKeyRangesByBoundariesTest.java
 ##########
 @@ -0,0 +1,214 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.phoenix.query;
+
+import static java.util.Arrays.asList;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Lists;
+import junit.framework.TestCase;
+
+import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.schema.types.PInteger;
+import org.apache.phoenix.util.ScanUtil;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+@RunWith(Parameterized.class)
+public class SplitKeyRangesByBoundariesTest extends TestCase {
+    private final List<List<KeyRange>> expected;
+    private final List<byte[]> boundaries;
+    private final List<KeyRange> keyRanges;
+
+    public SplitKeyRangesByBoundariesTest(List<List<KeyRange>> expected, List<byte[]>
boundaries,
+            List<KeyRange> keyRanges) {
+        this.expected = expected;
+        this.boundaries = boundaries;
+        this.keyRanges = keyRanges;
+    }
+
+    @Parameters(name = "{0} {1} {2}") public static Collection<Object> data() {
+        List<Object> testCases = Lists.newArrayList();
+
+        // 1, region boundaries is null, return null
+        testCases.addAll(Arrays.asList(new Object[][] { { expected(null), boundaries(null),
+                keyRanges(PInteger.INSTANCE
+                        .getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(2), false)) }
}));
+
+        // 2, key ranges is null, return null
+        testCases.addAll(Arrays.asList(new Object[][] {
+                { expected(null), boundaries(Bytes.toBytes(2)), keyRanges(null) } }));
+
+        // 3, empty key ranges, return null
+        testCases.addAll(Arrays.asList(new Object[][] {
+                { expected(null), boundaries(Bytes.toBytes(2)), keyRanges() } }));
+
+        // 4, single regions, single key range
+        testCases.addAll(Arrays.asList(new Object[][] {
+                {
+                        expected(new KeyRange[][] {
+                                { PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(5),
false), }, }),
+                        boundaries(),
+                        keyRanges(PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(5),
false))
+                } }));
+
+        // 5, single regions, multiple key ranges
+        testCases.addAll(Arrays.asList(new Object[][] {
+                {
+                        expected(new KeyRange[][] {
+                                {
+                                        PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true,
Bytes.toBytes(2), false),
+                                        PInteger.INSTANCE.getKeyRange(Bytes.toBytes(3), true,
Bytes.toBytes(5), false),
+                                },
+                        }),
+                        boundaries(),
+                        keyRanges(
+                                PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(2),
false),
+                                PInteger.INSTANCE.getKeyRange(Bytes.toBytes(3), true, Bytes.toBytes(5),
false)
+                        )
+                } }));
+
+        // 6, Multiple regions, one key range covers all regions.
+        testCases.addAll(Arrays.asList(new Object[][] {
+                {
+                        expected(new KeyRange[][] {
+                            { PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(2),
false), },
+                            { PInteger.INSTANCE.getKeyRange(Bytes.toBytes(2), true, Bytes.toBytes(4),
false), },
+                            { PInteger.INSTANCE.getKeyRange(Bytes.toBytes(4), true, Bytes.toBytes(5),
false), }, }),
+                        boundaries(Bytes.toBytes(2), Bytes.toBytes(4)),
+                        keyRanges(PInteger.INSTANCE.getKeyRange(Bytes.toBytes(1), true, Bytes.toBytes(5),
false))
+                } }));
+
+        // 7, Multiple regions, one key range is in the first region.
+        testCases.addAll(Arrays.asList(new Object[][] {
+                {
+                        expected(new KeyRange[][] {
 
 Review comment:
   I didn't see anything in the transform function ARRAY_TO_LIST that i think is handling
this?

----------------------------------------------------------------
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