use of org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator in project hive by apache.
the class VectorSelectOperatorBench method setup.
@Setup
public void setup(Blackhole bh) throws HiveException {
HiveConf hconf = new HiveConf();
List<String> columns = new ArrayList<String>();
columns.add("a");
columns.add("b");
columns.add("c");
VectorizationContext vc = new VectorizationContext("name", columns);
selDesc = new SelectDesc(false);
List<ExprNodeDesc> colList = new ArrayList<ExprNodeDesc>();
ExprNodeColumnDesc colDesc1 = new ExprNodeColumnDesc(Long.class, "a", "table", false);
ExprNodeColumnDesc colDesc2 = new ExprNodeColumnDesc(Long.class, "b", "table", false);
ExprNodeColumnDesc colDesc3 = new ExprNodeColumnDesc(Long.class, "c", "table", false);
ExprNodeGenericFuncDesc plusDesc = new ExprNodeGenericFuncDesc();
GenericUDF gudf = new GenericUDFOPPlus();
plusDesc.setGenericUDF(gudf);
List<ExprNodeDesc> children = new ArrayList<ExprNodeDesc>();
children.add(colDesc1);
children.add(colDesc2);
plusDesc.setChildren(children);
plusDesc.setTypeInfo(TypeInfoFactory.longTypeInfo);
colList.add(plusDesc);
colList.add(colDesc3);
selDesc.setColList(colList);
List<String> outputColNames = new ArrayList<String>();
outputColNames.add("_col0");
outputColNames.add("_col1");
selDesc.setOutputColumnNames(outputColNames);
VectorSelectDesc vectorSelectDesc = new VectorSelectDesc();
selDesc.setVectorDesc(vectorSelectDesc);
List<ExprNodeDesc> selectColList = selDesc.getColList();
VectorExpression[] vectorSelectExprs = new VectorExpression[selectColList.size()];
for (int i = 0; i < selectColList.size(); i++) {
ExprNodeDesc expr = selectColList.get(i);
VectorExpression ve = vc.getVectorExpression(expr);
vectorSelectExprs[i] = ve;
}
vectorSelectDesc.setSelectExpressions(vectorSelectExprs);
vectorSelectDesc.setProjectedOutputColumns(new int[] { 3, 2 });
CompilationOpContext opContext = new CompilationOpContext();
vso = new VectorSelectOperator(opContext, selDesc, vc, vectorSelectDesc);
// to trigger vectorForward
child = new ArrayList<>();
child.add(new BlackholeOperator(opContext, bh));
child.add(new BlackholeOperator(opContext, bh));
vso.initialize(hconf, null);
vrg = VectorizedRowGroupGenUtil.getVectorizedRowBatch(VectorizedRowBatch.DEFAULT_SIZE, 4, 17);
}
use of org.apache.hadoop.hive.ql.exec.vector.VectorSelectOperator in project hive by apache.
the class TestOperators method testSetDoneFromChildOperators.
@SuppressWarnings("unchecked")
@Test
public void testSetDoneFromChildOperators() throws HiveException {
VectorSelectDesc vectorSelectDesc = new VectorSelectDesc();
vectorSelectDesc.setProjectedOutputColumns(new int[0]);
vectorSelectDesc.setSelectExpressions(new VectorExpression[0]);
VectorSelectOperator selOp = new VectorSelectOperator(new CompilationOpContext(), new SelectDesc(), new VectorizationContext("dummy"), vectorSelectDesc);
VectorSelectOperator childOp = new VectorSelectOperator(new CompilationOpContext(), new SelectDesc(), new VectorizationContext("dummy"), vectorSelectDesc);
selOp.childOperatorsArray = new Operator[1];
selOp.childOperatorsArray[0] = childOp;
selOp.childOperatorsTag = new int[1];
selOp.childOperatorsTag[0] = 0;
childOp.childOperatorsArray = new Operator[0];
Assert.assertFalse(selOp.getDone());
Assert.assertFalse(childOp.getDone());
selOp.process(new VectorizedRowBatch(1), 0);
childOp.setDone(true);
// selOp is not done, it will detect child's done=true during the next process(batch) call
Assert.assertFalse(selOp.getDone());
Assert.assertTrue(childOp.getDone());
selOp.process(new VectorizedRowBatch(1), 0);
// selOp detects child's done=true, so it turns to done=true
Assert.assertTrue(selOp.getDone());
Assert.assertTrue(childOp.getDone());
}
Aggregations