use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method testDateSubColCol.
@Test
public void testDateSubColCol() {
for (VectorExpression.Type colType1 : dateTimestampStringTypes) testDateAddColCol(colType1, false);
VectorExpression udf = new VectorUDFDateSubColCol(0, 1, 2);
VectorizedRowBatch batch = new VectorizedRowBatch(3, 1);
BytesColumnVector bcv;
byte[] bytes = "error".getBytes(utf8);
udf.setInputTypes(VectorExpression.Type.STRING, VectorExpression.Type.TIMESTAMP);
batch.cols[0] = new BytesColumnVector(1);
batch.cols[1] = new LongColumnVector(1);
batch.cols[2] = new LongColumnVector(1);
bcv = (BytesColumnVector) batch.cols[0];
bcv.vector[0] = bytes;
bcv.start[0] = 0;
bcv.length[0] = bytes.length;
udf.evaluate(batch);
Assert.assertEquals(batch.cols[2].isNull[0], true);
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method testDateSubColScalar.
@Test
public void testDateSubColScalar() {
for (VectorExpression.Type colType1 : dateTimestampStringTypes) testDateAddColScalar(colType1, false);
VectorExpression udf = new VectorUDFDateSubColScalar(0, 0, 1);
udf.setInputTypes(VectorExpression.Type.STRING, VectorExpression.Type.TIMESTAMP);
VectorizedRowBatch batch = new VectorizedRowBatch(2, 1);
batch.cols[0] = new BytesColumnVector(1);
batch.cols[1] = new LongColumnVector(1);
BytesColumnVector bcv = (BytesColumnVector) batch.cols[0];
byte[] bytes = "error".getBytes(utf8);
bcv.vector[0] = bytes;
bcv.start[0] = 0;
bcv.length[0] = bytes.length;
udf.evaluate(batch);
Assert.assertEquals(batch.cols[1].isNull[0], true);
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method testDate.
@Test
public void testDate() {
for (VectorExpression.Type colType : dateTimestampStringTypes) {
LongColumnVector date = newRandomLongColumnVector(10000, size);
LongColumnVector output = new LongColumnVector(size);
VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
batch.cols[0] = castTo(date, colType);
batch.cols[1] = output;
validateDate(batch, colType, date);
TestVectorizedRowBatch.addRandomNulls(date);
batch.cols[0] = castTo(date, colType);
validateDate(batch, colType, date);
}
VectorExpression udf = new VectorUDFDateString(0, 1);
udf.setInputTypes(VectorExpression.Type.STRING);
VectorizedRowBatch batch = new VectorizedRowBatch(2, 1);
batch.cols[0] = new BytesColumnVector(1);
batch.cols[1] = new LongColumnVector(1);
BytesColumnVector bcv = (BytesColumnVector) batch.cols[0];
byte[] bytes = "error".getBytes(utf8);
bcv.vector[0] = bytes;
bcv.start[0] = 0;
bcv.length[0] = bytes.length;
udf.evaluate(batch);
Assert.assertEquals(batch.cols[1].isNull[0], true);
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorStringExpressions method makeStringBatchMixedCase.
VectorizedRowBatch makeStringBatchMixedCase() {
// create a batch with two string ("Bytes") columns
VectorizedRowBatch batch = new VectorizedRowBatch(2, VectorizedRowBatch.DEFAULT_SIZE);
BytesColumnVector v = new BytesColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
batch.cols[0] = v;
BytesColumnVector outV = new BytesColumnVector(VectorizedRowBatch.DEFAULT_SIZE);
outV.initBuffer();
batch.cols[1] = outV;
/*
* Add these 3 values:
*
* mixedUp
* green
* NULL
*/
v.setRef(0, mixedUp, 0, mixedUp.length);
v.isNull[0] = false;
v.setRef(1, green, 0, green.length);
v.isNull[1] = false;
v.setRef(2, emptyString, 0, emptyString.length);
v.isNull[2] = true;
v.noNulls = false;
batch.size = 3;
return batch;
}
use of org.apache.hadoop.hive.ql.exec.vector.BytesColumnVector in project hive by apache.
the class TestVectorStringExpressions method testVectorTrim.
@Test
public void testVectorTrim() {
VectorizedRowBatch b = makeTrimBatch();
VectorExpression expr = new StringTrim(0, 1);
expr.evaluate(b);
BytesColumnVector outV = (BytesColumnVector) b.cols[1];
Assert.assertEquals(0, StringExpr.compare(emptyString, 0, 0, outV.vector[0], 0, 0));
Assert.assertEquals(0, StringExpr.compare(blanksLeft, 2, 3, outV.vector[1], outV.start[1], outV.length[1]));
Assert.assertEquals(0, StringExpr.compare(blanksRight, 0, 3, outV.vector[2], outV.start[2], outV.length[2]));
Assert.assertEquals(0, StringExpr.compare(blanksBoth, 2, 3, outV.vector[3], outV.start[3], outV.length[3]));
Assert.assertEquals(0, StringExpr.compare(red, 0, 3, outV.vector[4], outV.start[4], outV.length[4]));
Assert.assertEquals(0, StringExpr.compare(blankString, 0, 0, outV.vector[5], outV.start[5], outV.length[5]));
}
Aggregations