Search in sources :

Example 1 with IntersectOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.

the class IntersectPOperator method getRequiredPropertiesForChildren.

@Override
public PhysicalRequirements getRequiredPropertiesForChildren(ILogicalOperator iop, IPhysicalPropertiesVector reqdByParent, IOptimizationContext context) {
    IntersectOperator intersectOp = (IntersectOperator) iop;
    StructuralPropertiesVector[] pv = new StructuralPropertiesVector[intersectOp.getNumInput()];
    for (int i = 0; i < intersectOp.getNumInput(); i++) {
        List<ILocalStructuralProperty> localProps = new ArrayList<>();
        List<OrderColumn> orderColumns = new ArrayList<>();
        for (LogicalVariable column : intersectOp.getInputVariables(i)) {
            orderColumns.add(new OrderColumn(column, OrderOperator.IOrder.OrderKind.ASC));
        }
        localProps.add(new LocalOrderProperty(orderColumns));
        IPartitioningProperty pp = null;
        if (intersectOp.getExecutionMode() == AbstractLogicalOperator.ExecutionMode.PARTITIONED) {
            Set<LogicalVariable> partitioningVariables = new HashSet<>(intersectOp.getInputVariables(i));
            pp = new UnorderedPartitionedProperty(partitioningVariables, null);
        }
        pv[i] = new StructuralPropertiesVector(pp, localProps);
    }
    return new PhysicalRequirements(pv, IPartitioningRequirementsCoordinator.NO_COORDINATION);
}
Also used : StructuralPropertiesVector(org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector) LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) UnorderedPartitionedProperty(org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty) OrderColumn(org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn) ArrayList(java.util.ArrayList) IPartitioningProperty(org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty) PhysicalRequirements(org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements) LocalOrderProperty(org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty) IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator) ILocalStructuralProperty(org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty) HashSet(java.util.HashSet)

Example 2 with IntersectOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.

the class IntersectPOperator method contributeRuntimeOperator.

@Override
public void contributeRuntimeOperator(IHyracksJobBuilder builder, JobGenContext context, ILogicalOperator op, IOperatorSchema opSchema, IOperatorSchema[] inputSchemas, IOperatorSchema outerPlanSchema) throws AlgebricksException {
    // logical op should have checked all the mismatch issues.
    IntersectOperator logicalOp = (IntersectOperator) op;
    int nInput = logicalOp.getNumInput();
    int[][] compareFields = new int[nInput][];
    IBinaryComparatorFactory[] comparatorFactories = JobGenHelper.variablesToAscBinaryComparatorFactories(logicalOp.getInputVariables(0), context.getTypeEnvironment(op), context);
    INormalizedKeyComputerFactoryProvider nkcfProvider = context.getNormalizedKeyComputerFactoryProvider();
    INormalizedKeyComputerFactory nkcf = null;
    if (nkcfProvider != null) {
        Object type = context.getTypeEnvironment(op).getVarType(logicalOp.getInputVariables(0).get(0));
        if (type != null) {
            nkcf = nkcfProvider.getNormalizedKeyComputerFactory(type, true);
        }
    }
    for (int i = 0; i < logicalOp.getNumInput(); i++) {
        compareFields[i] = JobGenHelper.variablesToFieldIndexes(logicalOp.getInputVariables(i), inputSchemas[i]);
    }
    IOperatorDescriptorRegistry spec = builder.getJobSpec();
    RecordDescriptor recordDescriptor = JobGenHelper.mkRecordDescriptor(context.getTypeEnvironment(op), opSchema, context);
    IntersectOperatorDescriptor opDescriptor = null;
    try {
        opDescriptor = new IntersectOperatorDescriptor(spec, nInput, compareFields, nkcf, comparatorFactories, recordDescriptor);
    } catch (HyracksException e) {
        throw new AlgebricksException(e);
    }
    contributeOpDesc(builder, (AbstractLogicalOperator) op, opDescriptor);
    for (int i = 0; i < op.getInputs().size(); i++) {
        builder.contributeGraphEdge(op.getInputs().get(i).getValue(), 0, op, i);
    }
}
Also used : RecordDescriptor(org.apache.hyracks.api.dataflow.value.RecordDescriptor) IBinaryComparatorFactory(org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory) AlgebricksException(org.apache.hyracks.algebricks.common.exceptions.AlgebricksException) HyracksException(org.apache.hyracks.api.exceptions.HyracksException) IOperatorDescriptorRegistry(org.apache.hyracks.api.job.IOperatorDescriptorRegistry) IntersectOperatorDescriptor(org.apache.hyracks.dataflow.std.intersect.IntersectOperatorDescriptor) INormalizedKeyComputerFactory(org.apache.hyracks.api.dataflow.value.INormalizedKeyComputerFactory) INormalizedKeyComputerFactoryProvider(org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider) IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)

Example 3 with IntersectOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.

the class LogicalOperatorDeepCopyWithNewVariablesVisitor method visitIntersectOperator.

@Override
public ILogicalOperator visitIntersectOperator(IntersectOperator op, ILogicalOperator arg) throws AlgebricksException {
    List<List<LogicalVariable>> liveVarsInInputs = getLiveVarsInInputs(op);
    List<LogicalVariable> outputCopy = new ArrayList<>();
    for (LogicalVariable var : op.getOutputVars()) {
        outputCopy.add(deepCopyVariable(var));
    }
    IntersectOperator opCopy = new IntersectOperator(outputCopy, liveVarsInInputs);
    deepCopyInputsAnnotationsAndExecutionMode(op, arg, opCopy);
    return opCopy;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)

Example 4 with IntersectOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.

the class IsomorphismOperatorVisitor method visitIntersectOperator.

@Override
public Boolean visitIntersectOperator(IntersectOperator op, ILogicalOperator arg) throws AlgebricksException {
    if (op.getOperatorTag() != LogicalOperatorTag.INTERSECT) {
        return Boolean.FALSE;
    }
    IntersectOperator intersetOpArg = (IntersectOperator) copyAndSubstituteVar(op, arg);
    List<LogicalVariable> variables = op.getOutputVars();
    List<LogicalVariable> variablesArg = intersetOpArg.getOutputVars();
    if (variables.size() != variablesArg.size()) {
        return Boolean.FALSE;
    }
    if (!VariableUtilities.varListEqualUnordered(variables, variablesArg)) {
        return Boolean.FALSE;
    }
    if (op.getNumInput() != intersetOpArg.getNumInput()) {
        return Boolean.FALSE;
    }
    for (int i = 0; i < op.getNumInput(); i++) {
        if (!VariableUtilities.varListEqualUnordered(op.getInputVariables(i), intersetOpArg.getInputVariables(i))) {
            return Boolean.FALSE;
        }
    }
    return Boolean.TRUE;
}
Also used : LogicalVariable(org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable) IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)

Example 5 with IntersectOperator

use of org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator in project asterixdb by apache.

the class IsomorphismVariableMappingVisitor method mapVariablesForIntersect.

private void mapVariablesForIntersect(IntersectOperator op, ILogicalOperator arg) {
    if (op.getOperatorTag() != arg.getOperatorTag()) {
        return;
    }
    IntersectOperator opArg = (IntersectOperator) arg;
    if (op.getNumInput() != opArg.getNumInput()) {
        return;
    }
    for (int i = 0; i < op.getNumInput(); i++) {
        for (int j = 0; j < op.getInputVariables(i).size(); j++) {
            if (!varEquivalent(op.getInputVariables(i).get(j), opArg.getInputVariables(i).get(j))) {
                return;
            }
        }
    }
    mapVariables(op.getOutputVars(), opArg.getOutputVars());
}
Also used : IntersectOperator(org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)

Aggregations

IntersectOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)7 LogicalVariable (org.apache.hyracks.algebricks.core.algebra.base.LogicalVariable)5 ArrayList (java.util.ArrayList)4 List (java.util.List)2 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)2 ILocalStructuralProperty (org.apache.hyracks.algebricks.core.algebra.properties.ILocalStructuralProperty)2 IPartitioningProperty (org.apache.hyracks.algebricks.core.algebra.properties.IPartitioningProperty)2 LocalOrderProperty (org.apache.hyracks.algebricks.core.algebra.properties.LocalOrderProperty)2 OrderColumn (org.apache.hyracks.algebricks.core.algebra.properties.OrderColumn)2 StructuralPropertiesVector (org.apache.hyracks.algebricks.core.algebra.properties.StructuralPropertiesVector)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Mutable (org.apache.commons.lang3.mutable.Mutable)1 ILogicalOperator (org.apache.hyracks.algebricks.core.algebra.base.ILogicalOperator)1 VariableReferenceExpression (org.apache.hyracks.algebricks.core.algebra.expressions.VariableReferenceExpression)1 OrderOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.OrderOperator)1 PhysicalRequirements (org.apache.hyracks.algebricks.core.algebra.properties.PhysicalRequirements)1 UnorderedPartitionedProperty (org.apache.hyracks.algebricks.core.algebra.properties.UnorderedPartitionedProperty)1 INormalizedKeyComputerFactoryProvider (org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider)1 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)1