use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method validateDateDiff.
private void validateDateDiff(VectorizedRowBatch batch, LongColumnVector date1, long scalar2, VectorExpression.Type colType1, VectorExpression.Type scalarType2) {
VectorExpression udf = null;
switch(scalarType2) {
case DATE:
udf = new VectorUDFDateDiffColScalar(0, scalar2, 1);
break;
case TIMESTAMP:
udf = new VectorUDFDateDiffColScalar(0, toTimestamp(scalar2), 1);
break;
case STRING:
udf = new VectorUDFDateDiffColScalar(0, toString(scalar2), 1);
break;
}
udf.setInputTypes(colType1, scalarType2);
udf.evaluate(batch);
LongColumnVector output = (LongColumnVector) batch.cols[1];
for (int i = 0; i < date1.vector.length; i++) {
Assert.assertEquals(date1.vector[i] - scalar2, output.vector[i]);
}
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method testDateAddColCol.
private void testDateAddColCol(VectorExpression.Type colType1, boolean isPositive) {
LongColumnVector date1 = newRandomLongColumnVector(10000, size);
LongColumnVector days2 = newRandomLongColumnVector(1000, size);
ColumnVector col1 = castTo(date1, colType1);
LongColumnVector output = new LongColumnVector(size);
VectorizedRowBatch batch = new VectorizedRowBatch(3, size);
batch.cols[0] = col1;
batch.cols[1] = days2;
batch.cols[2] = output;
validateDateAdd(batch, date1, days2, colType1, isPositive);
TestVectorizedRowBatch.addRandomNulls(date1);
batch.cols[0] = castTo(date1, colType1);
validateDateAdd(batch, date1, days2, colType1, isPositive);
TestVectorizedRowBatch.addRandomNulls(days2);
batch.cols[1] = days2;
validateDateAdd(batch, date1, days2, colType1, isPositive);
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorGenericDateExpressions method testToDate.
@Test
public void testToDate() {
for (VectorExpression.Type type : Arrays.asList(VectorExpression.Type.TIMESTAMP, VectorExpression.Type.STRING)) {
LongColumnVector date = newRandomLongColumnVector(10000, size);
LongColumnVector output = new LongColumnVector(size);
VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
batch.cols[0] = castTo(date, type);
batch.cols[1] = output;
validateToDate(batch, type, date);
TestVectorizedRowBatch.addRandomNulls(date);
batch.cols[0] = castTo(date, type);
validateToDate(batch, type, date);
}
VectorExpression udf = new CastStringToDate(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.LongColumnVector in project hive by apache.
the class TestVectorFilterExpressions method testFilterLongColLessLongColumn.
@Test
public void testFilterLongColLessLongColumn() {
int seed = 17;
VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 3, seed);
LongColumnVector lcv0 = (LongColumnVector) vrg.cols[0];
LongColumnVector lcv1 = (LongColumnVector) vrg.cols[1];
LongColumnVector lcv2 = (LongColumnVector) vrg.cols[2];
FilterLongColLessLongColumn expr = new FilterLongColLessLongColumn(2, 1);
LongColAddLongScalar childExpr = new LongColAddLongScalar(0, 10, 2);
expr.setChildExpressions(new VectorExpression[] { childExpr });
//Basic case
lcv0.vector[0] = 10;
lcv0.vector[1] = 20;
lcv0.vector[2] = 9;
lcv0.vector[3] = 20;
lcv0.vector[4] = 10;
lcv1.vector[0] = 20;
lcv1.vector[1] = 10;
lcv1.vector[2] = 20;
lcv1.vector[3] = 10;
lcv1.vector[4] = 20;
expr.evaluate(vrg);
assertEquals(1, vrg.size);
assertEquals(2, vrg.selected[0]);
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorFilterExpressions method getSimpleLongBatch.
private VectorizedRowBatch getSimpleLongBatch() {
VectorizedRowBatch batch = VectorizedRowGroupGenUtil.getVectorizedRowBatch(4, 1, 1);
LongColumnVector lcv0 = (LongColumnVector) batch.cols[0];
lcv0.vector[0] = 0;
lcv0.vector[1] = 1;
lcv0.vector[2] = 2;
lcv0.vector[3] = 3;
return batch;
}
Aggregations