use of io.ordinate.engine.function.column.ColumnFunction in project Mycat2 by MyCATApache.
the class ProjectionPlan method execute.
@Override
public Observable<VectorSchemaRoot> execute(RootContext rootContext) {
FieldVector[] vectorList = new FieldVector[schema().getFields().size()];
return input.execute(rootContext).subscribeOn(Schedulers.computation()).map(input -> {
try {
int index = 0;
for (VectorExpression expr : exprs) {
int finalIndex = index;
if (expr.isColumn()) {
ExprVectorExpression exprVectorExpression = (ExprVectorExpression) expr;
ColumnFunction columnFunction = (ColumnFunction) exprVectorExpression.getFunction();
FieldVector vector = input.getVector(columnFunction.getColumnIndex());
vectorList[finalIndex] = vector;
} else {
ArrowType type = expr.getType();
vectorList[finalIndex] = FieldBuilder.of("", type, expr.isNullable()).toArrow().createVector(rootContext.getRootAllocator());
vectorList[finalIndex].setInitialCapacity(input.getRowCount());
vectorList[finalIndex].allocateNew();
VectorContext vContext1 = new VectorContext() {
@Override
public VectorSchemaRoot getVectorSchemaRoot() {
return input;
}
@Override
public FieldVector getOutputVector() {
return vectorList[finalIndex];
}
@Override
public int getRowCount() {
return input.getRowCount();
}
};
expr.eval(vContext1);
vectorList[index] = (vContext1.getOutputVector());
vContext1.free();
}
index++;
}
VectorSchemaRoot res = VectorSchemaRoot.of(vectorList);
res.setRowCount(input.getRowCount());
return res;
} finally {
ProjectionPlan.this.input.eachFree(input);
}
});
}
Aggregations