use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method deepCopyPlan.
private ILogicalPlan deepCopyPlan(ILogicalPlan plan, ILogicalOperator arg) throws AlgebricksException {
List<Mutable<ILogicalOperator>> rootsCopy = deepCopyOperatorReferenceList(plan.getRoots(), arg);
ILogicalPlan planCopy = new ALogicalPlanImpl(rootsCopy);
return planCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan in project asterixdb by apache.
the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitGroupByOperator.
@Override
public ILogicalOperator visitGroupByOperator(GroupByOperator op, ILogicalOperator arg) throws AlgebricksException {
List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> groupByListCopy = deepCopyVariableExpressionReferencePairList(op.getGroupByList());
List<Pair<LogicalVariable, Mutable<ILogicalExpression>>> decorListCopy = deepCopyVariableExpressionReferencePairList(op.getDecorList());
List<ILogicalPlan> nestedPlansCopy = new ArrayList<ILogicalPlan>();
GroupByOperator opCopy = new GroupByOperator(groupByListCopy, decorListCopy, nestedPlansCopy, op.isGroupAll());
deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
deepCopyPlanList(op.getNestedPlans(), nestedPlansCopy, opCopy);
return opCopy;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan in project asterixdb by apache.
the class GroupByOperator method computeOutputTypeEnvironment.
@Override
public IVariableTypeEnvironment computeOutputTypeEnvironment(ITypingContext ctx) throws AlgebricksException {
int n = 0;
for (ILogicalPlan p : nestedPlans) {
n += p.getRoots().size();
}
ITypeEnvPointer[] envPointers = new ITypeEnvPointer[n];
int i = 0;
for (ILogicalPlan p : nestedPlans) {
for (Mutable<ILogicalOperator> r : p.getRoots()) {
envPointers[i] = new OpRefTypeEnvPointer(r, ctx);
i++;
}
}
IVariableTypeEnvironment env = new PropagatingTypeEnvironment(ctx.getExpressionTypeComputer(), ctx.getMissableTypeComputer(), ctx.getMetadataProvider(), TypePropagationPolicy.ALL, envPointers);
ILogicalOperator child = inputs.get(0).getValue();
IVariableTypeEnvironment env2 = ctx.getOutputTypeEnvironment(child);
for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getGroupByList()) {
ILogicalExpression expr = p.second.getValue();
if (p.first != null) {
env.setVarType(p.first, env2.getType(expr));
if (expr.getExpressionTag() == LogicalExpressionTag.VARIABLE) {
LogicalVariable v1 = ((VariableReferenceExpression) expr).getVariableReference();
env.setVarType(v1, env2.getVarType(v1));
}
} else {
VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
LogicalVariable v2 = vre.getVariableReference();
env.setVarType(v2, env2.getVarType(v2));
}
}
for (Pair<LogicalVariable, Mutable<ILogicalExpression>> p : getDecorList()) {
ILogicalExpression expr = p.second.getValue();
if (p.first != null) {
env.setVarType(p.first, env2.getType(expr));
} else {
VariableReferenceExpression vre = (VariableReferenceExpression) p.second.getValue();
LogicalVariable v2 = vre.getVariableReference();
env.setVarType(v2, env2.getVarType(v2));
}
}
return env;
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan in project asterixdb by apache.
the class SubplanOperator method setRootOp.
public void setRootOp(Mutable<ILogicalOperator> opRef) {
ILogicalPlan p = new ALogicalPlanImpl(opRef);
nestedPlans.add(p);
}
use of org.apache.hyracks.algebricks.core.algebra.base.ILogicalPlan in project asterixdb by apache.
the class HeuristicCompilerFactoryBuilder method create.
@Override
public ICompilerFactory create() {
return new ICompilerFactory() {
@Override
public ICompiler createCompiler(final ILogicalPlan plan, final IMetadataProvider<?, ?> metadata, int varCounter) {
final IOptimizationContext oc = optCtxFactory.createOptimizationContext(varCounter, expressionEvalSizeComputer, mergeAggregationExpressionFactory, expressionTypeComputer, missableTypeComputer, conflictingTypeResolver, physicalOptimizationConfig, clusterLocations);
oc.setMetadataDeclarations(metadata);
final HeuristicOptimizer opt = new HeuristicOptimizer(plan, logicalRewrites, physicalRewrites, oc);
return new ICompiler() {
@Override
public void optimize() throws AlgebricksException {
opt.optimize();
}
@Override
public JobSpecification createJob(Object appContext, IJobletEventListenerFactory jobEventListenerFactory) throws AlgebricksException {
AlgebricksConfig.ALGEBRICKS_LOGGER.fine("Starting Job Generation.\n");
JobGenContext context = new JobGenContext(null, metadata, appContext, serializerDeserializerProvider, hashFunctionFactoryProvider, hashFunctionFamilyProvider, comparatorFactoryProvider, typeTraitProvider, binaryBooleanInspectorFactory, binaryIntegerInspectorFactory, printerProvider, missingWriterFactory, normalizedKeyComputerFactoryProvider, expressionRuntimeProvider, expressionTypeComputer, oc, expressionEvalSizeComputer, partialAggregationTypeComputer, predEvaluatorFactoryProvider, physicalOptimizationConfig.getFrameSize(), clusterLocations);
PlanCompiler pc = new PlanCompiler(context);
return pc.compilePlan(plan, null, jobEventListenerFactory);
}
};
}
};
}
Aggregations