use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorArithmeticExpressions method getVectorizedRowBatch2LongInLongOut.
private VectorizedRowBatch getVectorizedRowBatch2LongInLongOut() {
VectorizedRowBatch batch = new VectorizedRowBatch(3);
LongColumnVector lcv, lcv2;
lcv = new LongColumnVector();
for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
lcv.vector[i] = i * 37;
}
batch.cols[0] = lcv;
lcv2 = new LongColumnVector();
batch.cols[1] = lcv2;
for (int i = 0; i < VectorizedRowBatch.DEFAULT_SIZE; i++) {
lcv2.vector[i] = i * 37;
}
batch.cols[2] = new LongColumnVector();
batch.size = VectorizedRowBatch.DEFAULT_SIZE;
return batch;
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorDateExpressions method getVectorizedRowBatch.
/**
* Input array is used to fill the entire size of the vector row batch
*/
private VectorizedRowBatch getVectorizedRowBatch(int[] inputs, int size) {
VectorizedRowBatch batch = new VectorizedRowBatch(2, size);
LongColumnVector lcv = new LongColumnVector(size);
for (int i = 0; i < size; i++) {
lcv.vector[i] = inputs[i % inputs.length];
}
batch.cols[0] = lcv;
batch.cols[1] = new LongColumnVector(size);
batch.size = size;
return batch;
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorFilterExpressions method testFilterLongBetween.
@Test
public void testFilterLongBetween() {
int seed = 17;
VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 2, seed);
LongColumnVector lcv0 = (LongColumnVector) vrb.cols[0];
VectorExpression expr1 = new FilterLongColumnBetween(0, 15, 17);
// Basic case
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
expr1.evaluate(vrb);
assertEquals(2, vrb.size);
assertTrue(vrb.selectedInUse);
assertEquals(2, vrb.selected[0]);
assertEquals(3, vrb.selected[1]);
// With nulls
VectorizedRowBatch vrb1 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 2, seed);
lcv0 = (LongColumnVector) vrb1.cols[0];
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
lcv0.noNulls = false;
lcv0.isNull[0] = true;
lcv0.isNull[2] = true;
expr1.evaluate(vrb1);
assertEquals(1, vrb1.size);
assertTrue(vrb1.selectedInUse);
assertEquals(3, vrb1.selected[0]);
// With nulls and selected
VectorizedRowBatch vrb2 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(7, 2, seed);
vrb2.selectedInUse = true;
vrb2.selected[0] = 1;
vrb2.selected[1] = 2;
vrb2.selected[2] = 4;
vrb2.size = 3;
lcv0 = (LongColumnVector) vrb2.cols[0];
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
lcv0.vector[5] = 19;
lcv0.vector[6] = 21;
lcv0.noNulls = false;
lcv0.isNull[0] = true;
lcv0.isNull[2] = true;
lcv0.isNull[5] = true;
expr1.evaluate(vrb2);
assertEquals(0, vrb2.size);
// Repeating non null
VectorizedRowBatch vrb3 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(7, 2, seed);
lcv0 = (LongColumnVector) vrb3.cols[0];
lcv0.isRepeating = true;
lcv0.vector[0] = 17;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
expr1.evaluate(vrb3);
assertEquals(7, vrb3.size);
assertFalse(vrb3.selectedInUse);
assertTrue(lcv0.isRepeating);
// Repeating null
lcv0.noNulls = false;
lcv0.vector[0] = 17;
lcv0.isNull[0] = true;
expr1.evaluate(vrb3);
assertEquals(0, vrb3.size);
}
use of org.apache.hadoop.hive.ql.exec.vector.LongColumnVector in project hive by apache.
the class TestVectorFilterExpressions method testFilterLongIn.
/**
* Test the IN filter VectorExpression classes.
*/
@Test
public void testFilterLongIn() throws HiveException {
int seed = 17;
VectorizedRowBatch vrb = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 2, seed);
LongColumnVector lcv0 = (LongColumnVector) vrb.cols[0];
long[] inList = { 5, 20 };
FilterLongColumnInList f = new FilterLongColumnInList(0);
f.setInListValues(inList);
f.setInputTypeInfos(new TypeInfo[] { TypeInfoFactory.longTypeInfo });
f.transientInit();
VectorExpression expr1 = f;
// Basic case
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
expr1.evaluate(vrb);
assertEquals(2, vrb.size);
assertTrue(vrb.selectedInUse);
assertEquals(0, vrb.selected[0]);
assertEquals(1, vrb.selected[1]);
// With nulls
VectorizedRowBatch vrb1 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(5, 2, seed);
lcv0 = (LongColumnVector) vrb1.cols[0];
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
lcv0.noNulls = false;
lcv0.isNull[0] = true;
lcv0.isNull[2] = true;
expr1.evaluate(vrb1);
assertEquals(1, vrb1.size);
assertTrue(vrb1.selectedInUse);
assertEquals(1, vrb1.selected[0]);
// With nulls and selected
VectorizedRowBatch vrb2 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(7, 2, seed);
vrb2.selectedInUse = true;
vrb2.selected[0] = 1;
vrb2.selected[1] = 2;
vrb2.selected[2] = 4;
vrb2.size = 3;
lcv0 = (LongColumnVector) vrb2.cols[0];
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
lcv0.vector[5] = 19;
lcv0.vector[6] = 21;
lcv0.noNulls = false;
lcv0.isNull[0] = true;
lcv0.isNull[2] = true;
lcv0.isNull[5] = true;
expr1.evaluate(vrb2);
assertEquals(1, vrb2.size);
assertEquals(1, vrb2.selected[0]);
// Repeating non null
VectorizedRowBatch vrb3 = VectorizedRowGroupGenUtil.getVectorizedRowBatch(7, 2, seed);
lcv0 = (LongColumnVector) vrb3.cols[0];
lcv0.isRepeating = true;
lcv0.vector[0] = 5;
lcv0.vector[1] = 20;
lcv0.vector[2] = 17;
lcv0.vector[3] = 15;
lcv0.vector[4] = 10;
expr1.evaluate(vrb3);
assertEquals(7, vrb3.size);
assertFalse(vrb3.selectedInUse);
assertTrue(lcv0.isRepeating);
// Repeating null
lcv0.noNulls = false;
lcv0.vector[0] = 5;
lcv0.isNull[0] = true;
expr1.evaluate(vrb3);
assertEquals(0, vrb3.size);
}
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]);
}
Aggregations