DynamicClassLoader classLoader,
TimeZoneKey timeZoneKey)
{
BootstrapEntry bootstrap = BootstrapEntry.makeBootstrap(classLoader, metadata);
ClassDefinition classDefinition = new ClassDefinition(new CompilerContext(bootstrap.getBootstrapMethod()),
a(PUBLIC, FINAL),
typeFromPathName("ScanFilterAndProjectOperator_" + CLASS_ID.incrementAndGet()),
type(AbstractScanFilterAndProjectOperator.class));
// declare fields
FieldDefinition sessionField = classDefinition.declareField(a(PRIVATE, FINAL), "session", ConnectorSession.class);
// constructor
classDefinition.declareConstructor(new CompilerContext(bootstrap.getBootstrapMethod()),
a(PUBLIC),
arg("operatorContext", OperatorContext.class),
arg("sourceId", PlanNodeId.class),
arg("dataStreamProvider", DataStreamProvider.class),
arg("columns", type(Iterable.class, ColumnHandle.class)),
arg("types", type(Iterable.class, Type.class)))
.getBody()
.comment("super(operatorContext, sourceId, dataStreamProvider, columns, types);")
.pushThis()
.getVariable("operatorContext")
.getVariable("sourceId")
.getVariable("dataStreamProvider")
.getVariable("columns")
.getVariable("types")
.invokeConstructor(AbstractScanFilterAndProjectOperator.class, OperatorContext.class, PlanNodeId.class, DataStreamProvider.class, Iterable.class, Iterable.class)
.comment("this.session = operatorContext.getSession();")
.pushThis()
.getVariable("operatorContext")
.invokeVirtual(OperatorContext.class, "getSession", ConnectorSession.class)
.putField(sessionField)
.ret();
generateFilterAndProjectRowOriented(bootstrap, classDefinition, filter, projections, expressionTypes);
generateFilterAndProjectCursorMethod(bootstrap, classDefinition, projections);
//
// filter method
//
generateFilterMethod(bootstrap, classDefinition, filter, expressionTypes, true, timeZoneKey);
generateFilterMethod(bootstrap, classDefinition, filter, expressionTypes, false, timeZoneKey);
//
// project methods
//
List<Type> types = new ArrayList<>();
int projectionIndex = 0;
for (Expression projection : projections) {
generateProjectMethod(bootstrap, classDefinition, "project_" + projectionIndex, projection, expressionTypes, true, timeZoneKey);
generateProjectMethod(bootstrap, classDefinition, "project_" + projectionIndex, projection, expressionTypes, false, timeZoneKey);
types.add(expressionTypes.get(projection));
projectionIndex++;
}
//
// toString method
//
classDefinition.declareMethod(new CompilerContext(bootstrap.getBootstrapMethod()), a(PUBLIC), "toString", type(String.class))
.getBody()
.push(toStringHelper(classDefinition.getType().getJavaClassName())
.add("filter", filter)
.add("projections", projections)
.toString())
.retObject();