use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus in project hive by apache.
the class TestVectorizationContext method testUnaryMinusColumnLong.
@Test
public void testUnaryMinusColumnLong() throws HiveException {
ExprNodeColumnDesc col1Expr = new ExprNodeColumnDesc(Integer.class, "col1", "table", false);
GenericUDF gudf = new GenericUDFOPNegative();
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>(1);
children.add(col1Expr);
ExprNodeGenericFuncDesc negExprDesc = new ExprNodeGenericFuncDesc(TypeInfoFactory.longTypeInfo, gudf, children);
List<String> columns = new ArrayList<String>();
columns.add("col0");
columns.add("col1");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(negExprDesc, VectorExpressionDescriptor.Mode.PROJECTION);
assertTrue(ve instanceof LongColUnaryMinus);
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus in project hive by apache.
the class TestUnaryMinus method testUnaryMinus.
@Test
public void testUnaryMinus() {
VectorizedRowBatch vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(1024, 2, 23);
LongColUnaryMinus expr = new LongColUnaryMinus(0, 1);
expr.evaluate(vrg);
//verify
long[] inVector = ((LongColumnVector) vrg.cols[0]).vector;
long[] outVector = ((LongColumnVector) vrg.cols[1]).vector;
for (int i = 0; i < outVector.length; i++) {
assertEquals(0, inVector[i] + outVector[i]);
}
}
Aggregations