@Override public Void visitJoin(Join join, List<Void> inputStreams) { beginJoinStage(join); pw.println(" if (source == left) {"); pw.println(" leftRows.add(_data);"); pw.println(" } else if (source == right) {"); pw.println(" rightRows.add(_data);"); pw.println(" }"); endStage(); return null; }
@Override public Void visitAggregate(Aggregate aggregate, List<Void> inputStreams) throws Exception { beginAggregateStage(aggregate); pw.println(" if (_data != null) {"); pw.println(" List<Object> curGroupValues = getGroupValues(_data);"); pw.println(" if (!correlatedGroupedValues.containsKey(curGroupValues)) {"); pw.println(" correlatedGroupedValues.put(curGroupValues, new ArrayList<CorrelatedValues>());"); pw.println(" }"); pw.println(" correlatedGroupedValues.get(curGroupValues).add(_data);"); pw.println(" if (!state.containsKey(curGroupValues)) {"); pw.println(" state.put(curGroupValues, new HashMap<String, Object>());"); pw.println(" }"); pw.println(" Map<String, Object> accumulators = state.get(curGroupValues);"); for (AggregateCall call : aggregate.getAggCallList()) { aggregate(call); } pw.println(" }"); endStage(); return null; }
@Override public Void visitProject(Project project, List<Void> inputStreams) throws Exception { beginStage(project); List<RexNode> childExps = project.getChildExps(); RelDataType inputRowType = project.getInput(0).getRowType(); int outputCount = project.getRowType().getFieldCount(); pw.print("Context context = new StreamlineContext(Processor.dataContext);\n"); pw.print("context.values = _data.toArray();\n"); pw.print(String.format("Object[] outputValues = new Object[%d];\n", outputCount)); pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString()); pw.print(" ctx.emit(new CorrelatedValues(_data.getCorrelated(), outputValues));\n"); endStage(); return null; }
@Override public Void visitFilter(Filter filter, List<Void> inputStreams) throws Exception { beginStage(filter); List<RexNode> childExps = filter.getChildExps(); RelDataType inputRowType = filter.getInput(0).getRowType(); pw.print("Context context = new StreamlineContext(Processor.dataContext);\n"); pw.print("context.values = _data.toArray();\n"); pw.print("Object[] outputValues = new Object[1];\n"); pw.write(rexCompiler.compileToBlock(childExps, inputRowType).toString()); String r = "((Boolean) outputValues[0])"; if (filter.getCondition().getType().isNullable()) { pw.print(String.format(" if (%s != null && %s) { ctx.emit(_data); }\n", r, r)); } else { pw.print(String.format(" if (%s) { ctx.emit(_data); }\n", r, r)); } endStage(); return null; }