final List<TransferPair> transfers = Lists.newArrayList();
final ClassGenerator<Filterer> cg = CodeGenerator.getRoot(Filterer.TEMPLATE_DEFINITION4, context.getFunctionRegistry());
final LogicalExpression expr = ExpressionTreeMaterializer.materialize(popConfig.getExpr(), incoming, collector, context.getFunctionRegistry());
if(collector.hasErrors()){
throw new SchemaChangeException(String.format("Failure while trying to materialize incoming schema. Errors:\n %s.", collector.toErrorString()));
}
cg.addExpr(new ReturnValueExpression(expr));
// for(VectorWrapper<?> i : incoming){
// ValueVector v = TypeHelper.getNewVector(i.getField(), context.getAllocator());
// container.add(v);
// allocators.add(getAllocator4(v));
// }
for (VectorWrapper<?> vw : incoming) {
for (ValueVector vv : vw.getValueVectors()) {
TransferPair pair = vv.getTransferPair();
container.add(pair.getTo());
transfers.add(pair);
}
}
// allocate outgoing sv4
container.buildSchema(SelectionVectorMode.FOUR_BYTE);
try {
TransferPair[] tx = transfers.toArray(new TransferPair[transfers.size()]);
Filterer filter = context.getImplementationClass(cg);
filter.setup(context, incoming, this, tx);
return filter;
} catch (ClassTransformationException | IOException e) {
throw new SchemaChangeException("Failure while attempting to load generated class", e);
}
}