private void generateMethods(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, RowExpression filter, int leftBlocksSize) { CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder); FieldDefinition sessionField = classDefinition.declareField(a(PRIVATE, FINAL), "session", ConnectorSession.class); Map<LambdaDefinitionExpression, CompiledLambda> compiledLambdaMap = generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, leftBlocksSize, filter); generateFilterMethod(classDefinition, callSiteBinder, cachedInstanceBinder, compiledLambdaMap, filter, leftBlocksSize, sessionField); generateConstructor(classDefinition, sessionField, cachedInstanceBinder); }
@Override public void generateMethods(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, RowExpression filter, List<RowExpression> projections) { CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder); generateProcessMethod(classDefinition, projections.size()); Map<LambdaDefinitionExpression, CompiledLambda> filterCompiledLambdaMap = generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, filter, "filter"); generateFilterMethod(classDefinition, callSiteBinder, cachedInstanceBinder, filterCompiledLambdaMap, filter); for (int i = 0; i < projections.size(); i++) { String methodName = "project_" + i; Map<LambdaDefinitionExpression, CompiledLambda> projectCompiledLambdaMap = generateMethodsForLambda(classDefinition, callSiteBinder, cachedInstanceBinder, projections.get(i), methodName); generateProjectMethod(classDefinition, callSiteBinder, cachedInstanceBinder, projectCompiledLambdaMap, methodName, projections.get(i)); } MethodDefinition constructorDefinition = classDefinition.declareConstructor(a(PUBLIC)); BytecodeBlock constructorBody = constructorDefinition.getBody(); Variable thisVariable = constructorDefinition.getThis(); constructorBody.comment("super();") .append(thisVariable) .invokeConstructor(Object.class); cachedInstanceBinder.generateInitializations(thisVariable, constructorBody); constructorBody.ret(); }
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(definition, binder);
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(definition, binder); ArrayMapBytecodeExpression newArray = ArrayGeneratorUtils.map(scope, cachedInstanceBinder, fromElementType, toElementType, value, elementCastSignature.getName(), elementCast);
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(lambdaProviderClassDefinition, callSiteBinder);
body.append(wasNull.set(constantFalse())); CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(definition, binder);
type(PageFilter.class)); CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder);
FieldDefinition resultField = classDefinition.declareField(a(PRIVATE), "result", Block.class); CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder);
private Filter compileRowExpression(RowExpression filter) { ParameterizedType className = CompilerUtils.makeClassName(Filter.class.getSimpleName()); ParameterizedType[] interfaces = {ParameterizedType.type(Filter.class)}; ParameterizedType type = ParameterizedType.type(Object.class); EnumSet<Access> accessList = a(new Access[]{PUBLIC, FINAL}); ClassDefinition classDefinition = new ClassDefinition(accessList, className, type, interfaces); classDefinition.declareDefaultConstructor(a(PUBLIC)); CallSiteBinder callSiteBinder = new CallSiteBinder(); CursorProcessorCompiler cursorProcessorCompiler = new CursorProcessorCompiler(metadata); Method method; try { method = cursorProcessorCompiler.getClass().getDeclaredMethod("generateFilterMethod", ClassDefinition.class, CallSiteBinder.class, CachedInstanceBinder.class, RowExpression.class); method.setAccessible(true); } catch (NoSuchMethodException e) { throw Throwables.propagate(e); } try { method.invoke(cursorProcessorCompiler, classDefinition, callSiteBinder, new CachedInstanceBinder(classDefinition, callSiteBinder), filter); } catch (IllegalAccessException | InvocationTargetException e) { throw Throwables.propagate(e); } Class<? extends Filter> aClass = defineClass(classDefinition, Filter.class, callSiteBinder.getBindings(), getClass().getClassLoader()); try { return aClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new RuntimeException("Couldn't compile expression", e); } }
@Override public void generateMethods(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, RowExpression filter, List<RowExpression> projections) { CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder); ImmutableList.Builder<MethodDefinition> projectMethods = ImmutableList.builder(); ImmutableList.Builder<MethodDefinition> projectColumnarMethods = ImmutableList.builder(); ImmutableList.Builder<MethodDefinition> projectDictionaryMethods = ImmutableList.builder(); for (int i = 0; i < projections.size(); i++) { MethodDefinition project = generateProjectMethod(classDefinition, callSiteBinder, cachedInstanceBinder, "project_" + i, projections.get(i)); MethodDefinition projectColumnar = generateProjectColumnarMethod(classDefinition, callSiteBinder, "projectColumnar_" + i, projections.get(i), project); MethodDefinition projectRLE = generateProjectRLEMethod(classDefinition, "projectRLE_" + i, projections.get(i), project, projectColumnar); MethodDefinition projectDictionary = generateProjectDictionaryMethod(classDefinition, "projectDictionary_" + i, projections.get(i), project, projectColumnar, projectRLE); projectMethods.add(project); projectColumnarMethods.add(projectColumnar); projectDictionaryMethods.add(projectDictionary); } List<MethodDefinition> projectMethodDefinitions = projectMethods.build(); List<MethodDefinition> projectColumnarMethodDefinitions = projectColumnarMethods.build(); List<MethodDefinition> projectDictionaryMethodDefinitions = projectDictionaryMethods.build(); generateProcessMethod(classDefinition, filter, projections, projectMethodDefinitions); generateGetNonLazyPageMethod(classDefinition, filter, projections); generateProcessColumnarMethod(classDefinition, projections, projectColumnarMethodDefinitions); generateProcessColumnarDictionaryMethod(classDefinition, projections, projectDictionaryMethodDefinitions); generateFilterPageMethod(classDefinition, filter); generateFilterMethod(classDefinition, callSiteBinder, cachedInstanceBinder, filter); generateConstructor(classDefinition, cachedInstanceBinder, projections.size()); }
@Override public void generateMethods(ClassDefinition classDefinition, CallSiteBinder callSiteBinder, RowExpression filter, List<RowExpression> projections) { CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(classDefinition, callSiteBinder); generateProcessMethod(classDefinition, projections.size()); generateFilterMethod(classDefinition, callSiteBinder, cachedInstanceBinder, filter); for (int i = 0; i < projections.size(); i++) { generateProjectMethod(classDefinition, callSiteBinder, cachedInstanceBinder, "project_" + i, projections.get(i)); } MethodDefinition constructorDefinition = classDefinition.declareConstructor(a(PUBLIC)); BytecodeBlock constructorBody = constructorDefinition.getBody(); Variable thisVariable = constructorDefinition.getThis(); constructorBody.comment("super();") .append(thisVariable) .invokeConstructor(Object.class); cachedInstanceBinder.generateInitializations(thisVariable, constructorBody); constructorBody.ret(); }
CachedInstanceBinder cachedInstanceBinder = new CachedInstanceBinder(definition, binder); ArrayMapBytecodeExpression newArray = ArrayGeneratorUtils.map(scope, cachedInstanceBinder, fromElementType, toElementType, value, elementCastSignature.getName(), elementCast);