@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { int keys[] = JobGenHelper.variablesToFieldIndexes(columnList, inputSchemas[0]); GroupByOperator gby = (GroupByOperator) op; int fdColumns[] = getFdColumns(gby, inputSchemas[0]); // compile subplans and set the gby op. schema accordingly AlgebricksPipeline[] subplans = compileSubplans(inputSchemas[0], gby, opSchema, context); AbstractAggregatorDescriptorFactory aggregatorFactory; List<ILogicalPlan> nestedPlans = gby.getNestedPlans(); if (!nestedPlans.isEmpty() && nestedPlans.get(0).getRoots().get(0).getValue() .getOperatorTag() == LogicalOperatorTag.RUNNINGAGGREGATE) { aggregatorFactory = new NestedPlansRunningAggregatorFactory(subplans, keys, fdColumns); } else { aggregatorFactory = new NestedPlansAccumulatingAggregatorFactory(subplans, keys, fdColumns); } aggregatorFactory.setSourceLocation(gby.getSourceLocation()); IOperatorDescriptorRegistry spec = builder.getJobSpec(); IBinaryComparatorFactory[] comparatorFactories = JobGenHelper .variablesToAscBinaryComparatorFactories(columnList, context.getTypeEnvironment(op), context); RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); PreclusteredGroupOperatorDescriptor opDesc = new PreclusteredGroupOperatorDescriptor(spec, keys, comparatorFactories, aggregatorFactory, recordDescriptor, groupAll, framesLimit); opDesc.setSourceLocation(gby.getSourceLocation()); contributeOpDesc(builder, gby, opDesc); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { int keys[] = JobGenHelper.variablesToFieldIndexes(columnList, inputSchemas[0]); GroupByOperator gby = (GroupByOperator) op; IVariableTypeEnvironment env = context.getTypeEnvironment(op); int fdColumns[] = getFdColumns(gby, inputSchemas[0]); // compile subplans and set the gby op. schema accordingly AlgebricksPipeline[] subplans = compileSubplans(inputSchemas[0], gby, opSchema, context); IAggregatorDescriptorFactory aggregatorFactory = new NestedPlansAccumulatingAggregatorFactory(subplans, keys, fdColumns); IBinaryComparatorFactory[] comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories(columnList, env, context); RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); RecordDescriptor inputRecordDesc = JobGenHelper.mkRecordDescriptor( context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context); MicroPreClusteredGroupRuntimeFactory runtime = new MicroPreClusteredGroupRuntimeFactory(keys, comparatorFactories, aggregatorFactory, inputRecordDesc, recordDescriptor, null); runtime.setSourceLocation(gby.getSourceLocation()); builder.contributeMicroOperator(gby, runtime, recordDescriptor); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { IOperatorDescriptorRegistry spec = builder.getJobSpec(); int[] keysAndDecs = getKeysAndDecs(inputSchemas[0]); IBinaryComparatorFactory[] comparatorFactories = JobGenHelper .variablesToAscBinaryComparatorFactories(columnList, context.getTypeEnvironment(op), context); IAggregateEvaluatorFactory[] aggFactories = new IAggregateEvaluatorFactory[] {}; AbstractAggregatorDescriptorFactory aggregatorFactory = new SimpleAlgebricksAccumulatingAggregatorFactory(aggFactories, keysAndDecs); aggregatorFactory.setSourceLocation(op.getSourceLocation()); RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); /* make fd columns part of the key but the comparator only compares the distinct key columns */ PreclusteredGroupOperatorDescriptor opDesc = new PreclusteredGroupOperatorDescriptor(spec, keysAndDecs, comparatorFactories, aggregatorFactory, recordDescriptor); opDesc.setSourceLocation(op.getSourceLocation()); contributeOpDesc(builder, (AbstractLogicalOperator) op, opDesc); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); } }
@Override public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException { int[] keysAndDecs = getKeysAndDecs(inputSchemas[0]); IBinaryComparatorFactory[] comparatorFactories = JobGenHelper .variablesToAscBinaryComparatorFactories(columnList, context.getTypeEnvironment(op), context); IAggregateEvaluatorFactory[] aggFactories = new IAggregateEvaluatorFactory[] {}; AbstractAggregatorDescriptorFactory aggregatorFactory = new SimpleAlgebricksAccumulatingAggregatorFactory(aggFactories, keysAndDecs); aggregatorFactory.setSourceLocation(op.getSourceLocation()); RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context); RecordDescriptor inputRecordDesc = JobGenHelper.mkRecordDescriptor( context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas[0], context); /* make fd columns part of the key but the comparator only compares the distinct key columns */ MicroPreClusteredGroupRuntimeFactory runtime = new MicroPreClusteredGroupRuntimeFactory(keysAndDecs, comparatorFactories, aggregatorFactory, inputRecordDesc, recordDescriptor, null); runtime.setSourceLocation(op.getSourceLocation()); builder.contributeMicroOperator(op, runtime, recordDescriptor); ILogicalOperator src = op.getInputs().get(0).getValue(); builder.contributeGraphEdge(src, 0, op, 0); } }
JobGenHelper.variablesToAscBinaryComparatorFactories(gbyCols, aggOpInputEnv, context); RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
int[][] compareFields = new int[nInput][]; IBinaryComparatorFactory[] comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories( logicalOp.getCompareVariables(0), context.getTypeEnvironment(op), context);
JobGenHelper.variablesToAscBinaryComparatorFactories(partitionColumns, opTypeEnv, context);