phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ndimi...@apache.org
Subject [01/22] phoenix git commit: PHOENIX-1514 Break up PDataType Enum
Date Thu, 18 Dec 2014 00:11:39 GMT
Repository: phoenix
Updated Branches:
  refs/heads/master a8d9eec60 -> 04ef859b7


http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java
index 444dd87..13e3f5e 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/ByteUtilTest.java
@@ -20,11 +20,9 @@ package org.apache.phoenix.util;
 import static org.junit.Assert.*;
 
 import org.apache.hadoop.hbase.util.Bytes;
+import org.apache.phoenix.schema.types.PInteger;
 import org.junit.Test;
 
-import org.apache.phoenix.schema.PDataType;
-
-
 public class ByteUtilTest {
 
     @Test
@@ -57,9 +55,9 @@ public class ByteUtilTest {
         byte[] nextKey = ByteUtil.nextKey(key);
         byte[] expectedKey = new byte[] {2,(byte)0};
         assertArrayEquals(expectedKey, nextKey); 
-        key = ByteUtil.concat(Bytes.toBytes("00D300000000XHP"), PDataType.INTEGER.toBytes(Integer.MAX_VALUE));
+        key = ByteUtil.concat(Bytes.toBytes("00D300000000XHP"), PInteger.INSTANCE.toBytes(Integer.MAX_VALUE));
         nextKey = ByteUtil.nextKey(key);
-        expectedKey = ByteUtil.concat(Bytes.toBytes("00D300000000XHQ"), PDataType.INTEGER.toBytes(Integer.MIN_VALUE));
+        expectedKey = ByteUtil.concat(Bytes.toBytes("00D300000000XHQ"), PInteger.INSTANCE.toBytes(Integer.MIN_VALUE));
         assertArrayEquals(expectedKey, nextKey);
         
         key = new byte[] {(byte)255};

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/PhoenixRuntimeTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/PhoenixRuntimeTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/PhoenixRuntimeTest.java
index 847aed9..a642e80 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/PhoenixRuntimeTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/PhoenixRuntimeTest.java
@@ -35,7 +35,7 @@ import org.apache.commons.lang.exception.ExceptionUtils;
 import org.apache.hadoop.hbase.util.Pair;
 import org.apache.phoenix.compile.QueryPlan;
 import org.apache.phoenix.query.BaseConnectionlessQueryTest;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
 import org.junit.Test;
 
 import com.google.common.collect.ImmutableList;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java b/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
index b1246b8..991ee72 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/ScanUtilTest.java
@@ -26,8 +26,10 @@ import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.KeyRange.Bound;
 import org.apache.phoenix.query.QueryConstants;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PChar;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.PDatum;
+import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.phoenix.schema.RowKeySchema;
 import org.apache.phoenix.schema.RowKeySchema.RowKeySchemaBuilder;
 import org.apache.phoenix.schema.SortOrder;
@@ -62,7 +64,7 @@ public class ScanUtilTest {
                     }
                     @Override
                     public PDataType getDataType() {
-                        return PDataType.CHAR;
+                        return PChar.INSTANCE;
                     }
                     @Override
                     public Integer getMaxLength() {
@@ -85,7 +87,7 @@ public class ScanUtilTest {
                     }
                     @Override
                     public PDataType getDataType() {
-                        return PDataType.VARCHAR;
+                        return PVarchar.INSTANCE;
                     }
                     @Override
                     public Integer getMaxLength() {
@@ -124,181 +126,181 @@ public class ScanUtilTest {
         // 1, Lower bound, all single keys, all inclusive.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a1A"),
+                PChar.INSTANCE.toBytes("a1A"),
                 Bound.LOWER
                 ));
         // 2, Lower bound, all range keys, all inclusive.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a1A"),
+                PChar.INSTANCE.toBytes("a1A"),
                 Bound.LOWER
                 ));
         // 3, Lower bound, mixed single and range keys, all inclusive.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a1A"),
+                PChar.INSTANCE.toBytes("a1A"),
                 Bound.LOWER
                 ));
         // 4, Lower bound, all range key, all exclusive on lower bound.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), false, Bytes.toBytes("b"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), false, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), false, Bytes.toBytes("b"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), false, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("b2B"),
+                PChar.INSTANCE.toBytes("b2B"),
                 Bound.LOWER
                 ));
         // 5, Lower bound, all range key, some exclusive.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), false, Bytes.toBytes("b"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), false, Bytes.toBytes("b"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("b1B"),
+                PChar.INSTANCE.toBytes("b1B"),
                 Bound.LOWER
                 ));
         // 6, Lower bound, mixed single and range key, mixed inclusive and exclusive.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a1B"),
+                PChar.INSTANCE.toBytes("a1B"),
                 Bound.LOWER
                 ));
         // 7, Lower bound, unbound key in the middle, fixed length.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
                         KeyRange.EVERYTHING_RANGE,},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), false, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a"),
+                PChar.INSTANCE.toBytes("a"),
                 Bound.LOWER
                 ));
         // 8, Lower bound, unbound key in the middle, variable length.
         testCases.addAll(
                 foreach(new KeyRange[][]{{
-                        PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                        PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
                             KeyRange.EVERYTHING_RANGE,}},
                     new int[] {1,1},
-                    PDataType.CHAR.toBytes("a"),
+                    PChar.INSTANCE.toBytes("a"),
                     Bound.LOWER
                     ));
         // 9, Lower bound, unbound key at end, variable length.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
                         KeyRange.EVERYTHING_RANGE,},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a"),
+                PChar.INSTANCE.toBytes("a"),
                 Bound.LOWER
                 ));
         // 10, Upper bound, all single keys, all inclusive, increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("A"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("a1B"),
+                PChar.INSTANCE.toBytes("a1B"),
                 Bound.UPPER
                 ));
         // 11, Upper bound, all range keys, all inclusive, increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("b2C"),
+                PChar.INSTANCE.toBytes("b2C"),
                 Bound.UPPER
                 ));
         // 12, Upper bound, all range keys, all exclusive, no increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
false),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
false),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
false),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
false),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
false),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
false),}},
                 new int[] {1,1,1},
-                PDataType.CHAR.toBytes("b2B"),
+                PChar.INSTANCE.toBytes("b2B"),
                 Bound.UPPER
                 ));
         // 13, Upper bound, single inclusive, range inclusive, increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
true),}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("a3"),
+                PChar.INSTANCE.toBytes("a3"),
                 Bound.UPPER
                 ));
         // 14, Upper bound, range exclusive, single inclusive, increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
false),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
false),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("b2"),
+                PChar.INSTANCE.toBytes("b2"),
                 Bound.UPPER
                 ));
         // 15, Upper bound, range inclusive, single inclusive, increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("b"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("1"),
true),}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("b2"),
+                PChar.INSTANCE.toBytes("b2"),
                 Bound.UPPER
                 ));
         // 16, Upper bound, single inclusive, range exclusive, no increment at end.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
false),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("1"), true, Bytes.toBytes("2"),
false),}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("a2"),
+                PChar.INSTANCE.toBytes("a2"),
                 Bound.UPPER
                 ));
         // 17, Upper bound, unbound key, fixed length;
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
                         KeyRange.EVERYTHING_RANGE,}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("b"),
+                PChar.INSTANCE.toBytes("b"),
                 Bound.UPPER
                 ));
         // 18, Upper bound, unbound key, variable length;
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
                     KeyRange.EVERYTHING_RANGE,}},
                 new int[] {1,1},
-                PDataType.CHAR.toBytes("b"),
+                PChar.INSTANCE.toBytes("b"),
                 Bound.UPPER
                 ));
         // 19, Upper bound, keys wrapped around when incrementing.
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                PDataType.CHAR.getKeyRange(new byte[] {-1}, true, new byte[] {-1}, true)},{
-                PDataType.CHAR.getKeyRange(new byte[] {-1}, true, new byte[] {-1}, true)}},
+                PChar.INSTANCE.getKeyRange(new byte[] {-1}, true, new byte[] {-1}, true)},{
+                PChar.INSTANCE.getKeyRange(new byte[] {-1}, true, new byte[] {-1}, true)}},
                 new int[] {1, 1},
                 ByteUtil.EMPTY_BYTE_ARRAY,
                 Bound.UPPER
@@ -306,10 +308,10 @@ public class ScanUtilTest {
         // 20, Variable length
         testCases.addAll(
             foreach(new KeyRange[][]{{
-                    PDataType.CHAR.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
-                    PDataType.VARCHAR.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
+                    PChar.INSTANCE.getKeyRange(Bytes.toBytes("a"), true, Bytes.toBytes("a"),
true),},{
+                    PVarchar.INSTANCE.getKeyRange(Bytes.toBytes("A"), true, Bytes.toBytes("B"),
true),}},
                 new int[] {1,0},
-                ByteUtil.nextKey(ByteUtil.concat(PDataType.VARCHAR.toBytes("aB"), QueryConstants.SEPARATOR_BYTE_ARRAY)),
+                ByteUtil.nextKey(ByteUtil.concat(PVarchar.INSTANCE.toBytes("aB"), QueryConstants.SEPARATOR_BYTE_ARRAY)),
                 Bound.UPPER
                 ));
         return testCases;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index f1e98f8..8c55f1b 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@ -77,7 +77,7 @@ import org.apache.phoenix.parse.LikeParseNode.LikeType;
 import org.apache.phoenix.query.KeyRange;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.schema.PColumn;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.schema.RowKeyValueAccessor;
 import org.apache.phoenix.schema.tuple.Tuple;
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/CsvUpsertExecutorTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/csv/CsvUpsertExecutorTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/CsvUpsertExecutorTest.java
index 21b985c..84f44f3 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/csv/CsvUpsertExecutorTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/CsvUpsertExecutorTest.java
@@ -24,8 +24,9 @@ import org.apache.commons.csv.CSVFormat;
 import org.apache.commons.csv.CSVParser;
 import org.apache.commons.csv.CSVRecord;
 import org.apache.phoenix.query.BaseConnectionlessQueryTest;
-import org.apache.phoenix.schema.PArrayDataType;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PInteger;
+import org.apache.phoenix.schema.types.PIntegerArray;
+import org.apache.phoenix.schema.types.PArrayDataType;
 import org.apache.phoenix.util.ColumnInfo;
 import org.junit.After;
 import org.junit.Before;
@@ -60,7 +61,7 @@ public class CsvUpsertExecutorTest extends BaseConnectionlessQueryTest {
                 new ColumnInfo("ID", Types.BIGINT),
                 new ColumnInfo("NAME", Types.VARCHAR),
                 new ColumnInfo("AGE", Types.INTEGER),
-                new ColumnInfo("VALUES", PDataType.INTEGER_ARRAY.getSqlType()));
+                new ColumnInfo("VALUES", PIntegerArray.INSTANCE.getSqlType()));
 
         preparedStatement = mock(PreparedStatement.class);
         upsertListener = mock(CsvUpsertExecutor.UpsertListener.class);
@@ -83,7 +84,7 @@ public class CsvUpsertExecutorTest extends BaseConnectionlessQueryTest {
         verify(preparedStatement).setObject(1, Long.valueOf(123L));
         verify(preparedStatement).setObject(2, "NameValue");
         verify(preparedStatement).setObject(3, Integer.valueOf(42));
-        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PDataType.INTEGER,
new Object[]{1,2,3}));
+        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PInteger.INSTANCE,
new Object[]{1,2,3}));
         verify(preparedStatement).execute();
         verifyNoMoreInteractions(preparedStatement);
     }
@@ -108,7 +109,7 @@ public class CsvUpsertExecutorTest extends BaseConnectionlessQueryTest
{
         verify(preparedStatement).setObject(1, Long.valueOf(123L));
         verify(preparedStatement).setObject(2, "NameValue");
         verify(preparedStatement).setObject(3, Integer.valueOf(42));
-        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PDataType.INTEGER,
new Object[]{1,2,3}));
+        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PInteger.INSTANCE,
new Object[]{1,2,3}));
         verify(preparedStatement).execute();
         verifyNoMoreInteractions(preparedStatement);
     }
@@ -123,7 +124,7 @@ public class CsvUpsertExecutorTest extends BaseConnectionlessQueryTest
{
         verify(preparedStatement).setObject(1, Long.valueOf(123L));
         verify(preparedStatement).setObject(2, "NameValue");
         verify(preparedStatement).setNull(3, columnInfoList.get(2).getSqlType());
-        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PDataType.INTEGER,
new Object[]{1,2,3}));
+        verify(preparedStatement).setObject(4, PArrayDataType.instantiatePhoenixArray(PInteger.INSTANCE,
new Object[]{1,2,3}));
         verify(preparedStatement).execute();
         verifyNoMoreInteractions(preparedStatement);
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/StringToArrayConverterTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/csv/StringToArrayConverterTest.java
b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/StringToArrayConverterTest.java
index 8f2b0e5..25d9d80 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/csv/StringToArrayConverterTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/csv/StringToArrayConverterTest.java
@@ -26,7 +26,8 @@ import java.sql.DriverManager;
 import java.sql.SQLException;
 
 import org.apache.phoenix.query.BaseConnectionlessQueryTest;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PInteger;
+import org.apache.phoenix.schema.types.PVarchar;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -39,7 +40,7 @@ public class StringToArrayConverterTest extends BaseConnectionlessQueryTest
{
     @Before
     public void setUp() throws SQLException {
         conn = DriverManager.getConnection(getUrl());
-        converter = new StringToArrayConverter(conn, ":", PDataType.VARCHAR);
+        converter = new StringToArrayConverter(conn, ":", PVarchar.INSTANCE);
     }
 
     @After
@@ -73,7 +74,7 @@ public class StringToArrayConverterTest extends BaseConnectionlessQueryTest
{
     @Test
     public void testToArray_IntegerValues() throws SQLException {
         StringToArrayConverter intArrayConverter = new StringToArrayConverter(
-                                                            conn, ":", PDataType.INTEGER);
+            conn, ":", PInteger.INSTANCE);
         Array intArray = intArrayConverter.toArray("1:2:3");
         assertArrayEquals(
                 new int[]{1, 2, 3},

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/RegexEventSerializer.java
----------------------------------------------------------------------
diff --git a/phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/RegexEventSerializer.java
b/phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/RegexEventSerializer.java
index cb188e2..6562eb7 100644
--- a/phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/RegexEventSerializer.java
+++ b/phoenix-flume/src/main/java/org/apache/phoenix/flume/serializer/RegexEventSerializer.java
@@ -35,7 +35,7 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
 
 public class RegexEventSerializer extends BaseEventSerializer {
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtil.java
b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtil.java
index 4f7d776..69bcd73 100644
--- a/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtil.java
+++ b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/PhoenixPigSchemaUtil.java
@@ -28,7 +28,7 @@ import org.apache.commons.logging.LogFactory;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil;
 import org.apache.phoenix.mapreduce.util.PhoenixConfigurationUtil.SchemaType;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.util.ColumnInfo;
 import org.apache.pig.ResourceSchema;
 import org.apache.pig.ResourceSchema.ResourceFieldSchema;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/TypeUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/TypeUtil.java b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/TypeUtil.java
index 1da2d01..bdee3a4 100644
--- a/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/TypeUtil.java
+++ b/phoenix-pig/src/main/java/org/apache/phoenix/pig/util/TypeUtil.java
@@ -28,7 +28,31 @@ import java.util.List;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.phoenix.pig.writable.PhoenixPigDBWritable;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PBinary;
+import org.apache.phoenix.schema.types.PChar;
+import org.apache.phoenix.schema.types.PDecimal;
+import org.apache.phoenix.schema.types.PBoolean;
+import org.apache.phoenix.schema.types.PDataType;
+import org.apache.phoenix.schema.types.PDate;
+import org.apache.phoenix.schema.types.PDouble;
+import org.apache.phoenix.schema.types.PFloat;
+import org.apache.phoenix.schema.types.PInteger;
+import org.apache.phoenix.schema.types.PLong;
+import org.apache.phoenix.schema.types.PSmallint;
+import org.apache.phoenix.schema.types.PTime;
+import org.apache.phoenix.schema.types.PTimestamp;
+import org.apache.phoenix.schema.types.PTinyint;
+import org.apache.phoenix.schema.types.PUnsignedDate;
+import org.apache.phoenix.schema.types.PUnsignedDouble;
+import org.apache.phoenix.schema.types.PUnsignedFloat;
+import org.apache.phoenix.schema.types.PUnsignedInt;
+import org.apache.phoenix.schema.types.PUnsignedLong;
+import org.apache.phoenix.schema.types.PUnsignedSmallint;
+import org.apache.phoenix.schema.types.PUnsignedTime;
+import org.apache.phoenix.schema.types.PUnsignedTimestamp;
+import org.apache.phoenix.schema.types.PUnsignedTinyint;
+import org.apache.phoenix.schema.types.PVarbinary;
+import org.apache.phoenix.schema.types.PVarchar;
 import org.apache.pig.PigException;
 import org.apache.pig.ResourceSchema.ResourceFieldSchema;
 import org.apache.pig.backend.hadoop.hbase.HBaseBinaryConverter;
@@ -47,7 +71,7 @@ public final class TypeUtil {
 	
     private static final Log LOG = LogFactory.getLog(TypeUtil.class);
     private static final HBaseBinaryConverter binaryConverter = new HBaseBinaryConverter
();
-	private static final ImmutableMap<PDataType,Byte> phoenixTypeToPigDataType = init();

+	private static final ImmutableMap<PDataType,Byte> phoenixTypeToPigDataType = init();
 	
 	private TypeUtil(){
 	}
@@ -58,29 +82,29 @@ public final class TypeUtil {
 	 */
 	private static ImmutableMap<PDataType, Byte> init() {
         final ImmutableMap.Builder<PDataType,Byte> builder = new Builder<PDataType,Byte>
();
-        builder.put(PDataType.LONG,DataType.LONG);
-        builder.put(PDataType.VARBINARY,DataType.BYTEARRAY);
-        builder.put(PDataType.CHAR,DataType.CHARARRAY);
-        builder.put(PDataType.VARCHAR,DataType.CHARARRAY);
-        builder.put(PDataType.DOUBLE,DataType.DOUBLE);
-        builder.put(PDataType.FLOAT,DataType.FLOAT);
-        builder.put(PDataType.INTEGER,DataType.INTEGER);
-        builder.put(PDataType.TINYINT,DataType.INTEGER);
-        builder.put(PDataType.SMALLINT,DataType.INTEGER);
-        builder.put(PDataType.DECIMAL,DataType.BIGDECIMAL);
-        builder.put(PDataType.TIME,DataType.DATETIME);
-        builder.put(PDataType.TIMESTAMP,DataType.DATETIME);
-        builder.put(PDataType.BOOLEAN,DataType.BOOLEAN);
-        builder.put(PDataType.DATE,DataType.DATETIME);
-        builder.put(PDataType.UNSIGNED_DATE,DataType.DATETIME);
-        builder.put(PDataType.UNSIGNED_DOUBLE,DataType.DOUBLE);
-        builder.put(PDataType.UNSIGNED_FLOAT,DataType.FLOAT);
-        builder.put(PDataType.UNSIGNED_INT,DataType.INTEGER);
-        builder.put(PDataType.UNSIGNED_LONG,DataType.LONG);
-        builder.put(PDataType.UNSIGNED_SMALLINT,DataType.INTEGER);
-        builder.put(PDataType.UNSIGNED_TIME,DataType.DATETIME);
-        builder.put(PDataType.UNSIGNED_TIMESTAMP,DataType.DATETIME);
-        builder.put(PDataType.UNSIGNED_TINYINT,DataType.INTEGER);
+        builder.put(PLong.INSTANCE,DataType.LONG);
+        builder.put(PVarbinary.INSTANCE,DataType.BYTEARRAY);
+        builder.put(PChar.INSTANCE,DataType.CHARARRAY);
+        builder.put(PVarchar.INSTANCE,DataType.CHARARRAY);
+        builder.put(PDouble.INSTANCE,DataType.DOUBLE);
+        builder.put(PFloat.INSTANCE,DataType.FLOAT);
+        builder.put(PInteger.INSTANCE,DataType.INTEGER);
+        builder.put(PTinyint.INSTANCE,DataType.INTEGER);
+        builder.put(PSmallint.INSTANCE,DataType.INTEGER);
+        builder.put(PDecimal.INSTANCE,DataType.BIGDECIMAL);
+        builder.put(PTime.INSTANCE,DataType.DATETIME);
+        builder.put(PTimestamp.INSTANCE,DataType.DATETIME);
+        builder.put(PBoolean.INSTANCE,DataType.BOOLEAN);
+        builder.put(PDate.INSTANCE,DataType.DATETIME);
+        builder.put(PUnsignedDate.INSTANCE,DataType.DATETIME);
+        builder.put(PUnsignedDouble.INSTANCE,DataType.DOUBLE);
+        builder.put(PUnsignedFloat.INSTANCE,DataType.FLOAT);
+        builder.put(PUnsignedInt.INSTANCE,DataType.INTEGER);
+        builder.put(PUnsignedLong.INSTANCE,DataType.LONG);
+        builder.put(PUnsignedSmallint.INSTANCE,DataType.INTEGER);
+        builder.put(PUnsignedTime.INSTANCE,DataType.DATETIME);
+        builder.put(PUnsignedTimestamp.INSTANCE,DataType.DATETIME);
+        builder.put(PUnsignedTinyint.INSTANCE,DataType.INTEGER);
         return builder.build();
     }
     /**
@@ -102,33 +126,33 @@ public final class TypeUtil {
 
 		switch (type) {
 		case DataType.BYTEARRAY:
-			sqlType = PDataType.VARBINARY;
+			sqlType = PVarbinary.INSTANCE;
 			break;
 		case DataType.CHARARRAY:
-			sqlType = PDataType.VARCHAR;
+			sqlType = PVarchar.INSTANCE;
 			break;
 		case DataType.DOUBLE:
 		case DataType.BIGDECIMAL:
-			sqlType = PDataType.DOUBLE;
+			sqlType = PDouble.INSTANCE;
 			break;
 		case DataType.FLOAT:
-			sqlType = PDataType.FLOAT;
+			sqlType = PFloat.INSTANCE;
 			break;
 		case DataType.INTEGER:
-			sqlType = PDataType.INTEGER;
+			sqlType = PInteger.INSTANCE;
 			break;
 		case DataType.LONG:
 		case DataType.BIGINTEGER:
-			sqlType = PDataType.LONG;
+			sqlType = PLong.INSTANCE;
 			break;
 		case DataType.BOOLEAN:
-			sqlType = PDataType.BOOLEAN;
+			sqlType = PBoolean.INSTANCE;
 			break;
 		case DataType.DATETIME:
-			sqlType = PDataType.DATE;
+			sqlType = PDate.INSTANCE;
 			break;
 		case DataType.BYTE:
-			sqlType = PDataType.TINYINT;
+			sqlType = PTinyint.INSTANCE;
 			break;
 		default:
 			throw new RuntimeException("Unknown type " + obj.getClass().getName()
@@ -156,17 +180,17 @@ public final class TypeUtil {
 			return null;
 		}
 
-		if(inferredPType == PDataType.VARBINARY) {
+		if(inferredPType == PVarbinary.INSTANCE) {
 			try {
 				o = castBytes(o, targetPhoenixType);
-				if(targetPhoenixType != PDataType.VARBINARY && targetPhoenixType != PDataType.BINARY)
{
+				if(targetPhoenixType != PVarbinary.INSTANCE && targetPhoenixType != PBinary.INSTANCE)
{
 					inferredPType = getType(o, DataType.findType(o));	
 				}
 			} catch (IOException e) {
 				throw new RuntimeException("Error while casting bytes for object " +o);
 			}
 		}
-		if(inferredPType == PDataType.DATE) {
+		if(inferredPType == PDate.INSTANCE) {
 			int inferredSqlType = targetPhoenixType.getSqlType();
 
 			if(inferredSqlType == Types.DATE) {
@@ -200,36 +224,27 @@ public final class TypeUtil {
 	 */
 	private static Object castBytes(Object o, PDataType targetPhoenixType) throws IOException
{
         byte[] bytes = ((DataByteArray)o).get();
-        
-        switch(targetPhoenixType) {
-        case CHAR:
-        case VARCHAR:
+
+        if (PDataType.equalsAny(targetPhoenixType, PChar.INSTANCE, PVarchar.INSTANCE)) {
             return binaryConverter.bytesToCharArray(bytes);
-        case UNSIGNED_SMALLINT:
-        case SMALLINT:
+        } else if (PDataType.equalsAny(targetPhoenixType, PUnsignedSmallint.INSTANCE, PSmallint.INSTANCE))
{
             return binaryConverter.bytesToInteger(bytes).shortValue();
-        case UNSIGNED_TINYINT:
-        case TINYINT:
+        } else if (PDataType.equalsAny(targetPhoenixType, PUnsignedTinyint.INSTANCE, PTinyint.INSTANCE))
{
             return binaryConverter.bytesToInteger(bytes).byteValue();
-        case UNSIGNED_INT:
-        case INTEGER:
-        	return binaryConverter.bytesToInteger(bytes);
-        case BOOLEAN:
+        } else if (PDataType.equalsAny(targetPhoenixType, PUnsignedInt.INSTANCE, PInteger.INSTANCE))
{
+            return binaryConverter.bytesToInteger(bytes);
+        } else if (targetPhoenixType.equals(PBoolean.INSTANCE)) {
             return binaryConverter.bytesToBoolean(bytes);
-        case FLOAT:
-        case UNSIGNED_FLOAT:
+        } else if (PDataType.equalsAny(targetPhoenixType, PFloat.INSTANCE, PUnsignedFloat.INSTANCE))
{
             return binaryConverter.bytesToFloat(bytes);
-        case DOUBLE:
-        case UNSIGNED_DOUBLE:
+        } else if (PDataType.equalsAny(targetPhoenixType, PDouble.INSTANCE, PUnsignedDouble.INSTANCE))
{
             return binaryConverter.bytesToDouble(bytes);
-        case UNSIGNED_LONG:
-        case LONG:
+        } else if (PDataType.equalsAny(targetPhoenixType, PUnsignedLong.INSTANCE, PLong.INSTANCE))
{
             return binaryConverter.bytesToLong(bytes);
-        case VARBINARY : 
-        case BINARY:
-        	 return bytes;
-        default:
-        	return o;
+        } else if (PDataType.equalsAny(targetPhoenixType, PVarbinary.INSTANCE, PBinary.INSTANCE))
{
+            return bytes;
+        } else {
+            return o;
         }        
     }
     
@@ -259,7 +274,7 @@ public final class TypeUtil {
                 
                 switch(fieldSchema.getType()) {
                     case DataType.BYTEARRAY:
-                        byte[] bytes = PDataType.fromTypeId(PDataType.BINARY.getSqlType()).toBytes(object);
+                        byte[] bytes = PDataType.fromTypeId(PBinary.INSTANCE.getSqlType()).toBytes(object);
                         tuple.set(i,new DataByteArray(bytes,0,bytes.length));
                         break;
                     case DataType.CHARARRAY:

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04ef859b/phoenix-pig/src/main/java/org/apache/phoenix/pig/writable/PhoenixPigDBWritable.java
----------------------------------------------------------------------
diff --git a/phoenix-pig/src/main/java/org/apache/phoenix/pig/writable/PhoenixPigDBWritable.java
b/phoenix-pig/src/main/java/org/apache/phoenix/pig/writable/PhoenixPigDBWritable.java
index a7399c9..566e427 100644
--- a/phoenix-pig/src/main/java/org/apache/phoenix/pig/writable/PhoenixPigDBWritable.java
+++ b/phoenix-pig/src/main/java/org/apache/phoenix/pig/writable/PhoenixPigDBWritable.java
@@ -26,7 +26,7 @@ import java.util.List;
 import org.apache.hadoop.io.Writable;
 import org.apache.hadoop.mapreduce.lib.db.DBWritable;
 import org.apache.phoenix.pig.util.TypeUtil;
-import org.apache.phoenix.schema.PDataType;
+import org.apache.phoenix.schema.types.PDataType;
 import org.apache.phoenix.util.ColumnInfo;
 import org.apache.pig.ResourceSchema.ResourceFieldSchema;
 import org.apache.pig.data.DataType;


Mime
View raw message