use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan in project hive by apache.
the class TestVectorizationContext method testFilterWithNegativeScalar.
@Test
public void testFilterWithNegativeScalar() throws HiveException {
ExprNodeColumnDesc col1Expr = new ExprNodeColumnDesc(Integer.class, "col1", "table", false);
ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(new Integer(-10));
GenericUDFOPGreaterThan udf = new GenericUDFOPGreaterThan();
ExprNodeGenericFuncDesc exprDesc = new ExprNodeGenericFuncDesc();
exprDesc.setGenericUDF(udf);
List<ExprNodeDesc> children1 = new ArrayList<ExprNodeDesc>(2);
children1.add(col1Expr);
children1.add(constDesc);
exprDesc.setChildren(children1);
List<String> columns = new ArrayList<String>();
columns.add("col0");
columns.add("col1");
columns.add("col2");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(exprDesc, VectorExpressionDescriptor.Mode.FILTER);
assertTrue(ve instanceof FilterLongColGreaterLongScalar);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan in project hive by apache.
the class TestVectorizationContext method testNotExpression.
@Test
public void testNotExpression() throws HiveException {
ExprNodeColumnDesc col1Expr = new ExprNodeColumnDesc(Integer.class, "col1", "table", false);
ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(new Integer(10));
GenericUDFOPGreaterThan udf = new GenericUDFOPGreaterThan();
ExprNodeGenericFuncDesc greaterExprDesc = new ExprNodeGenericFuncDesc();
greaterExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
greaterExprDesc.setGenericUDF(udf);
List<ExprNodeDesc> children1 = new ArrayList<ExprNodeDesc>(2);
children1.add(col1Expr);
children1.add(constDesc);
greaterExprDesc.setChildren(children1);
ExprNodeGenericFuncDesc notExpr = new ExprNodeGenericFuncDesc();
notExpr.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
GenericUDFOPNot notUdf = new GenericUDFOPNot();
notExpr.setGenericUDF(notUdf);
List<ExprNodeDesc> childOfNot = new ArrayList<ExprNodeDesc>();
childOfNot.add(greaterExprDesc);
notExpr.setChildren(childOfNot);
List<String> columns = new ArrayList<String>();
columns.add("col0");
columns.add("col1");
columns.add("col2");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(notExpr, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(ve.getClass(), SelectColumnIsFalse.class);
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
ve = vc.getVectorExpression(notExpr, VectorExpressionDescriptor.Mode.PROJECTION);
assertEquals(ve.getClass(), NotCol.class);
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan in project hive by apache.
the class TestVectorizationContext method testFilterScalarCompareColumn.
@Test
public void testFilterScalarCompareColumn() throws HiveException {
ExprNodeGenericFuncDesc scalarGreaterColExpr = new ExprNodeGenericFuncDesc();
GenericUDFOPGreaterThan gudf = new GenericUDFOPGreaterThan();
scalarGreaterColExpr.setGenericUDF(gudf);
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>(2);
ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(TypeInfoFactory.longTypeInfo, 20);
ExprNodeColumnDesc colDesc = new ExprNodeColumnDesc(Long.class, "a", "table", false);
children.add(constDesc);
children.add(colDesc);
scalarGreaterColExpr.setChildren(children);
List<String> columns = new ArrayList<String>();
columns.add("a");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(scalarGreaterColExpr, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(FilterLongScalarGreaterLongColumn.class, ve.getClass());
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan in project hive by apache.
the class TestVectorizationContext method testVectorizeFilterMultiAndOrExpression.
@Test
public void testVectorizeFilterMultiAndOrExpression() throws HiveException {
ExprNodeColumnDesc col1Expr = new ExprNodeColumnDesc(Integer.class, "col1", "table", false);
ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(new Integer(10));
GenericUDFOPGreaterThan udf = new GenericUDFOPGreaterThan();
ExprNodeGenericFuncDesc greaterExprDesc = new ExprNodeGenericFuncDesc();
greaterExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
greaterExprDesc.setGenericUDF(udf);
List<ExprNodeDesc> children1 = new ArrayList<ExprNodeDesc>(2);
children1.add(col1Expr);
children1.add(constDesc);
greaterExprDesc.setChildren(children1);
ExprNodeColumnDesc col2Expr = new ExprNodeColumnDesc(Float.class, "col2", "table", false);
ExprNodeConstantDesc const2Desc = new ExprNodeConstantDesc(new Float(1.0));
GenericUDFOPLessThan udf2 = new GenericUDFOPLessThan();
ExprNodeGenericFuncDesc lessExprDesc = new ExprNodeGenericFuncDesc();
lessExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
lessExprDesc.setGenericUDF(udf2);
List<ExprNodeDesc> children2 = new ArrayList<ExprNodeDesc>(2);
children2.add(col2Expr);
children2.add(const2Desc);
lessExprDesc.setChildren(children2);
ExprNodeColumnDesc col3Expr = new ExprNodeColumnDesc(Integer.class, "col3", "table", false);
ExprNodeConstantDesc const3Desc = new ExprNodeConstantDesc(new Integer(10));
GenericUDFOPGreaterThan udf3 = new GenericUDFOPGreaterThan();
ExprNodeGenericFuncDesc greaterExprDesc3 = new ExprNodeGenericFuncDesc();
greaterExprDesc3.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
greaterExprDesc3.setGenericUDF(udf3);
List<ExprNodeDesc> children3 = new ArrayList<ExprNodeDesc>(2);
children3.add(col3Expr);
children3.add(const3Desc);
greaterExprDesc3.setChildren(children3);
GenericUDFOPAnd andUdf = new GenericUDFOPAnd();
ExprNodeGenericFuncDesc andExprDesc = new ExprNodeGenericFuncDesc();
andExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
andExprDesc.setGenericUDF(andUdf);
List<ExprNodeDesc> children4 = new ArrayList<ExprNodeDesc>(2);
children4.add(greaterExprDesc);
children4.add(lessExprDesc);
children4.add(greaterExprDesc3);
andExprDesc.setChildren(children4);
List<String> columns = new ArrayList<String>();
columns.add("col0");
columns.add("col1");
columns.add("col2");
columns.add("col3");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(andExprDesc, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(ve.getClass(), FilterExprAndExpr.class);
assertEquals(ve.getChildExpressions()[0].getClass(), FilterLongColGreaterLongScalar.class);
assertEquals(ve.getChildExpressions()[1].getClass(), FilterDoubleColLessDoubleScalar.class);
assertEquals(ve.getChildExpressions()[2].getClass(), FilterLongColGreaterLongScalar.class);
GenericUDFOPOr orUdf = new GenericUDFOPOr();
ExprNodeGenericFuncDesc orExprDesc = new ExprNodeGenericFuncDesc();
orExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
orExprDesc.setGenericUDF(orUdf);
List<ExprNodeDesc> children5 = new ArrayList<ExprNodeDesc>(2);
children5.add(greaterExprDesc);
children5.add(lessExprDesc);
children5.add(greaterExprDesc3);
orExprDesc.setChildren(children5);
VectorExpression veOr = vc.getVectorExpression(orExprDesc, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(veOr.getClass(), FilterExprOrExpr.class);
assertEquals(veOr.getChildExpressions()[0].getClass(), FilterLongColGreaterLongScalar.class);
assertEquals(veOr.getChildExpressions()[1].getClass(), FilterDoubleColLessDoubleScalar.class);
assertEquals(ve.getChildExpressions()[2].getClass(), FilterLongColGreaterLongScalar.class);
}
use of org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPGreaterThan in project hive by apache.
the class TestVectorizationContext method testVectorizeFilterAndOrExpression.
@Test
public void testVectorizeFilterAndOrExpression() throws HiveException {
ExprNodeColumnDesc col1Expr = new ExprNodeColumnDesc(Integer.class, "col1", "table", false);
ExprNodeConstantDesc constDesc = new ExprNodeConstantDesc(new Integer(10));
GenericUDFOPGreaterThan udf = new GenericUDFOPGreaterThan();
ExprNodeGenericFuncDesc greaterExprDesc = new ExprNodeGenericFuncDesc();
greaterExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
greaterExprDesc.setGenericUDF(udf);
List<ExprNodeDesc> children1 = new ArrayList<ExprNodeDesc>(2);
children1.add(col1Expr);
children1.add(constDesc);
greaterExprDesc.setChildren(children1);
ExprNodeColumnDesc col2Expr = new ExprNodeColumnDesc(Float.class, "col2", "table", false);
ExprNodeConstantDesc const2Desc = new ExprNodeConstantDesc(new Float(1.0));
GenericUDFOPLessThan udf2 = new GenericUDFOPLessThan();
ExprNodeGenericFuncDesc lessExprDesc = new ExprNodeGenericFuncDesc();
lessExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
lessExprDesc.setGenericUDF(udf2);
List<ExprNodeDesc> children2 = new ArrayList<ExprNodeDesc>(2);
children2.add(col2Expr);
children2.add(const2Desc);
lessExprDesc.setChildren(children2);
GenericUDFOPAnd andUdf = new GenericUDFOPAnd();
ExprNodeGenericFuncDesc andExprDesc = new ExprNodeGenericFuncDesc();
andExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
andExprDesc.setGenericUDF(andUdf);
List<ExprNodeDesc> children3 = new ArrayList<ExprNodeDesc>(2);
children3.add(greaterExprDesc);
children3.add(lessExprDesc);
andExprDesc.setChildren(children3);
List<String> columns = new ArrayList<String>();
columns.add("col0");
columns.add("col1");
columns.add("col2");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(andExprDesc, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(ve.getClass(), FilterExprAndExpr.class);
assertEquals(ve.getChildExpressions()[0].getClass(), FilterLongColGreaterLongScalar.class);
assertEquals(ve.getChildExpressions()[1].getClass(), FilterDoubleColLessDoubleScalar.class);
GenericUDFOPOr orUdf = new GenericUDFOPOr();
ExprNodeGenericFuncDesc orExprDesc = new ExprNodeGenericFuncDesc();
orExprDesc.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
orExprDesc.setGenericUDF(orUdf);
List<ExprNodeDesc> children4 = new ArrayList<ExprNodeDesc>(2);
children4.add(greaterExprDesc);
children4.add(lessExprDesc);
orExprDesc.setChildren(children4);
VectorExpression veOr = vc.getVectorExpression(orExprDesc, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(veOr.getClass(), FilterExprOrExpr.class);
assertEquals(veOr.getChildExpressions()[0].getClass(), FilterLongColGreaterLongScalar.class);
assertEquals(veOr.getChildExpressions()[1].getClass(), FilterDoubleColLessDoubleScalar.class);
}
Aggregations