phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sama...@apache.org
Subject [2/2] phoenix git commit: PHOENIX-1759 PhoenixArray to have decent toString() implementation (Alex Warshavsky)
Date Fri, 17 Apr 2015 19:38:37 GMT
PHOENIX-1759 PhoenixArray to have decent toString() implementation (Alex Warshavsky)


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/45c9716c
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/45c9716c
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/45c9716c

Branch: refs/heads/4.x-HBase-0.98
Commit: 45c9716c1d9b79b3620c3efd9e5eaa1bd2a0aa1a
Parents: 97719a8
Author: Samarth <samarth.jain@salesforce.com>
Authored: Fri Apr 17 12:38:07 2015 -0700
Committer: Samarth <samarth.jain@salesforce.com>
Committed: Fri Apr 17 12:38:07 2015 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/ArrayIT.java     |  125 +-
 .../apache/phoenix/schema/types/PDataType.java  |   15 +-
 .../org/apache/phoenix/schema/types/PDate.java  |   15 +-
 .../apache/phoenix/schema/types/PVarchar.java   |    2 +-
 .../phoenix/schema/types/PhoenixArray.java      |   55 +-
 .../phoenix/schema/PDataTypeForArraysTest.java  | 1141 ------------------
 .../types/BasePhoenixArrayToStringTest.java     |   81 ++
 ...PrimitiveDoublePhoenixArrayToStringTest.java |   39 +
 ...asePrimitiveIntPhoenixArrayToStringTest.java |   50 +
 .../schema/types/PDataTypeForArraysTest.java    | 1141 ++++++++++++++++++
 .../schema/types/PDateArrayToStringTest.java    |   73 ++
 .../schema/types/PVarcharArrayToStringTest.java |   71 ++
 ...rimitiveBooleanPhoenixArrayToStringTest.java |   50 +
 .../PrimitiveBytePhoenixArrayToStringTest.java  |   34 +
 ...PrimitiveDoublePhoenixArrayToStringTest.java |   36 +
 .../PrimitiveFloatPhoenixArrayToStringTest.java |   36 +
 .../PrimitiveIntPhoenixArrayToStringTest.java   |   20 +
 .../PrimitiveLongPhoenixArrayToStringTest.java  |   35 +
 .../PrimitiveShortPhoenixArrayToStringTest.java |   36 +
 19 files changed, 1885 insertions(+), 1170 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
index d7dce54..4b79142 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ArrayIT.java
@@ -51,6 +51,7 @@ import com.google.common.primitives.Floats;
 public class ArrayIT extends BaseClientManagedTimeIT {
 
 	private static final String SIMPLE_TABLE_WITH_ARRAY = "SIMPLE_TABLE_WITH_ARRAY";
+    private static final String TABLE_WITH_ALL_ARRAY_TYPES = "TABLE_WITH_ALL_ARRAY_TYPES";
 
     private static void initTablesWithArrays(String tenantId, Date date, Long ts, boolean useNull, String url) throws Exception {
         Properties props = new Properties();
@@ -159,6 +160,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 					doubleArr);
 			PhoenixArray resultArray = (PhoenixArray) rs.getArray(1);
 			assertEquals(resultArray, array);
+            assertEquals("[25.343, 36.763, 37.56, 386.63]", rs.getString(1));
 			assertEquals(rs.getString("B_string"), B_VALUE);
 			assertTrue(Floats.compare(rs.getFloat(3), 0.01f) == 0);
 			assertFalse(rs.next());
@@ -206,6 +208,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 			array = conn.createArrayOf("DOUBLE", doubleArr);
 			Array resultArray = rs.getArray(1);
 			assertEquals(resultArray, array);
+            assertEquals("[25.343, 36.763, 37.56, 386.63]", rs.getString(1));
 			assertEquals(rs.getString("B_string"), B_VALUE);
 			assertTrue(Floats.compare(rs.getFloat(3), 0.01f) == 0);
 			assertFalse(rs.next());
@@ -248,6 +251,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 			array = conn.createArrayOf("DOUBLE", doubleArr);
 			Array resultArray = rs.getArray(1);
 			assertEquals(resultArray, array);
+            assertEquals("[25.343, 36.763, 37.56, 386.63]", rs.getString(1));
 			assertEquals(rs.getString("B_string"), B_VALUE);
 			assertTrue(Floats.compare(rs.getFloat(3), 0.01f) == 0);
 			assertFalse(rs.next());
@@ -280,6 +284,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 			Array array = conn.createArrayOf("VARCHAR", strArr);
 			PhoenixArray resultArray = (PhoenixArray) rs.getArray(1);
 			assertEquals(resultArray, array);
+            assertEquals("['ABC', 'CEDF', 'XYZWER', 'AB']", rs.getString(1));
 			assertFalse(rs.next());
 		} finally {
 			conn.close();
@@ -654,6 +659,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
             intArr[2] = 1;
             Array resultArr = conn.createArrayOf("INTEGER", intArr);
             assertEquals(resultArr, array);
+            assertEquals("[1, 2, 1]", rs.getString(2));
             assertFalse(rs.next());
         } finally {
             conn.close();
@@ -685,6 +691,10 @@ public class ArrayIT extends BaseClientManagedTimeIT {
             strArr[2] = "b";
             Array resultArr = conn.createArrayOf("VARCHAR", strArr);
             assertEquals(resultArr, array);
+            // since array is var length, last string element is messed up
+            String expectedPrefix = "['abc', 'defgh', 'b";
+            assertTrue("Expected to start with " + expectedPrefix,
+                rs.getString(2).startsWith(expectedPrefix));
             assertFalse(rs.next());
         } finally {
             conn.close();
@@ -719,6 +729,9 @@ public class ArrayIT extends BaseClientManagedTimeIT {
             strArr[5] = "b";
             Array resultArr = conn.createArrayOf("VARCHAR", strArr);
             assertEquals(resultArr, array);
+            String expectedPrefix = "['abc', null, 'bcd', null, null, 'b";
+            assertTrue("Expected to start with " + expectedPrefix,
+                rs.getString(2).startsWith(expectedPrefix));
             assertFalse(rs.next());
         } finally {
             conn.close();
@@ -824,6 +837,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
         assertTrue(rs.next());
         PhoenixArray strArr = (PhoenixArray)rs.getArray(1);
         assertEquals(array, strArr);
+        assertEquals("['abc', 'def', 'ghi', 'jkll', null, null, null, 'xxx']", rs.getString(1));
         conn.close();
     }
 
@@ -888,6 +902,93 @@ public class ArrayIT extends BaseClientManagedTimeIT {
     }
 
     @Test
+    public void testArraySelectGetString() throws Exception {
+        Connection conn;
+        PreparedStatement stmt;
+        long ts = nextTimestamp();
+        String tenantId = getOrganizationId();
+
+        // create the table
+        createTableWithAllArrayTypes(getUrl(), getDefaultSplits(tenantId), null, ts - 2);
+
+        // populate the table with data
+        Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+        conn = DriverManager.getConnection(getUrl(), props);
+        stmt =
+                conn.prepareStatement("UPSERT INTO "
+                        + TABLE_WITH_ALL_ARRAY_TYPES
+                        + "(ORGANIZATION_ID, ENTITY_ID, BOOLEAN_ARRAY, BYTE_ARRAY, DOUBLE_ARRAY, FLOAT_ARRAY, INT_ARRAY, LONG_ARRAY, SHORT_ARRAY, STRING_ARRAY)\n"
+                        + "VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
+        stmt.setString(1, tenantId);
+        stmt.setString(2, ROW1);
+        // boolean array
+        Array boolArray = conn.createArrayOf("BOOLEAN", new Boolean[] { true, false });
+        int boolIndex = 3;
+        stmt.setArray(boolIndex, boolArray);
+        // byte array
+        Array byteArray = conn.createArrayOf("TINYINT", new Byte[] { 11, 22 });
+        int byteIndex = 4;
+        stmt.setArray(byteIndex, byteArray);
+        // double array
+        Array doubleArray = conn.createArrayOf("DOUBLE", new Double[] { 67.78, 78.89 });
+        int doubleIndex = 5;
+        stmt.setArray(doubleIndex, doubleArray);
+        // float array
+        Array floatArray = conn.createArrayOf("FLOAT", new Float[] { 12.23f, 45.56f });
+        int floatIndex = 6;
+        stmt.setArray(floatIndex, floatArray);
+        // int array
+        Array intArray = conn.createArrayOf("INTEGER", new Integer[] { 5555, 6666 });
+        int intIndex = 7;
+        stmt.setArray(intIndex, intArray);
+        // long array
+        Array longArray = conn.createArrayOf("BIGINT", new Long[] { 7777777L, 8888888L });
+        int longIndex = 8;
+        stmt.setArray(longIndex, longArray);
+        // short array
+        Array shortArray = conn.createArrayOf("SMALLINT", new Short[] { 333, 444 });
+        int shortIndex = 9;
+        stmt.setArray(shortIndex, shortArray);
+        // create character array
+        Array stringArray = conn.createArrayOf("VARCHAR", new String[] { "a", "b" });
+        int stringIndex = 10;
+        stmt.setArray(stringIndex, stringArray);
+        stmt.execute();
+        conn.commit();
+        conn.close();
+
+        props.setProperty(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 30));
+        conn = DriverManager.getConnection(getUrl(), props);
+        stmt =
+                conn.prepareStatement("SELECT organization_id, entity_id, boolean_array, byte_array, double_array, float_array, int_array, long_array, short_array, string_array FROM "
+                        + TABLE_WITH_ALL_ARRAY_TYPES);
+        analyzeTable(conn, TABLE_WITH_ALL_ARRAY_TYPES);
+
+        ResultSet rs = stmt.executeQuery();
+        assertTrue(rs.next());
+
+        assertEquals(tenantId, rs.getString(1));
+        assertEquals(ROW1, rs.getString(2));
+        
+        assertArrayGetString(rs, boolIndex, boolArray, "true, false");
+        assertArrayGetString(rs, byteIndex, byteArray, "11, 22");
+        assertArrayGetString(rs, doubleIndex, doubleArray, "67.78, 78.89");
+        assertArrayGetString(rs, floatIndex, floatArray, "12.23, 45.56");
+        assertArrayGetString(rs, intIndex, intArray, "5555, 6666");
+        assertArrayGetString(rs, longIndex, longArray, "7777777, 8888888");
+        assertArrayGetString(rs, shortIndex, shortArray, "333, 444");
+        assertArrayGetString(rs, stringIndex, stringArray, "'a', 'b'");
+        conn.close();
+    }
+
+    private void assertArrayGetString(ResultSet rs, int arrayIndex, Array expectedArray, String expectedString)
+            throws SQLException {
+        assertEquals(expectedArray, rs.getArray(arrayIndex));
+        assertEquals("[" + expectedString + "]", rs.getString(arrayIndex));
+    }
+    
+    @Test
     public void testArrayWithCast() throws Exception {
         Connection conn;
         PreparedStatement stmt;
@@ -917,6 +1018,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
         array = conn.createArrayOf("DOUBLE", d);
         PhoenixArray arr = (PhoenixArray)rs.getArray(1);
         assertEquals(array, arr);
+        assertEquals("[1.0, 2.0]", rs.getString(1));
         conn.close();
     }
 
@@ -951,6 +1053,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
         String[] array3 = (String[])arr.getArray();
         assertEquals(array2[0], array3[0]);
         assertEquals(array2[1], array3[1]);
+        assertEquals("['1', '2']", rs.getString(1));
         conn.close();
     }
 
@@ -1018,6 +1121,7 @@ public class ArrayIT extends BaseClientManagedTimeIT {
 			Array array = conn.createArrayOf("DOUBLE", doubleArr);
 			PhoenixArray resultArray = (PhoenixArray) rs.getArray(1);
 			assertEquals(resultArray, array);
+            assertEquals("[25.343, 36.763, 37.56, 386.63]", rs.getString(1));
 			assertFalse(rs.next());
 		} finally {
 			conn.close();
@@ -1657,7 +1761,26 @@ public class ArrayIT extends BaseClientManagedTimeIT {
         }
 
     }
-
+    
+    private static void createTableWithAllArrayTypes(String url, byte[][] bs, Object object,
+            long ts) throws SQLException {
+        String ddlStmt = "create table "
+                + TABLE_WITH_ALL_ARRAY_TYPES
+                + "   (organization_id char(15) not null, \n"
+                + "    entity_id char(15) not null,\n"
+                + "    boolean_array boolean array,\n"
+                + "    byte_array tinyint array,\n"
+                + "    double_array double array[],\n"
+                + "    float_array float array,\n"
+                + "    int_array integer array,\n"
+                + "    long_array bigint[5],\n"
+                + "    short_array smallint array,\n"
+                + "    string_array varchar(100) array[3],\n"
+                + "    CONSTRAINT pk PRIMARY KEY (organization_id, entity_id)\n"
+                + ")";
+        BaseTest.createTestTable(url, ddlStmt, bs, ts);
+    }
+    
     static void createTableWithArray(String url, byte[][] bs, Object object,
 			long ts) throws SQLException {
 		String ddlStmt = "create table "

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
index e8654ff..60d2020 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDataType.java
@@ -1095,12 +1095,19 @@ public abstract class PDataType<T> implements DataType<T>, Comparable<PDataType<
     return toStringLiteral(o, formatter);
   }
   
-  public String toStringLiteral(Object o, Format formatter) {
-      if (formatter != null) {
-          return formatter.format(o);
+    public String toStringLiteral(Object o, Format formatter) {
+        if (formatter != null) {
+            return formatter.format(o);
+        } else if (null == o) {
+            return String.valueOf(o);
         }
         return o.toString();
-  }
+    }
+
+    public String toStringLiteral(Object o) {
+        // use default formatter when one is unspecified
+        return toStringLiteral(o, null);
+    }
 
   private static final PhoenixArrayFactory DEFAULT_ARRAY_FACTORY = new PhoenixArrayFactory() {
     @Override public PhoenixArray newArray(PDataType type, Object[] elements) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDate.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDate.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDate.java
index b926afb..947c30e 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDate.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PDate.java
@@ -148,14 +148,15 @@ public class PDate extends PDataType<Date> {
   }
 
   @Override
-  public String toStringLiteral(Object o, Format formatter) {
-      if (formatter == null) {
-          // If default formatter has not been overridden,
-          // use default one.
-          formatter = DateUtil.DEFAULT_DATE_FORMATTER;
+    public String toStringLiteral(Object o, Format formatter) {
+        if (formatter == null) {
+            // If default formatter has not been overridden,
+            // use default one.
+            formatter = DateUtil.DEFAULT_DATE_FORMATTER;
         }
-        return "'" + StringUtil.escapeStringConstant(super.toStringLiteral(o, formatter)) + "'";
-  }
+        return null == o ? String.valueOf(o) : "'"
+                + StringUtil.escapeStringConstant(super.toStringLiteral(o, formatter)) + "'";
+    }
 
   @Override
   public void coerceBytes(ImmutableBytesWritable ptr, Object object, PDataType actualType,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
index 9883e12..fa3dbad 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
@@ -143,7 +143,7 @@ public class PVarchar extends PDataType<String> {
     if (formatter != null) {
       return "'" + formatter.format(o) + "'";
     }
-    return "'" + StringUtil.escapeStringConstant(o.toString()) + "'";
+    return null == o ? String.valueOf(o) : "'" + StringUtil.escapeStringConstant(o.toString()) + "'";
   }
 
   private char[] sampleChars = new char[1];

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
index dcfb2c3..982834d 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PhoenixArray.java
@@ -29,11 +29,16 @@ import org.apache.phoenix.util.SQLCloseable;
  * java.sql.Array implementation for Phoenix
  */
 public class PhoenixArray implements Array,SQLCloseable {
+	private static final String TO_STRING_SEPARATOR = ", ";
+	private static final String TO_STRING_END = "]";
+	private static final String TO_STRING_BEGIN = "[";
+	
 	PDataType baseType;
 	Object array;
 	int numElements;
 	Integer maxLength;
-  protected int hashCode = Integer.MIN_VALUE;
+	protected int hashCode = Integer.MIN_VALUE;
+
 	public PhoenixArray() {
 		// empty constructor
 	}
@@ -227,6 +232,23 @@ public class PhoenixArray implements Array,SQLCloseable {
 		return this.baseType.toBytes(((Object[])array)[pos]);
 	}
 	
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(TO_STRING_BEGIN);
+        boolean isFirst = true;
+        for (int i = 0; i < getDimensions(); i++) {
+            Object o = getElement(i);
+            if (isFirst) {
+                isFirst = false;
+            } else {
+                sb.append(TO_STRING_SEPARATOR);
+            }
+            sb.append(this.baseType.toStringLiteral(o));
+        }
+        sb.append(TO_STRING_END);
+        return sb.toString();
+    }
+	
 	public boolean isNull(int pos) {
 	    if(this.baseType.toBytes(((Object[])array)[pos]).length == 0) {
 	        return true;
@@ -263,18 +285,19 @@ public class PhoenixArray implements Array,SQLCloseable {
 		public PrimitiveIntPhoenixArray(PDataType dataType, Object[] elements) {
 			super(dataType, elements);
 		}
+
 		@Override
-		public Object convertObjectArrayToPrimitiveArray(Object[] elements) {
-			intArr = new int[elements.length];
-			int i = 0;
-			for(Object o : elements) {
-			    if (o != null) {
-			        intArr[i] = (Integer)o;
-			    }
-			    i++;
-			}
-      return intArr;
-		}
+        public Object convertObjectArrayToPrimitiveArray(Object[] elements) {
+            intArr = new int[elements.length];
+            int i = 0;
+            for (Object o : elements) {
+                if (o != null) {
+                    intArr[i] = (Integer) o;
+                }
+                i++;
+            }
+            return intArr;
+        }
 		
 		@Override
         public int estimateByteSize(int pos) {
@@ -340,7 +363,7 @@ public class PhoenixArray implements Array,SQLCloseable {
         public byte[] toBytes(int pos) {
 			return this.baseType.toBytes(shortArr[pos]);
 		}
-		
+
 		@Override
 		public boolean equals(Object obj) {
       if (obj == null) return false;
@@ -394,7 +417,7 @@ public class PhoenixArray implements Array,SQLCloseable {
         public byte[] toBytes(int pos) {
 			return this.baseType.toBytes(longArr[pos]);
 		}
-		
+
 		@Override
 		public boolean equals(Object obj) {
       if (obj == null) return false;
@@ -449,7 +472,7 @@ public class PhoenixArray implements Array,SQLCloseable {
         public byte[] toBytes(int pos) {
 			return this.baseType.toBytes(doubleArr[pos]);
 		}
-		
+
 		@Override
 		public boolean equals(Object obj) {
       if (obj == null) return false;
@@ -504,7 +527,7 @@ public class PhoenixArray implements Array,SQLCloseable {
         public byte[] toBytes(int pos) {
 			return this.baseType.toBytes(floatArr[pos]);
 		}
-		
+
 		@Override
 		public boolean equals(Object obj) {
       if (obj == null) return false;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/test/java/org/apache/phoenix/schema/PDataTypeForArraysTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/PDataTypeForArraysTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/PDataTypeForArraysTest.java
deleted file mode 100644
index d5e5b5b..0000000
--- a/phoenix-core/src/test/java/org/apache/phoenix/schema/PDataTypeForArraysTest.java
+++ /dev/null
@@ -1,1141 +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.schema;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-import java.math.BigDecimal;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import org.apache.hadoop.hbase.io.ImmutableBytesWritable;
-import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.schema.types.PArrayDataType;
-import org.apache.phoenix.schema.types.PBoolean;
-import org.apache.phoenix.schema.types.PBooleanArray;
-import org.apache.phoenix.schema.types.PChar;
-import org.apache.phoenix.schema.types.PCharArray;
-import org.apache.phoenix.schema.types.PDate;
-import org.apache.phoenix.schema.types.PDateArray;
-import org.apache.phoenix.schema.types.PDecimal;
-import org.apache.phoenix.schema.types.PDecimalArray;
-import org.apache.phoenix.schema.types.PDouble;
-import org.apache.phoenix.schema.types.PDoubleArray;
-import org.apache.phoenix.schema.types.PFloat;
-import org.apache.phoenix.schema.types.PFloatArray;
-import org.apache.phoenix.schema.types.PInteger;
-import org.apache.phoenix.schema.types.PIntegerArray;
-import org.apache.phoenix.schema.types.PLong;
-import org.apache.phoenix.schema.types.PLongArray;
-import org.apache.phoenix.schema.types.PSmallint;
-import org.apache.phoenix.schema.types.PSmallintArray;
-import org.apache.phoenix.schema.types.PTime;
-import org.apache.phoenix.schema.types.PTimeArray;
-import org.apache.phoenix.schema.types.PTimestamp;
-import org.apache.phoenix.schema.types.PTimestampArray;
-import org.apache.phoenix.schema.types.PTinyint;
-import org.apache.phoenix.schema.types.PTinyintArray;
-import org.apache.phoenix.schema.types.PUnsignedDate;
-import org.apache.phoenix.schema.types.PUnsignedDateArray;
-import org.apache.phoenix.schema.types.PUnsignedDouble;
-import org.apache.phoenix.schema.types.PUnsignedDoubleArray;
-import org.apache.phoenix.schema.types.PUnsignedFloat;
-import org.apache.phoenix.schema.types.PUnsignedFloatArray;
-import org.apache.phoenix.schema.types.PUnsignedInt;
-import org.apache.phoenix.schema.types.PUnsignedIntArray;
-import org.apache.phoenix.schema.types.PUnsignedLong;
-import org.apache.phoenix.schema.types.PUnsignedLongArray;
-import org.apache.phoenix.schema.types.PUnsignedSmallint;
-import org.apache.phoenix.schema.types.PUnsignedSmallintArray;
-import org.apache.phoenix.schema.types.PUnsignedTime;
-import org.apache.phoenix.schema.types.PUnsignedTimeArray;
-import org.apache.phoenix.schema.types.PUnsignedTimestamp;
-import org.apache.phoenix.schema.types.PUnsignedTimestampArray;
-import org.apache.phoenix.schema.types.PUnsignedTinyint;
-import org.apache.phoenix.schema.types.PUnsignedTinyintArray;
-import org.apache.phoenix.schema.types.PVarchar;
-import org.apache.phoenix.schema.types.PVarcharArray;
-import org.apache.phoenix.schema.types.PhoenixArray;
-import org.junit.Ignore;
-import org.junit.Test;
-
-public class PDataTypeForArraysTest {
-	@Test
-	public void testForIntegerArray() {
-		Integer[] intArr = new Integer[2];
-		intArr[0] = 1;
-		intArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-        PInteger.INSTANCE, intArr);
-		PIntegerArray.INSTANCE.toObject(arr, PIntegerArray.INSTANCE);
-		byte[] bytes = PIntegerArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PIntegerArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForBooleanArray() {
-		Boolean[] boolArr = new Boolean[2];
-		boolArr[0] = true;
-		boolArr[1] = false;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PBoolean.INSTANCE, boolArr);
-		PBooleanArray.INSTANCE.toObject(arr, PBooleanArray.INSTANCE);
-		byte[] bytes = PBooleanArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PBooleanArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForVarCharArray() {
-		String[] strArr = new String[2];
-		strArr[0] = "abc";
-		strArr[1] = "klmnop";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-	
-	@Test
-	public void testVarCharArrayWithNullValues1() {
-	    String[] strArr = new String[6];
-        strArr[0] = "abc";
-        strArr[1] = null;
-        strArr[2] = "bcd";
-        strArr[3] = null;
-        strArr[4] = null;
-        strArr[5] = "b";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-                .toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-	}
-	
-    @Test
-    public void testVarCharArrayWithNullValues2() {
-        String[] strArr = new String[6];
-        strArr[0] = "abc";
-        strArr[1] = null;
-        strArr[2] = "bcd";
-        strArr[3] = null;
-        strArr[4] = "cde";
-        strArr[5] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    @Test
-    public void testVarCharArrayWithNullValues3() {
-        String[] strArr = new String[6];
-        strArr[0] = "abc";
-        strArr[1] = null;
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = null;
-        strArr[5] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    @Test
-    public void testVarCharArrayWithNullValues4() {
-        String[] strArr = new String[7];
-        strArr[0] = "abc";
-        strArr[1] = null;
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = null;
-        strArr[5] = null;
-        strArr[6] = "xys";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    
-    @Test
-    public void testVarCharArrayWithNullValues5() {
-        String[] strArr = new String[6];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = "cde";
-        strArr[3] = null;
-        strArr[4] = null;
-        strArr[5] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    @Test
-    public void testVarCharArrayWithNullValues6() {
-        String[] strArr = new String[6];
-        strArr[0] = "abc";
-        strArr[1] = null;
-        strArr[2] = "cde";
-        strArr[3] = "bcd";
-        strArr[4] = null;
-        strArr[5] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    @Test
-    public void testVarCharArrayWithNullValues7() {
-        String[] strArr = new String[6];
-        strArr[0] = null;
-        strArr[1] = "abc";
-        strArr[2] = null;
-        strArr[3] = "bcd";
-        strArr[4] = null;
-        strArr[5] = "cde";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-
-	@Test
-	public void testForCharArray() {
-		String[] strArr = new String[2];
-		strArr[0] = "a";
-		strArr[1] = "d";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PChar.INSTANCE, strArr);
-		byte[] bytes = PCharArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PCharArray.INSTANCE.toObject(
-				bytes, 0, bytes.length, PCharArray.INSTANCE, null, 1, null);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForLongArray() {
-		Long[] longArr = new Long[2];
-		longArr[0] = 1l;
-		longArr[1] = 2l;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PLong.INSTANCE, longArr);
-		PLongArray.INSTANCE.toObject(arr, PLongArray.INSTANCE);
-		byte[] bytes = PLongArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PLongArray.INSTANCE.toObject(
-				bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForSmallIntArray() {
-		Short[] shortArr = new Short[2];
-		shortArr[0] = 1;
-		shortArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PSmallint.INSTANCE, shortArr);
-		PSmallintArray.INSTANCE.toObject(arr, PSmallintArray.INSTANCE);
-		byte[] bytes = PSmallintArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PSmallintArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForVarCharArrayForOddNumber() {
-		String[] strArr = new String[3];
-		strArr[0] = "abx";
-		strArr[1] = "ereref";
-		strArr[2] = "random";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-    @Test
-    public void testForVarCharArrayOneElement() {
-        String[] strArr = new String[1];
-        strArr[0] = "ereref";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-                .toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-
-    @Test
-    public void testForVarcharArrayWith1ElementInLargerBuffer() {
-        String[] strArr = new String[1];
-        strArr[0] = "abx";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        byte[] moreBytes = new byte[bytes.length + 20];
-        // Generate some garbage
-        for (int i = 0; i < moreBytes.length; i++) {
-            moreBytes[i] = (byte)-i;
-        }
-        System.arraycopy(bytes, 0, moreBytes, 10, bytes.length);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE.toObject(moreBytes, 10, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    
-	@Test
-	public void testForVarCharArrayForEvenNumberWithIndex() {
-		String[] strArr = new String[5];
-		strArr[0] = "abx";
-		strArr[1] = "ereref";
-		strArr[2] = "random";
-		strArr[3] = "random12";
-		strArr[4] = "ranzzz";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-		int offset = ptr.getOffset();
-		int length = ptr.getLength();
-		byte[] bs = ptr.get();
-		byte[] res = new byte[length];
-		System.arraycopy(bs, offset, res, 0, length);
-		assertEquals("ranzzz", Bytes.toString(res));
-	}
-	
-    
-    @Test
-    public void testForVarCharArrayWithOneElementIndex() {
-        String[] strArr = new String[1];
-        strArr[0] = "abx";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("abx", Bytes.toString(res));
-    }
-	
-	@Ignore
-	public void testVariableLengthArrayWithElementsMoreThanShortMax() {
-	    String[] strArr = new String[(2 * Short.MAX_VALUE) + 100]; 
-	    for(int i = 0 ; i < (2 * Short.MAX_VALUE) + 100; i++ ) {
-	        String str = "abc";
-	        for(int j = 0 ; j <= i ;j++) {
-	            str += "-";
-	        }
-	        strArr[i] = str;
-	    }
-	    PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("abc---", Bytes.toString(res));
-	}
-	
-	@Test
-	public void testGetArrayLengthForVariableLengthArray() {
-		String[] strArr = new String[5];
-		strArr[0] = "abx";
-		strArr[1] = "ereref";
-		strArr[2] = "random";
-		strArr[3] = "random12";
-		strArr[4] = "ranzzz";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		int result = PArrayDataType.getArrayLength(ptr, PVarchar.INSTANCE, null);
-		assertEquals(5, result);
-	}
-
-	@Test
-	public void testForVarCharArrayForOddNumberWithIndex() {
-		String[] strArr = new String[5];
-		strArr[0] = "abx";
-		strArr[1] = "ereref";
-		strArr[2] = "random";
-		strArr[3] = "random12";
-		strArr[4] = "ran";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-		int offset = ptr.getOffset();
-		int length = ptr.getLength();
-		byte[] bs = ptr.get();
-		byte[] res = new byte[length];
-		System.arraycopy(bs, offset, res, 0, length);
-		assertEquals("random12", Bytes.toString(res));
-	}
-
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValue1() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("random", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValue2() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random12";
-        strArr[4] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 2, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("random", Bytes.toString(res));
-    }
-    @Test
-    public void testForVarCharArrayForOddNumberWithIndex3() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random12";
-        strArr[4] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testForVarCharArrayForOddNumberWithIndex4() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testForVarCharArrayForOddNumberWithIndex5() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "random12";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("random12", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testForVarCharArrayForOddNumberWithIndex6() {
-        String[] strArr = new String[6];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "random12";
-        strArr[5] = "random17";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("random12", Bytes.toString(res));
-    }
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValue5() {
-        String[] strArr = new String[5];
-        strArr[0] = "abx";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValueAtTheStart1() {
-        String[] strArr = new String[5];
-        strArr[0] = null;
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 3, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValueAtTheStart2() {
-        String[] strArr = new String[5];
-        strArr[0] = null;
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithNullValueAtTheStart3() {
-        String[] strArr = new String[5];
-        strArr[0] = null;
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("ran", Bytes.toString(res));
-    }
-    
-    @Test
-    public void testPositionSearchWithVarLengthArrayWithAllNulls() {
-        String[] strArr = new String[5];
-        strArr[0] = null;
-        strArr[1] = null;
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = null;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-        PArrayDataType.positionAtArrayElement(ptr, 4, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-        int offset = ptr.getOffset();
-        int length = ptr.getLength();
-        byte[] bs = ptr.get();
-        byte[] res = new byte[length];
-        System.arraycopy(bs, offset, res, 0, length);
-        assertEquals("", Bytes.toString(res));
-    }
-
-	@Test
-	public void testForVarCharArrayForOneElementArrayWithIndex() {
-		String[] strArr = new String[1];
-		strArr[0] = "abx";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		PArrayDataType.positionAtArrayElement(ptr, 0, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-		int offset = ptr.getOffset();
-		int length = ptr.getLength();
-		byte[] bs = ptr.get();
-		byte[] res = new byte[length];
-		System.arraycopy(bs, offset, res, 0, length);
-		assertEquals("abx", Bytes.toString(res));
-	}
-
-	@Test
-	public void testForVarCharArrayForWithTwoelementsElementArrayWithIndex() {
-		String[] strArr = new String[2];
-		strArr[0] = "abx";
-		strArr[1] = "ereref";
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		PArrayDataType.positionAtArrayElement(ptr, 1, PVarchar.INSTANCE, PVarchar.INSTANCE.getByteSize());
-		int offset = ptr.getOffset();
-		int length = ptr.getLength();
-		byte[] bs = ptr.get();
-		byte[] res = new byte[length];
-		System.arraycopy(bs, offset, res, 0, length);
-		assertEquals("ereref", Bytes.toString(res));
-	}
-
-	@Test
-	public void testLongArrayWithIndex() {
-		Long[] longArr = new Long[4];
-		longArr[0] = 1l;
-		longArr[1] = 2l;
-		longArr[2] = 4l;
-		longArr[3] = 5l;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PLong.INSTANCE, longArr);
-		PLongArray.INSTANCE.toObject(arr, PLongArray.INSTANCE);
-		byte[] bytes = PLongArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		PArrayDataType.positionAtArrayElement(ptr, 2, PLong.INSTANCE, PLong.INSTANCE.getByteSize());
-		int offset = ptr.getOffset();
-		int length = ptr.getLength();
-		byte[] bs = ptr.get();
-		byte[] res = new byte[length];
-		System.arraycopy(bs, offset, res, 0, length);
-		long result = (Long) PLong.INSTANCE.toObject(res);
-		assertEquals(4l, result);
-	}
-	
-	@Test
-	public void testGetArrayLengthForFixedLengthArray() {
-		Long[] longArr = new Long[4];
-		longArr[0] = 1l;
-		longArr[1] = 2l;
-		longArr[2] = 4l;
-		longArr[3] = 5l;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PLong.INSTANCE, longArr);
-		PLongArray.INSTANCE.toObject(arr, PLongArray.INSTANCE);
-		byte[] bytes = PLongArray.INSTANCE.toBytes(arr);
-		ImmutableBytesWritable ptr = new ImmutableBytesWritable(bytes);
-		int length = PArrayDataType.getArrayLength(ptr, PLong.INSTANCE, null);
-		assertEquals(4, length);
-	}
-
-	@Test
-	public void testForVarcharArrayBiggerArraysNumber() {
-		String[] strArr = new String[101];
-		for (int i = 0; i <= 100; i++) {
-			strArr[i] = "abc" + i;
-		}
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PVarchar.INSTANCE, strArr);
-		byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForTinyIntArray() {
-		Byte[] byteArr = new Byte[2];
-		byteArr[0] = 1;
-		byteArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PTinyint.INSTANCE, byteArr);
-		PTinyintArray.INSTANCE.toObject(arr, PTinyintArray.INSTANCE);
-		byte[] bytes = PTinyintArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PTinyintArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForFloatArray() {
-		Float[] floatArr = new Float[2];
-		floatArr[0] = 1.06f;
-		floatArr[1] = 2.89f;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PFloat.INSTANCE, floatArr);
-		PFloatArray.INSTANCE.toObject(arr, PFloatArray.INSTANCE);
-		byte[] bytes = PFloatArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PFloatArray.INSTANCE.toObject(
-				bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForDoubleArray() {
-		Double[] doubleArr = new Double[2];
-		doubleArr[0] = 1.06;
-		doubleArr[1] = 2.89;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PDouble.INSTANCE, doubleArr);
-		PDoubleArray.INSTANCE.toObject(arr, PDoubleArray.INSTANCE);
-		byte[] bytes = PDoubleArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PDoubleArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForDecimalArray() {
-		BigDecimal[] bigDecimalArr = new BigDecimal[2];
-		bigDecimalArr[0] = new BigDecimal(89997);
-		bigDecimalArr[1] = new BigDecimal(8999.995f);
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PDecimal.INSTANCE, bigDecimalArr);
-		PDecimalArray.INSTANCE.toObject(arr, PDecimalArray.INSTANCE);
-		byte[] bytes = PDecimalArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PDecimalArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForTimeStampArray() {
-		Timestamp[] timeStampArr = new Timestamp[2];
-		timeStampArr[0] = new Timestamp(System.currentTimeMillis());
-		timeStampArr[1] = new Timestamp(900000l);
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PTimestamp.INSTANCE, timeStampArr);
-		PTimestampArray.INSTANCE.toObject(arr, PTimestampArray.INSTANCE);
-		byte[] bytes = PTimestampArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PTimestampArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedTimeStampArray() {
-		Timestamp[] timeStampArr = new Timestamp[2];
-		timeStampArr[0] = new Timestamp(System.currentTimeMillis());
-		timeStampArr[1] = new Timestamp(900000l);
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedTimestamp.INSTANCE, timeStampArr);
-		PUnsignedTimestampArray.INSTANCE.toObject(arr,
-				PUnsignedTimestampArray.INSTANCE);
-		byte[] bytes = PUnsignedTimestampArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedTimestampArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForTimeArray() {
-		Time[] timeArr = new Time[2];
-		timeArr[0] = new Time(System.currentTimeMillis());
-		timeArr[1] = new Time(900000l);
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-        PTime.INSTANCE, timeArr);
-		PTimeArray.INSTANCE.toObject(arr, PTimeArray.INSTANCE);
-		byte[] bytes = PTimeArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PTimeArray.INSTANCE.toObject(
-				bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnsignedTimeArray() {
-		Time[] timeArr = new Time[2];
-		timeArr[0] = new Time(System.currentTimeMillis());
-		timeArr[1] = new Time(900000l);
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedTime.INSTANCE, timeArr);
-		PUnsignedTimeArray.INSTANCE.toObject(arr,
-				PUnsignedTimeArray.INSTANCE);
-		byte[] bytes = PUnsignedTimeArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedTimeArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForDateArray() {
-		Date[] dateArr = new Date[2];
-		dateArr[0] = new Date(System.currentTimeMillis());
-		dateArr[1] = new Date(System.currentTimeMillis()
-				+ System.currentTimeMillis());
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-        PDate.INSTANCE, dateArr);
-		PDateArray.INSTANCE.toObject(arr, PDateArray.INSTANCE);
-		byte[] bytes = PDateArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PDateArray.INSTANCE.toObject(
-				bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedDateArray() {
-		Date[] dateArr = new Date[2];
-		dateArr[0] = new Date(System.currentTimeMillis());
-		dateArr[1] = new Date(System.currentTimeMillis()
-				+ System.currentTimeMillis());
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedDate.INSTANCE, dateArr);
-		PUnsignedDateArray.INSTANCE.toObject(arr,
-				PUnsignedDateArray.INSTANCE);
-		byte[] bytes = PUnsignedDateArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedDateArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedLongArray() {
-		Long[] longArr = new Long[2];
-		longArr[0] = 1l;
-		longArr[1] = 2l;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedLong.INSTANCE, longArr);
-		PUnsignedLongArray.INSTANCE.toObject(arr,
-				PUnsignedLongArray.INSTANCE);
-		byte[] bytes = PUnsignedLongArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedLongArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedIntArray() {
-		Integer[] intArr = new Integer[2];
-		intArr[0] = 1;
-		intArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedInt.INSTANCE, intArr);
-		PUnsignedIntArray.INSTANCE
-				.toObject(arr, PUnsignedIntArray.INSTANCE);
-		byte[] bytes = PUnsignedIntArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedIntArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedSmallIntArray() {
-		Short[] shortArr = new Short[2];
-		shortArr[0] = 1;
-		shortArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedSmallint.INSTANCE, shortArr);
-		PUnsignedSmallintArray.INSTANCE.toObject(arr,
-				PUnsignedSmallintArray.INSTANCE);
-		byte[] bytes = PUnsignedSmallintArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedSmallintArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedTinyIntArray() {
-		Byte[] byteArr = new Byte[2];
-		byteArr[0] = 1;
-		byteArr[1] = 2;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedTinyint.INSTANCE, byteArr);
-		PUnsignedTinyintArray.INSTANCE.toObject(arr,
-				PUnsignedTinyintArray.INSTANCE);
-		byte[] bytes = PUnsignedTinyintArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedTinyintArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedFloatArray() {
-		Float[] floatArr = new Float[2];
-		floatArr[0] = 1.9993f;
-		floatArr[1] = 2.786f;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedFloat.INSTANCE, floatArr);
-		PUnsignedFloatArray.INSTANCE.toObject(arr,
-				PUnsignedFloatArray.INSTANCE);
-		byte[] bytes = PUnsignedFloatArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedFloatArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-	@Test
-	public void testForUnSignedDoubleArray() {
-		Double[] doubleArr = new Double[2];
-		doubleArr[0] = 1.9993;
-		doubleArr[1] = 2.786;
-		PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-				PUnsignedDouble.INSTANCE, doubleArr);
-		PUnsignedDoubleArray.INSTANCE.toObject(arr,
-				PUnsignedDoubleArray.INSTANCE);
-		byte[] bytes = PUnsignedDoubleArray.INSTANCE.toBytes(arr);
-		PhoenixArray resultArr = (PhoenixArray) PUnsignedDoubleArray.INSTANCE
-				.toObject(bytes, 0, bytes.length);
-		assertEquals(arr, resultArr);
-	}
-
-    @Test
-    public void testForArrayComparisionsForFixedWidth() {
-        Double[] doubleArr = new Double[2];
-        doubleArr[0] = 1.9993;
-        doubleArr[1] = 2.786;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PUnsignedDouble.INSTANCE, doubleArr);
-        PUnsignedDoubleArray.INSTANCE.toObject(arr, PUnsignedDoubleArray.INSTANCE);
-        byte[] bytes1 = PUnsignedDoubleArray.INSTANCE.toBytes(arr);
-
-        doubleArr = new Double[2];
-        doubleArr[0] = 1.9993;
-        doubleArr[1] = 2.786;
-        arr = PArrayDataType.instantiatePhoenixArray(PUnsignedDouble.INSTANCE, doubleArr);
-        PUnsignedDoubleArray.INSTANCE.toObject(arr, PUnsignedDoubleArray.INSTANCE);
-        byte[] bytes2 = PUnsignedDoubleArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.equals(bytes1, bytes2));
-    }
-
-    @Test
-    public void testForArrayComparisionsWithInEqualityForFixedWidth() {
-        Double[] doubleArr = new Double[2];
-        doubleArr[0] = 1.9993;
-        doubleArr[1] = 2.786;
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PUnsignedDouble.INSTANCE, doubleArr);
-        PUnsignedDoubleArray.INSTANCE.toObject(arr, PUnsignedDoubleArray.INSTANCE);
-        byte[] bytes1 = PUnsignedDoubleArray.INSTANCE.toBytes(arr);
-
-        doubleArr = new Double[3];
-        doubleArr[0] = 1.9993;
-        doubleArr[1] = 2.786;
-        doubleArr[2] = 6.3;
-        arr = PArrayDataType.instantiatePhoenixArray(PUnsignedDouble.INSTANCE, doubleArr);
-        PUnsignedDoubleArray.INSTANCE.toObject(arr, PUnsignedDoubleArray.INSTANCE);
-        byte[] bytes2 = PUnsignedDoubleArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.compareTo(bytes1, bytes2) < 0);
-    }
-
-    @Test
-    public void testForArrayComparisonsForVarWidthArrays() {
-        String[] strArr = new String[5];
-        strArr[0] = "abc";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random1";
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes1 = PVarcharArray.INSTANCE.toBytes(arr);
-
-        strArr = new String[5];
-        strArr[0] = "abc";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random1";
-        strArr[4] = "ran";
-        arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes2 = PVarcharArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.equals(bytes1, bytes2));
-    }
-
-    @Test
-    public void testForArrayComparisonsInEqualityForVarWidthArrays() {
-        String[] strArr = new String[5];
-        strArr[0] = "abc";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random1";
-        strArr[4] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes1 = PVarcharArray.INSTANCE.toBytes(arr);
-
-        strArr = new String[5];
-        strArr[0] = "abc";
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = "random1";
-        arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes2 = PVarcharArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.compareTo(bytes1, bytes2) > 0);
-    }
-
-    @Test
-    public void testForArrayComparsionInEqualityWithNullsRepeatingInTheMiddle() {
-        String[] strArr = new String[6];
-        strArr[0] = null;
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = "ran";
-        strArr[5] = "ran";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes1 = PVarcharArray.INSTANCE.toBytes(arr);
-
-        strArr = new String[6];
-        strArr[0] = null;
-        strArr[1] = "ereref";
-        strArr[2] = "random";
-        strArr[3] = null;
-        strArr[4] = null;
-        strArr[5] = "ran";
-        arr = PArrayDataType.instantiatePhoenixArray(PVarchar.INSTANCE, strArr);
-        byte[] bytes2 = PVarcharArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.compareTo(bytes1, bytes2) > 0);
-    }
-    
-    @Test
-    public void testVarCharArrayWithGreatherThan255NullsInMiddle() {
-        String strArr[] = new String[300];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = "bcd";
-        for(int i = 5; i < strArr.length - 2; i++) {
-            strArr[i] = null;
-        }
-        strArr[strArr.length - 1] = "abc";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr);
-        PhoenixArray resultArr = (PhoenixArray) PVarcharArray.INSTANCE
-                .toObject(bytes, 0, bytes.length);
-        assertEquals(arr, resultArr);
-    }
-    
-    @Test
-    public void testVarCharArrayComparisonWithGreaterThan255NullsinMiddle() {
-        String strArr[] = new String[240];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = "bcd";
-        strArr[strArr.length - 1] = "abc";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes1 = PVarcharArray.INSTANCE.toBytes(arr);
-        
-        strArr = new String[16];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = "bcd";
-        strArr[strArr.length - 1] = "abc";
-        arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes2 = PVarcharArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.compareTo(bytes1, bytes2) < 0);
-    }
-    
-    @Test
-    public void testVarCharArrayComparisonWithGreaterThan255NullsinMiddle1() {
-        String strArr[] = new String[500];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = "bcd";
-        strArr[strArr.length - 1] = "abc";
-        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes1 = PVarcharArray.INSTANCE.toBytes(arr);
-        
-        strArr = new String[500];
-        strArr[0] = "abc";
-        strArr[1] = "bcd";
-        strArr[2] = null;
-        strArr[3] = null;
-        strArr[4] = "bcd";
-        strArr[strArr.length - 1] = "abc";
-        arr = PArrayDataType.instantiatePhoenixArray(
-                PVarchar.INSTANCE, strArr);
-        byte[] bytes2 = PVarcharArray.INSTANCE.toBytes(arr);
-        assertTrue(Bytes.compareTo(bytes1, bytes2) == 0);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePhoenixArrayToStringTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePhoenixArrayToStringTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePhoenixArrayToStringTest.java
new file mode 100644
index 0000000..d67c599
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePhoenixArrayToStringTest.java
@@ -0,0 +1,81 @@
+/*
+ * 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.schema.types;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+
+public abstract class BasePhoenixArrayToStringTest {
+
+    @Test
+    public void testEmptyArray() {
+        helpTestToString(getBaseType(), new Object[] {}, "[]");
+    }
+
+    @Test
+    public void testSingleObjectArray() {
+        helpTestToString(getBaseType(), new Object[] { getElement1() }, "[" + getString1() + "]");
+    }
+
+    @Test
+    public void testMultipleObjectArray() {
+        // Object[] arr = createArray(getBaseJavaType(), 3);
+        // arr[0] = getElement1();
+        // arr[1] = getElement2();
+        // arr[2] = getElement3();
+        helpTestToString(getBaseType(),
+            new Object[] { getElement1(), getElement2(), getElement3() }, "[" + getString1() + ", "
+                    + getString2() + ", " + getString3() + "]");
+    }
+
+    @Test
+    public void testSingleNullObjectArray() {
+        helpTestToString(getBaseType(), new Object[] { null }, "[" + getNullString() + "]");
+    }
+
+    @Test
+    public void testMultipleNullObjectArray() {
+        helpTestToString(getBaseType(), new Object[] { null, null }, "[" + getNullString() + ", "
+                + getNullString() + "]");
+    }
+
+    @Test
+    public void testNormalAndNullObjectArray() {
+        helpTestToString(getBaseType(), new Object[] { null, getElement1(), null, getElement2() },
+            "[" + getNullString() + ", " + getString1() + ", " + getNullString() + ", "
+                    + getString2() + "]");
+    }
+
+    protected abstract PDataType getBaseType();
+
+    protected abstract Object getElement1();
+
+    protected abstract String getString1();
+
+    protected abstract Object getElement2();
+
+    protected abstract String getString2();
+
+    protected abstract Object getElement3();
+
+    protected abstract String getString3();
+
+    protected String getNullString() {
+        return "null";
+    }
+
+    protected void helpTestToString(PDataType type, Object[] array, String expected) {
+        PhoenixArray arr = PArrayDataType.instantiatePhoenixArray(type, array);
+        assertEquals(expected, arr.toString());
+    }
+
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveDoublePhoenixArrayToStringTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveDoublePhoenixArrayToStringTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveDoublePhoenixArrayToStringTest.java
new file mode 100644
index 0000000..7ee7428
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveDoublePhoenixArrayToStringTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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.schema.types;
+
+public abstract class BasePrimitiveDoublePhoenixArrayToStringTest extends
+        BasePhoenixArrayToStringTest {
+
+    public BasePrimitiveDoublePhoenixArrayToStringTest() {
+        super();
+    }
+
+    @Override
+    protected String getString1() {
+        return "1.1";
+    }
+
+    @Override
+    protected String getString2() {
+        return "2.2";
+    }
+
+    @Override
+    protected String getString3() {
+        return "3.3";
+    }
+
+    @Override
+    protected String getNullString() {
+        return "0.0";
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/phoenix/blob/45c9716c/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveIntPhoenixArrayToStringTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveIntPhoenixArrayToStringTest.java b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveIntPhoenixArrayToStringTest.java
new file mode 100644
index 0000000..0f105bc
--- /dev/null
+++ b/phoenix-core/src/test/java/org/apache/phoenix/schema/types/BasePrimitiveIntPhoenixArrayToStringTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.schema.types;
+
+public abstract class BasePrimitiveIntPhoenixArrayToStringTest extends BasePhoenixArrayToStringTest {
+
+    @Override
+    protected Number getElement1() {
+        return 1;
+    }
+
+    @Override
+    protected String getString1() {
+        return "1";
+    }
+
+    @Override
+    protected Number getElement2() {
+        return 2;
+    }
+
+    @Override
+    protected String getString2() {
+        return "2";
+    }
+
+    @Override
+    protected Number getElement3() {
+        return 3;
+    }
+
+    @Override
+    protected String getString3() {
+        return "3";
+    }
+
+    @Override
+    protected String getNullString() {
+        return "0";
+    }
+
+}
\ No newline at end of file


Mime
View raw message