Search in sources :

Example 1 with AlgebricksCountPartitionConstraint

use of org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint in project asterixdb by apache.

the class AbstractPhysicalOperator method contributeOpDesc.

protected void contributeOpDesc(IHyracksJobBuilder builder, AbstractLogicalOperator op, IOperatorDescriptor opDesc) {
    if (op.getExecutionMode() == ExecutionMode.UNPARTITIONED) {
        AlgebricksPartitionConstraint apc = new AlgebricksCountPartitionConstraint(1);
        builder.contributeAlgebricksPartitionConstraint(opDesc, apc);
    }
    builder.contributeHyracksOperator(op, opDesc);
}
Also used : AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) AlgebricksCountPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint)

Example 2 with AlgebricksCountPartitionConstraint

use of org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint in project asterixdb by apache.

the class AssignPOperator method contributeRuntimeOperator.

@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
    AssignOperator assign = (AssignOperator) op;
    List<LogicalVariable> variables = assign.getVariables();
    List<Mutable<ILogicalExpression>> expressions = assign.getExpressions();
    int[] outColumns = new int[variables.size()];
    for (int i = 0; i < outColumns.length; i++) {
        outColumns[i] = opSchema.findVariable(variables.get(i));
    }
    IScalarEvaluatorFactory[] evalFactories = new IScalarEvaluatorFactory[expressions.size()];
    IExpressionRuntimeProvider expressionRuntimeProvider = context.getExpressionRuntimeProvider();
    for (int i = 0; i < evalFactories.length; i++) {
        evalFactories[i] = expressionRuntimeProvider.createEvaluatorFactory(expressions.get(i).getValue(), context.getTypeEnvironment(op.getInputs().get(0).getValue()), inputSchemas, context);
    }
    // TODO push projections into the operator
    int[] projectionList = JobGenHelper.projectAllVariables(opSchema);
    AssignRuntimeFactory runtime = new AssignRuntimeFactory(outColumns, evalFactories, projectionList, flushFramesRapidly);
    // contribute one Asterix framewriter
    RecordDescriptor recDesc = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
    if (cardinalityConstraint > 0) {
        AlgebricksCountPartitionConstraint countConstraint = new AlgebricksCountPartitionConstraint(cardinalityConstraint);
        builder.contributeMicroOperator(assign, runtime, recDesc, countConstraint);
    } else {
        builder.contributeMicroOperator(assign, runtime, recDesc);
    }
    // and contribute one edge from its child
    ILogicalOperator src = assign.getInputs().get(0).getValue();
    builder.contributeGraphEdge(src, 0, assign, 0);
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) ILogicalOperator(org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator) AlgebricksCountPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint) AssignOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator) AssignRuntimeFactory(org.apache.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory) AlgebricksCountPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory) Mutable(org.apache.commons.lang3.mutable.Mutable) IExpressionRuntimeProvider(org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider)

Example 3 with AlgebricksCountPartitionConstraint

use of org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint in project asterixdb by apache.

the class JobBuilder method contributeAlgebricksPartitionConstraint.

@Override
public void contributeAlgebricksPartitionConstraint(IOperatorDescriptor opDesc, AlgebricksPartitionConstraint apcArg) {
    AlgebricksPartitionConstraint apc = apcArg;
    if (apc.getPartitionConstraintType() == PartitionConstraintType.COUNT) {
        AlgebricksCountPartitionConstraint constraint = (AlgebricksCountPartitionConstraint) apc;
        if (constraint.getCount() == 1) {
            apc = countOneLocation;
        }
    }
    partitionConstraintMap.put(opDesc, apc);
}
Also used : AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) AlgebricksCountPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint)

Aggregations

AlgebricksCountPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksCountPartitionConstraint)3 AlgebricksPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint)2 Mutable (org.apache.commons.lang3.mutable.Mutable)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)1 IExpressionRuntimeProvider (org.apache.hyracks.algebricks.core.algebra.expressions.IExpressionRuntimeProvider)1 AssignOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.AssignOperator)1 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)1 AssignRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.AssignRuntimeFactory)1 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)1