Search in sources :

Example 36 with PhoenixArray

use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.

the class PDataTypeForArraysTest method testForUnSignedIntArray.

@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);
}
Also used : PInteger(org.apache.phoenix.schema.types.PInteger) PhoenixArray(org.apache.phoenix.schema.types.PhoenixArray) Test(org.junit.Test)

Example 37 with PhoenixArray

use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.

the class PDataTypeForArraysTest method testForUnSignedDoubleArray.

@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);
}
Also used : PhoenixArray(org.apache.phoenix.schema.types.PhoenixArray) PUnsignedDouble(org.apache.phoenix.schema.types.PUnsignedDouble) PDouble(org.apache.phoenix.schema.types.PDouble) Test(org.junit.Test)

Example 38 with PhoenixArray

use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.

the class PDataTypeForArraysTest method testForTimeArray.

@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);
}
Also used : PhoenixArray(org.apache.phoenix.schema.types.PhoenixArray) Time(java.sql.Time) PUnsignedTime(org.apache.phoenix.schema.types.PUnsignedTime) PTime(org.apache.phoenix.schema.types.PTime) Test(org.junit.Test)

Example 39 with PhoenixArray

use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.

the class PDataTypeForArraysTest method testForIntegerArray.

@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);
}
Also used : PInteger(org.apache.phoenix.schema.types.PInteger) PhoenixArray(org.apache.phoenix.schema.types.PhoenixArray) Test(org.junit.Test)

Example 40 with PhoenixArray

use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.

the class PDataTypeForArraysTest method testIsRowKeyOrderOptimized2.

@Test
public void testIsRowKeyOrderOptimized2() {
    Object[] objects = new Object[] { "a", "b", "c" };
    PhoenixArray arr = new PhoenixArray(PVarchar.INSTANCE, objects);
    byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr, SortOrder.DESC);
    assertTrue(PArrayDataType.isRowKeyOrderOptimized(PVarcharArray.INSTANCE, SortOrder.DESC, bytes, 0, bytes.length));
}
Also used : PhoenixArray(org.apache.phoenix.schema.types.PhoenixArray) Test(org.junit.Test)

Aggregations

PhoenixArray (org.apache.phoenix.schema.types.PhoenixArray)107 Test (org.junit.Test)97 Connection (java.sql.Connection)25 ResultSet (java.sql.ResultSet)25 PSmallint (org.apache.phoenix.schema.types.PSmallint)25 PTinyint (org.apache.phoenix.schema.types.PTinyint)25 PUnsignedSmallint (org.apache.phoenix.schema.types.PUnsignedSmallint)25 PUnsignedTinyint (org.apache.phoenix.schema.types.PUnsignedTinyint)25 ImmutableBytesWritable (org.apache.hadoop.hbase.io.ImmutableBytesWritable)23 PreparedStatement (java.sql.PreparedStatement)7 Properties (java.util.Properties)7 BaseTest (org.apache.phoenix.query.BaseTest)7 Array (java.sql.Array)6 PDouble (org.apache.phoenix.schema.types.PDouble)5 PLong (org.apache.phoenix.schema.types.PLong)4 PUnsignedLong (org.apache.phoenix.schema.types.PUnsignedLong)4 Timestamp (java.sql.Timestamp)3 PTimestamp (org.apache.phoenix.schema.types.PTimestamp)3 PUnsignedDouble (org.apache.phoenix.schema.types.PUnsignedDouble)3 PUnsignedTimestamp (org.apache.phoenix.schema.types.PUnsignedTimestamp)3