use of org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression in project hive by apache.
the class VectorSMBMapJoinOperator method process.
@Override
public void process(Object row, int tag) throws HiveException {
byte alias = (byte) tag;
if (alias != this.posBigTable) {
super.process(row, tag);
} else {
VectorizedRowBatch inBatch = (VectorizedRowBatch) row;
if (null != bigTableFilterExpressions) {
for (VectorExpression ve : bigTableFilterExpressions) {
ve.evaluate(inBatch);
}
}
if (null != bigTableValueExpressions) {
for (VectorExpression ve : bigTableValueExpressions) {
ve.evaluate(inBatch);
}
}
for (VectorExpression ve : keyExpressions) {
ve.evaluate(inBatch);
}
keyWrapperBatch.evaluateBatch(inBatch);
keyValues = keyWrapperBatch.getVectorHashKeyWrappers();
//
for (batchIndex = 0; batchIndex < inBatch.size; ++batchIndex) {
super.process(row, tag);
}
// Set these two to invalid values so any attempt to use them
// outside the inner loop results in NPE/OutOfBounds errors
batchIndex = -1;
keyValues = null;
}
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression in project hive by apache.
the class TestVectorizationContext method testTimeStampUdfs.
@Test
public void testTimeStampUdfs() throws HiveException {
ExprNodeGenericFuncDesc tsFuncExpr = new ExprNodeGenericFuncDesc();
tsFuncExpr.setTypeInfo(TypeInfoFactory.intTypeInfo);
ExprNodeColumnDesc colDesc1 = new ExprNodeColumnDesc(TypeInfoFactory.timestampTypeInfo, "a", "table", false);
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>();
children.add(colDesc1);
List<String> columns = new ArrayList<String>();
columns.add("b");
columns.add("a");
VectorizationContext vc = new VectorizationContext("name", columns);
// UDFYear
GenericUDFBridge gudfBridge = new GenericUDFBridge("year", false, UDFYear.class.getName());
tsFuncExpr.setGenericUDF(gudfBridge);
tsFuncExpr.setChildren(children);
VectorExpression ve = vc.getVectorExpression(tsFuncExpr);
Assert.assertEquals(VectorUDFYearTimestamp.class, ve.getClass());
// GenericUDFToUnixTimeStamp
GenericUDFToUnixTimeStamp gudf = new GenericUDFToUnixTimeStamp();
tsFuncExpr.setGenericUDF(gudf);
tsFuncExpr.setTypeInfo(TypeInfoFactory.longTypeInfo);
ve = vc.getVectorExpression(tsFuncExpr);
Assert.assertEquals(VectorUDFUnixTimeStampTimestamp.class, ve.getClass());
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression in project hive by apache.
the class TestVectorizationContext method testUnaryStringExpressions.
@Test
public void testUnaryStringExpressions() throws HiveException {
ExprNodeGenericFuncDesc stringUnary = new ExprNodeGenericFuncDesc();
stringUnary.setTypeInfo(TypeInfoFactory.stringTypeInfo);
ExprNodeColumnDesc colDesc = new ExprNodeColumnDesc(String.class, "a", "table", false);
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>();
children.add(colDesc);
stringUnary.setChildren(children);
List<String> columns = new ArrayList<String>();
columns.add("b");
columns.add("a");
VectorizationContext vc = new VectorizationContext("name", columns);
GenericUDF stringLower = new GenericUDFLower();
stringUnary.setGenericUDF(stringLower);
VectorExpression ve = vc.getVectorExpression(stringUnary);
assertEquals(StringLower.class, ve.getClass());
assertEquals(2, ((StringLower) ve).getOutputColumnNum());
vc = new VectorizationContext("name", columns);
ExprNodeGenericFuncDesc anotherUnary = new ExprNodeGenericFuncDesc();
anotherUnary.setTypeInfo(TypeInfoFactory.stringTypeInfo);
List<ExprNodeDesc> children2 = new ArrayList<ExprNodeDesc>();
children2.add(stringUnary);
anotherUnary.setChildren(children2);
GenericUDFBridge udfbridge = new GenericUDFBridge("ltrim", false, GenericUDFLTrim.class.getName());
anotherUnary.setGenericUDF(udfbridge);
ve = vc.getVectorExpression(anotherUnary);
VectorExpression childVe = ve.getChildExpressions()[0];
assertEquals(StringLower.class, childVe.getClass());
assertEquals(2, ((StringLower) childVe).getOutputColumnNum());
assertEquals(StringLTrim.class, ve.getClass());
assertEquals(3, ((StringLTrim) ve).getOutputColumnNum());
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression in project hive by apache.
the class TestVectorizationContext method testNullExpressions.
@Test
public void testNullExpressions() 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 isNullExpr = new ExprNodeGenericFuncDesc();
isNullExpr.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
GenericUDFOPNull isNullUdf = new GenericUDFOPNull();
isNullExpr.setGenericUDF(isNullUdf);
List<ExprNodeDesc> childOfIsNull = new ArrayList<ExprNodeDesc>();
childOfIsNull.add(greaterExprDesc);
isNullExpr.setChildren(childOfIsNull);
List<String> columns = new ArrayList<String>();
columns.add("col1");
columns.add("col2");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(isNullExpr, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(ve.getClass(), SelectColumnIsNull.class);
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
assertEquals(2, ve.getChildExpressions()[0].getOutputColumnNum());
ve = vc.getVectorExpression(isNullExpr, VectorExpressionDescriptor.Mode.PROJECTION);
assertEquals(ve.getClass(), IsNull.class);
assertEquals(3, ve.getOutputColumnNum());
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
}
use of org.apache.hadoop.hive.ql.exec.vector.expressions.VectorExpression in project hive by apache.
the class TestVectorizationContext method testNotNullExpressions.
@Test
public void testNotNullExpressions() 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 isNotNullExpr = new ExprNodeGenericFuncDesc();
isNotNullExpr.setTypeInfo(TypeInfoFactory.booleanTypeInfo);
GenericUDFOPNotNull notNullUdf = new GenericUDFOPNotNull();
isNotNullExpr.setGenericUDF(notNullUdf);
List<ExprNodeDesc> childOfNot = new ArrayList<ExprNodeDesc>();
childOfNot.add(greaterExprDesc);
isNotNullExpr.setChildren(childOfNot);
List<String> columns = new ArrayList<String>();
columns.add("col1");
columns.add("col2");
VectorizationContext vc = new VectorizationContext("name", columns);
VectorExpression ve = vc.getVectorExpression(isNotNullExpr, VectorExpressionDescriptor.Mode.FILTER);
assertEquals(ve.getClass(), SelectColumnIsNotNull.class);
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
ve = vc.getVectorExpression(isNotNullExpr, VectorExpressionDescriptor.Mode.PROJECTION);
assertEquals(ve.getClass(), IsNotNull.class);
assertEquals(ve.getChildExpressions()[0].getClass(), LongColGreaterLongScalar.class);
}
Aggregations