use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.
the class PDataTypeForArraysTest method testForArrayComparisonsInEqualityForVarWidthArrays.
@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);
}
use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.
the class PDataTypeForArraysTest method testPositionSearchWithVarLengthArrayWithNullValue1.
@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);
PArrayDataTypeDecoder.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));
}
use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.
the class PDataTypeForArraysTest method testPositionSearchWithVarLengthArrayWithNullValue5.
@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);
PArrayDataTypeDecoder.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));
}
use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.
the class PDataTypeForArraysTest method testForUnSignedTinyIntArray.
@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);
}
use of org.apache.phoenix.schema.types.PhoenixArray in project phoenix by apache.
the class PDataTypeForArraysTest method testIsRowKeyOrderOptimized1.
@Test
public void testIsRowKeyOrderOptimized1() {
Object[] objects = new Object[] { "a", "b", "c" };
PhoenixArray arr = new PhoenixArray(PVarchar.INSTANCE, objects);
byte[] bytes = PVarcharArray.INSTANCE.toBytes(arr, PVarchar.INSTANCE, SortOrder.ASC);
assertTrue(PArrayDataType.isRowKeyOrderOptimized(PVarcharArray.INSTANCE, SortOrder.ASC, bytes, 0, bytes.length));
}
Aggregations