Search in sources :

Example 1 with LongColUnaryMinus

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);
}
Also used : GenericUDF(org.apache.hadoop.hive.ql.udf.generic.GenericUDF) ExprNodeColumnDesc(org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc) ArrayList(java.util.ArrayList) GenericUDFOPNegative(org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNegative) ExprNodeGenericFuncDesc(org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc) VectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression) DynamicValueVectorExpression(org.apache.hadoop.hive.ql.exec.vector.expressions.DynamicValueVectorExpression) ExprNodeDesc(org.apache.hadoop.hive.ql.plan.ExprNodeDesc) LongColUnaryMinus(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus) Test(org.junit.Test)

Example 2 with 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]);
    }
}
Also used : VectorizedRowBatch(org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch) LongColUnaryMinus(org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus) LongColumnVector(org.apache.hadoop.hive.ql.exec.vector.LongColumnVector) Test(org.junit.Test)

Aggregations

LongColUnaryMinus (org.apache.hadoop.hive.ql.exec.vector.expressions.gen.LongColUnaryMinus)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 LongColumnVector (org.apache.hadoop.hive.ql.exec.vector.LongColumnVector)1 VectorizedRowBatch (org.apache.hadoop.hive.ql.exec.vector.VectorizedRowBatch)1 DynamicValueVectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.DynamicValueVectorExpression)1 VectorExpression (org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression)1 ExprNodeColumnDesc (org.apache.hadoop.hive.ql.plan.ExprNodeColumnDesc)1 ExprNodeDesc (org.apache.hadoop.hive.ql.plan.ExprNodeDesc)1 ExprNodeGenericFuncDesc (org.apache.hadoop.hive.ql.plan.ExprNodeGenericFuncDesc)1 GenericUDF (org.apache.hadoop.hive.ql.udf.generic.GenericUDF)1 GenericUDFOPNegative (org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPNegative)1