You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2014/08/19 22:03:24 UTC
git commit: PHOENIX-1180 Rename test classes so they are properly
picked up by the test runner (Kyle Buzsaki)
Repository: phoenix
Updated Branches:
refs/heads/3.0 721cc6573 -> 05eb9a668
PHOENIX-1180 Rename test classes so they are properly picked up by the test runner (Kyle Buzsaki)
Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/05eb9a66
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/05eb9a66
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/05eb9a66
Branch: refs/heads/3.0
Commit: 05eb9a66872d99048bbc9431e2abb86805f40e74
Parents: 721cc65
Author: James Taylor <ja...@apache.org>
Authored: Tue Aug 19 13:03:12 2014 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Tue Aug 19 13:03:12 2014 -0700
----------------------------------------------------------------------
.../RoundFloorCeilExpressionsTest.java | 230 +++++++++++++++++++
.../RoundFloorCeilExpressionsUnitTests.java | 230 -------------------
.../phoenix/query/KeyRangeCoalesceTest.java | 161 +++++++++++++
.../phoenix/query/KeyRangeCoalesceTests.java | 161 -------------
.../phoenix/query/KeyRangeIntersectTest.java | 97 ++++++++
.../phoenix/query/KeyRangeIntersectTests.java | 97 --------
.../apache/phoenix/query/KeyRangeUnionTest.java | 97 ++++++++
.../phoenix/query/KeyRangeUnionTests.java | 97 --------
8 files changed, 585 insertions(+), 585 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsTest.java b/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsTest.java
new file mode 100644
index 0000000..55bcd7f
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsTest.java
@@ -0,0 +1,230 @@
+/*
+ * 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.expression;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.math.BigDecimal;
+import java.sql.Date;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
+import org.apache.phoenix.expression.function.CeilDateExpression;
+import org.apache.phoenix.expression.function.CeilDecimalExpression;
+import org.apache.phoenix.expression.function.FloorDateExpression;
+import org.apache.phoenix.expression.function.FloorDecimalExpression;
+import org.apache.phoenix.expression.function.RoundDateExpression;
+import org.apache.phoenix.expression.function.RoundDecimalExpression;
+import org.apache.phoenix.expression.function.TimeUnit;
+import org.apache.phoenix.schema.IllegalDataException;
+import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.util.DateUtil;
+import org.junit.Test;
+
+/**
+ *
+ * Unit tests for {@link RoundDecimalExpression}, {@link FloorDecimalExpression}
+ * and {@link CeilDecimalExpression}.
+ *
+ *
+ * @since 3.0.0
+ */
+public class RoundFloorCeilExpressionsTest {
+
+ @Test
+ public void testRoundDecimalExpression() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
+ Expression rde = RoundDecimalExpression.create(bd, 3);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof BigDecimal);
+ BigDecimal value = (BigDecimal)obj;
+ assertEquals(BigDecimal.valueOf(1.239), value);
+ }
+
+ @Test
+ public void testCeilDecimalExpression() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
+ Expression rde = CeilDecimalExpression.create(bd, 3);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof BigDecimal);
+ BigDecimal value = (BigDecimal)obj;
+ assertEquals(BigDecimal.valueOf(1.239), value);
+ }
+
+ @Test
+ public void testCeilDecimalExpressionNoop() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
+ Expression rde = CeilDecimalExpression.create(bd, 3);
+ assertEquals(rde, bd);
+ }
+
+ @Test
+ public void testFloorDecimalExpressionNoop() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
+ Expression rde = FloorDecimalExpression.create(bd, 3);
+ assertEquals(rde, bd);
+ }
+
+ @Test
+ public void testRoundDecimalExpressionNoop() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
+ Expression rde = RoundDecimalExpression.create(bd, 3);
+ assertEquals(rde, bd);
+ }
+
+ @Test
+ public void testFloorDecimalExpression() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
+ Expression rde = FloorDecimalExpression.create(bd, 3);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof BigDecimal);
+ BigDecimal value = (BigDecimal)obj;
+ assertEquals(BigDecimal.valueOf(1.238), value);
+ }
+
+ @Test
+ public void testRoundDecimalExpressionScaleParamValidation() throws Exception {
+ LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
+ LiteralExpression scale = LiteralExpression.newConstant("3", PDataType.VARCHAR);
+ List<Expression> exprs = new ArrayList<Expression>(2);
+ exprs.add(bd);
+ exprs.add(scale);
+ try {
+ RoundDecimalExpression.create(exprs);
+ fail("Evaluation should have failed because only an INTEGER is allowed for second param in a RoundDecimalExpression");
+ } catch(IllegalDataException e) {
+
+ }
+ }
+
+ @Test
+ public void testRoundDateExpression() throws Exception {
+ LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = RoundDateExpression.create(date, TimeUnit.DAY);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-02 00:00:00"), value);
+ }
+
+ @Test
+ public void testRoundDateExpressionWithMultiplier() throws Exception {
+ Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = RoundDateExpression.create(date, TimeUnit.MINUTE, 10);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-01 14:30:00"), value);
+ }
+
+ @Test
+ public void testCeilDateExpression() throws Exception {
+ LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = CeilDateExpression.create(date, TimeUnit.DAY);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-02 00:00:00"), value);
+ }
+
+ @Test
+ public void testCeilDateExpressionWithMultiplier() throws Exception {
+ Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = CeilDateExpression.create(date, TimeUnit.SECOND, 10);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-01 14:25:30"), value);
+ }
+
+ @Test
+ public void testFloorDateExpression() throws Exception {
+ LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = FloorDateExpression.create(date, TimeUnit.DAY);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-01 00:00:00"), value);
+ }
+
+ @Test
+ public void testFloorDateExpressionWithMultiplier() throws Exception {
+ Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ Expression rde = FloorDateExpression.create(date, TimeUnit.SECOND, 10);
+ ImmutableBytesWritable ptr = new ImmutableBytesWritable();
+ rde.evaluate(null, ptr);
+ Object obj = rde.getDataType().toObject(ptr);
+ assertTrue(obj instanceof Date);
+ Date value = (Date)obj;
+ assertEquals(DateUtil.parseDate("2012-01-01 14:25:20"), value);
+ }
+
+ /**
+ * Tests {@link RoundDateExpression} constructor check which only allows number of arguments between 2 and 3.
+ */
+ @Test
+ public void testRoundDateExpressionValidation_1() throws Exception {
+ LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ List<Expression> exprs = new ArrayList<Expression>(1);
+ exprs.add(date);
+ try {
+ RoundDateExpression.create(exprs);
+ fail("Instantiating a RoundDateExpression with only one argument should have failed.");
+ } catch(IllegalArgumentException e) {
+
+ }
+ }
+
+ /**
+ * Tests {@link RoundDateExpression} constructor for a valid value of time unit.
+ */
+ @Test
+ public void testRoundDateExpressionValidation_2() throws Exception {
+ LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
+ LiteralExpression timeUnit = LiteralExpression.newConstant("millis", PDataType.VARCHAR);
+ List<Expression> exprs = new ArrayList<Expression>(1);
+ exprs.add(date);
+ exprs.add(timeUnit);
+ try {
+ RoundDateExpression.create(exprs);
+ fail("Only a valid time unit represented by TimeUnit enum is allowed and millis is invalid.");
+ } catch(IllegalArgumentException e) {
+
+ }
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsUnitTests.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsUnitTests.java b/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsUnitTests.java
deleted file mode 100644
index c92fed4..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/expression/RoundFloorCeilExpressionsUnitTests.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*
- * 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.expression;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.phoenix.expression.function.CeilDateExpression;
-import org.apache.phoenix.expression.function.CeilDecimalExpression;
-import org.apache.phoenix.expression.function.FloorDateExpression;
-import org.apache.phoenix.expression.function.FloorDecimalExpression;
-import org.apache.phoenix.expression.function.RoundDateExpression;
-import org.apache.phoenix.expression.function.RoundDecimalExpression;
-import org.apache.phoenix.expression.function.TimeUnit;
-import org.apache.phoenix.schema.IllegalDataException;
-import org.apache.phoenix.schema.PDataType;
-import org.apache.phoenix.util.DateUtil;
-import org.junit.Test;
-
-/**
- *
- * Unit tests for {@link RoundDecimalExpression}, {@link FloorDecimalExpression}
- * and {@link CeilDecimalExpression}.
- *
- *
- * @since 3.0.0
- */
-public class RoundFloorCeilExpressionsUnitTests {
-
- @Test
- public void testRoundDecimalExpression() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
- Expression rde = RoundDecimalExpression.create(bd, 3);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof BigDecimal);
- BigDecimal value = (BigDecimal)obj;
- assertEquals(BigDecimal.valueOf(1.239), value);
- }
-
- @Test
- public void testCeilDecimalExpression() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
- Expression rde = CeilDecimalExpression.create(bd, 3);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof BigDecimal);
- BigDecimal value = (BigDecimal)obj;
- assertEquals(BigDecimal.valueOf(1.239), value);
- }
-
- @Test
- public void testCeilDecimalExpressionNoop() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
- Expression rde = CeilDecimalExpression.create(bd, 3);
- assertEquals(rde, bd);
- }
-
- @Test
- public void testFloorDecimalExpressionNoop() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
- Expression rde = FloorDecimalExpression.create(bd, 3);
- assertEquals(rde, bd);
- }
-
- @Test
- public void testRoundDecimalExpressionNoop() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(5, PDataType.INTEGER);
- Expression rde = RoundDecimalExpression.create(bd, 3);
- assertEquals(rde, bd);
- }
-
- @Test
- public void testFloorDecimalExpression() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
- Expression rde = FloorDecimalExpression.create(bd, 3);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof BigDecimal);
- BigDecimal value = (BigDecimal)obj;
- assertEquals(BigDecimal.valueOf(1.238), value);
- }
-
- @Test
- public void testRoundDecimalExpressionScaleParamValidation() throws Exception {
- LiteralExpression bd = LiteralExpression.newConstant(1.23898, PDataType.DECIMAL);
- LiteralExpression scale = LiteralExpression.newConstant("3", PDataType.VARCHAR);
- List<Expression> exprs = new ArrayList<Expression>(2);
- exprs.add(bd);
- exprs.add(scale);
- try {
- RoundDecimalExpression.create(exprs);
- fail("Evaluation should have failed because only an INTEGER is allowed for second param in a RoundDecimalExpression");
- } catch(IllegalDataException e) {
-
- }
- }
-
- @Test
- public void testRoundDateExpression() throws Exception {
- LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = RoundDateExpression.create(date, TimeUnit.DAY);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-02 00:00:00"), value);
- }
-
- @Test
- public void testRoundDateExpressionWithMultiplier() throws Exception {
- Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = RoundDateExpression.create(date, TimeUnit.MINUTE, 10);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-01 14:30:00"), value);
- }
-
- @Test
- public void testCeilDateExpression() throws Exception {
- LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = CeilDateExpression.create(date, TimeUnit.DAY);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-02 00:00:00"), value);
- }
-
- @Test
- public void testCeilDateExpressionWithMultiplier() throws Exception {
- Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = CeilDateExpression.create(date, TimeUnit.SECOND, 10);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-01 14:25:30"), value);
- }
-
- @Test
- public void testFloorDateExpression() throws Exception {
- LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = FloorDateExpression.create(date, TimeUnit.DAY);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-01 00:00:00"), value);
- }
-
- @Test
- public void testFloorDateExpressionWithMultiplier() throws Exception {
- Expression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- Expression rde = FloorDateExpression.create(date, TimeUnit.SECOND, 10);
- ImmutableBytesWritable ptr = new ImmutableBytesWritable();
- rde.evaluate(null, ptr);
- Object obj = rde.getDataType().toObject(ptr);
- assertTrue(obj instanceof Date);
- Date value = (Date)obj;
- assertEquals(DateUtil.parseDate("2012-01-01 14:25:20"), value);
- }
-
- /**
- * Tests {@link RoundDateExpression} constructor check which only allows number of arguments between 2 and 3.
- */
- @Test
- public void testRoundDateExpressionValidation_1() throws Exception {
- LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- List<Expression> exprs = new ArrayList<Expression>(1);
- exprs.add(date);
- try {
- RoundDateExpression.create(exprs);
- fail("Instantiating a RoundDateExpression with only one argument should have failed.");
- } catch(IllegalArgumentException e) {
-
- }
- }
-
- /**
- * Tests {@link RoundDateExpression} constructor for a valid value of time unit.
- */
- @Test
- public void testRoundDateExpressionValidation_2() throws Exception {
- LiteralExpression date = LiteralExpression.newConstant(DateUtil.parseDate("2012-01-01 14:25:28"), PDataType.DATE);
- LiteralExpression timeUnit = LiteralExpression.newConstant("millis", PDataType.VARCHAR);
- List<Expression> exprs = new ArrayList<Expression>(1);
- exprs.add(date);
- exprs.add(timeUnit);
- try {
- RoundDateExpression.create(exprs);
- fail("Only a valid time unit represented by TimeUnit enum is allowed and millis is invalid.");
- } catch(IllegalArgumentException e) {
-
- }
- }
-
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTest.java
new file mode 100644
index 0000000..7fe7319
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTest.java
@@ -0,0 +1,161 @@
+/*
+ * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
+import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
+import static java.util.Arrays.asList;
+import static org.apache.hadoop.hbase.util.Bytes.toBytes;
+
+import java.util.*;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.apache.phoenix.schema.PDataType;
+
+@RunWith(Parameterized.class)
+public class KeyRangeCoalesceTest extends TestCase {
+ private static final Random RANDOM = new Random(1);
+ private final List<KeyRange> expected, input;
+
+ public KeyRangeCoalesceTest(List<KeyRange> expected, List<KeyRange> input) {
+ this.expected = expected;
+ this.input = input;
+ }
+
+ @Parameters(name="{0} coalesces to {1}")
+ public static Collection<?> data() {
+ return Arrays.asList(new Object[][] {
+ {expect(
+ EMPTY_RANGE
+ ),
+ input(
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("Z"), true)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), true)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), true)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("A"), true),
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("A"), true),
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
+ PDataType.CHAR.getKeyRange(toBytes("B"), false, toBytes("Z"), false)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
+ PDataType.CHAR.getKeyRange(toBytes("B"), false, toBytes("Z"), false)
+ )},
+ {expect(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("Z"), false)
+ ),
+ input(
+ PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
+ PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
+ )},
+ {expect(
+ EVERYTHING_RANGE
+ ),
+ input(
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE
+ )},
+ {expect(
+ EVERYTHING_RANGE
+ ),
+ input(
+ EVERYTHING_RANGE
+ )},
+ {expect(
+ EVERYTHING_RANGE
+ ),
+ input(
+ EMPTY_RANGE,
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE
+ )},
+ {expect(
+ EMPTY_RANGE
+ ),
+ input(
+ EMPTY_RANGE
+ )}
+ });
+ }
+ @Test
+ public void coalesce() {
+ assertEquals(expected, KeyRange.coalesce(input));
+ List<KeyRange> tmp = new ArrayList<KeyRange>(input);
+ Collections.reverse(tmp);
+ assertEquals(expected, KeyRange.coalesce(input));
+ Collections.shuffle(tmp, RANDOM);
+ assertEquals(expected, KeyRange.coalesce(input));
+ }
+
+ private static final List<KeyRange> expect(KeyRange... kr) {
+ return asList(kr);
+ }
+
+ private static final List<KeyRange> input(KeyRange... kr) {
+ return asList(kr);
+ }
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTests.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTests.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTests.java
deleted file mode 100644
index c7f0ce0..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeCoalesceTests.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
-import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
-import static java.util.Arrays.asList;
-import static org.apache.hadoop.hbase.util.Bytes.toBytes;
-
-import java.util.*;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import org.apache.phoenix.schema.PDataType;
-
-@RunWith(Parameterized.class)
-public class KeyRangeCoalesceTests extends TestCase {
- private static final Random RANDOM = new Random(1);
- private final List<KeyRange> expected, input;
-
- public KeyRangeCoalesceTests(List<KeyRange> expected, List<KeyRange> input) {
- this.expected = expected;
- this.input = input;
- }
-
- @Parameters(name="{0} coalesces to {1}")
- public static Collection<?> data() {
- return Arrays.asList(new Object[][] {
- {expect(
- EMPTY_RANGE
- ),
- input(
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("Z"), true)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), true)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), true)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("D"), true),
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("Z"), true)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("A"), true),
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("A"), true),
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
- PDataType.CHAR.getKeyRange(toBytes("B"), false, toBytes("Z"), false)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
- PDataType.CHAR.getKeyRange(toBytes("B"), false, toBytes("Z"), false)
- )},
- {expect(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("Z"), false)
- ),
- input(
- PDataType.CHAR.getKeyRange(toBytes("A"), true, toBytes("B"), false),
- PDataType.CHAR.getKeyRange(toBytes("B"), true, toBytes("Z"), false)
- )},
- {expect(
- EVERYTHING_RANGE
- ),
- input(
- EVERYTHING_RANGE,
- EVERYTHING_RANGE
- )},
- {expect(
- EVERYTHING_RANGE
- ),
- input(
- EVERYTHING_RANGE
- )},
- {expect(
- EVERYTHING_RANGE
- ),
- input(
- EMPTY_RANGE,
- EVERYTHING_RANGE,
- EVERYTHING_RANGE
- )},
- {expect(
- EMPTY_RANGE
- ),
- input(
- EMPTY_RANGE
- )}
- });
- }
- @Test
- public void coalesce() {
- assertEquals(expected, KeyRange.coalesce(input));
- List<KeyRange> tmp = new ArrayList<KeyRange>(input);
- Collections.reverse(tmp);
- assertEquals(expected, KeyRange.coalesce(input));
- Collections.shuffle(tmp, RANDOM);
- assertEquals(expected, KeyRange.coalesce(input));
- }
-
- private static final List<KeyRange> expect(KeyRange... kr) {
- return asList(kr);
- }
-
- private static final List<KeyRange> input(KeyRange... kr) {
- return asList(kr);
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTest.java
new file mode 100644
index 0000000..f34b956
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
+import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
+import static org.apache.hadoop.hbase.util.Bytes.toBytes;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.apache.phoenix.schema.PDataType;
+
+@RunWith(Parameterized.class)
+public class KeyRangeIntersectTest extends TestCase {
+ private final KeyRange a, b, intersection;
+
+ public KeyRangeIntersectTest(KeyRange a, KeyRange b, KeyRange intersection) {
+ this.a = a;
+ this.b = b;
+ this.intersection = intersection;
+ }
+
+ @Parameters(name="intersection of {0} and {1} is {2}")
+ public static Collection<?> data() {
+ return Arrays.asList(new Object[][] {
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("E"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
+ PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("E"), false)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
+ PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
+ EMPTY_RANGE
+ },
+ {
+ EVERYTHING_RANGE,
+ PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
+ },
+ {
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE,
+ },
+ {
+ EMPTY_RANGE,
+ EVERYTHING_RANGE,
+ EMPTY_RANGE
+ },
+ {
+ EMPTY_RANGE,
+ PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
+ EMPTY_RANGE
+ },
+ });
+ }
+ @Test
+ public void intersect() {
+ assertEquals(intersection, a.intersect(b));
+ assertEquals(intersection, b.intersect(a));
+ }
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTests.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTests.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTests.java
deleted file mode 100644
index 7d311cf..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeIntersectTests.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
-import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
-import static org.apache.hadoop.hbase.util.Bytes.toBytes;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import org.apache.phoenix.schema.PDataType;
-
-@RunWith(Parameterized.class)
-public class KeyRangeIntersectTests extends TestCase {
- private final KeyRange a, b, intersection;
-
- public KeyRangeIntersectTests(KeyRange a, KeyRange b, KeyRange intersection) {
- this.a = a;
- this.b = b;
- this.intersection = intersection;
- }
-
- @Parameters(name="intersection of {0} and {1} is {2}")
- public static Collection<?> data() {
- return Arrays.asList(new Object[][] {
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("E"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
- PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), false, toBytes("E"), false)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
- PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
- EMPTY_RANGE
- },
- {
- EVERYTHING_RANGE,
- PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
- },
- {
- EVERYTHING_RANGE,
- EVERYTHING_RANGE,
- EVERYTHING_RANGE,
- },
- {
- EMPTY_RANGE,
- EVERYTHING_RANGE,
- EMPTY_RANGE
- },
- {
- EMPTY_RANGE,
- PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
- EMPTY_RANGE
- },
- });
- }
- @Test
- public void intersect() {
- assertEquals(intersection, a.intersect(b));
- assertEquals(intersection, b.intersect(a));
- }
-}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTest.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTest.java
new file mode 100644
index 0000000..f280bbd
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTest.java
@@ -0,0 +1,97 @@
+/*
+ * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
+import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
+import static org.apache.hadoop.hbase.util.Bytes.toBytes;
+
+import java.util.Arrays;
+import java.util.Collection;
+
+import junit.framework.TestCase;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
+
+import org.apache.phoenix.schema.PDataType;
+
+@RunWith(Parameterized.class)
+public class KeyRangeUnionTest extends TestCase {
+ private final KeyRange a, b, union;
+
+ public KeyRangeUnionTest(KeyRange a, KeyRange b, KeyRange union) {
+ this.a = a;
+ this.b = b;
+ this.union = union;
+ }
+
+ @Parameters(name="union of {0} and {1} is {2}")
+ public static Collection<?> data() {
+ return Arrays.asList(new Object[][] {
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("F"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
+ PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("F"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
+ PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
+ },
+ {
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
+ EMPTY_RANGE,
+ PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
+ },
+ {
+ EVERYTHING_RANGE,
+ PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
+ EVERYTHING_RANGE,
+ },
+ {
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE,
+ },
+ {
+ EMPTY_RANGE,
+ EVERYTHING_RANGE,
+ EVERYTHING_RANGE,
+ },
+ });
+ }
+ @Test
+ public void union() {
+ assertEquals(union, a.union(b));
+ assertEquals(union, b.union(a));
+ }
+}
http://git-wip-us.apache.org/repos/asf/phoenix/blob/05eb9a66/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTests.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTests.java b/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTests.java
deleted file mode 100644
index 5a442eb..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/KeyRangeUnionTests.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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 org.apache.phoenix.query.KeyRange.EMPTY_RANGE;
-import static org.apache.phoenix.query.KeyRange.EVERYTHING_RANGE;
-import static org.apache.hadoop.hbase.util.Bytes.toBytes;
-
-import java.util.Arrays;
-import java.util.Collection;
-
-import junit.framework.TestCase;
-
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-import org.apache.phoenix.schema.PDataType;
-
-@RunWith(Parameterized.class)
-public class KeyRangeUnionTests extends TestCase {
- private final KeyRange a, b, union;
-
- public KeyRangeUnionTests(KeyRange a, KeyRange b, KeyRange union) {
- this.a = a;
- this.b = b;
- this.union = union;
- }
-
- @Parameters(name="union of {0} and {1} is {2}")
- public static Collection<?> data() {
- return Arrays.asList(new Object[][] {
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("F"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("F"), true),
- PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("F"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
- PDataType.CHAR.getKeyRange(toBytes("D"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), false, toBytes("E"), false),
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true),
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), true)
- },
- {
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
- EMPTY_RANGE,
- PDataType.CHAR.getKeyRange(toBytes("C"), true, toBytes("E"), false),
- },
- {
- EVERYTHING_RANGE,
- PDataType.CHAR.getKeyRange(toBytes("E"), false, toBytes("F"), true),
- EVERYTHING_RANGE,
- },
- {
- EVERYTHING_RANGE,
- EVERYTHING_RANGE,
- EVERYTHING_RANGE,
- },
- {
- EMPTY_RANGE,
- EVERYTHING_RANGE,
- EVERYTHING_RANGE,
- },
- });
- }
- @Test
- public void union() {
- assertEquals(union, a.union(b));
- assertEquals(union, b.union(a));
- }
-}