Search in sources :

Example 1 with VectorHashKeyWrapperGeneral

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)));
}
Also used : VectorHashKeyWrapperBase(org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperBase) VectorHashKeyWrapperGeneral(org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperGeneral) VectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression) IdentityExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.IdentityExpression) TypeInfo(org.apache.hadoop.hive.serde2.typeinfo.TypeInfo) VectorHashKeyWrapperBatch(org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperBatch) Test(org.junit.Test)

Aggregations

IdentityExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.IdentityExpression)1 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)1 VectorHashKeyWrapperBase (org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperBase)1 VectorHashKeyWrapperBatch (org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperBatch)1 VectorHashKeyWrapperGeneral (org.apache.hadoop.hive.ql.exec.vector.wrapper.VectorHashKeyWrapperGeneral)1 TypeInfo (org.apache.hadoop.hive.serde2.typeinfo.TypeInfo)1 Test (org.junit.Test)1