use of org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperGeneral in project hive by apache.
the class TestVectorHashKeyWrapperBatch method testVectorHashKeyWrapperGeneralCopyKey.
// Test for HIVE-24575
@Test
public void testVectorHashKeyWrapperGeneralCopyKey() throws HiveException {
VectorExpression[] keyExpressions = new VectorExpression[] { new IdentityExpression(0) };
TypeInfo[] typeInfos = new TypeInfo[] { TypeInfoFactory.stringTypeInfo };
VectorHashKeyWrapperBatch vhkwb = VectorHashKeyWrapperBatch.compileKeyWrapperBatch(keyExpressions, typeInfos);
VectorizedRowBatch batch = new VectorizedRowBatch(1);
batch.selectedInUse = false;
BytesColumnVector bytesColumnVector = new BytesColumnVector();
bytesColumnVector.initBuffer(1024);
batch.cols[0] = bytesColumnVector;
byte[] contents = "education_reference".getBytes();
bytesColumnVector.setVal(0, "system_management".getBytes());
bytesColumnVector.setVal(1, "travel_transportation".getBytes());
bytesColumnVector.setVal(2, contents);
bytesColumnVector.setVal(3, "app_management".getBytes());
batch.size = 4;
vhkwb.evaluateBatch(batch);
VectorHashKeyWrapperBase[] vhkwArray = vhkwb.getVectorHashKeyWrappers();
VectorHashKeyWrapperGeneral hashKey2 = (VectorHashKeyWrapperGeneral) vhkwArray[2];
VectorHashKeyWrapperGeneral hashKey1 = (VectorHashKeyWrapperGeneral) vhkwArray[1];
assertTrue(StringExpr.equal(hashKey2.getBytes(0), hashKey2.getByteStart(0), hashKey2.getByteLength(0), contents, 0, contents.length));
assertFalse(StringExpr.equal(hashKey2.getBytes(0), hashKey2.getByteStart(0), hashKey2.getByteLength(0), hashKey1.getBytes(0), hashKey1.getByteStart(0), hashKey1.getByteLength(0)));
hashKey2.copyKey(hashKey1);
assertTrue(StringExpr.equal(hashKey2.getBytes(0), hashKey2.getByteStart(0), hashKey2.getByteLength(0), contents, 0, contents.length));
assertTrue(StringExpr.equal(hashKey2.getBytes(0), hashKey2.getByteStart(0), hashKey2.getByteLength(0), hashKey1.getBytes(0), hashKey1.getByteStart(0), hashKey1.getByteLength(0)));
}
Aggregations