Search in sources :

Example 1 with IntersectOperatorDescriptor

use of org.apache.hyracks.dataflow.std.intersect.IntersectOperatorDescriptor 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 2 with IntersectOperatorDescriptor

use of org.apache.hyracks.dataflow.std.intersect.IntersectOperatorDescriptor in project asterixdb by apache.

the class IntersectOperatorDescriptorTest method testNormalOperatorInitialization.

@Test
public void testNormalOperatorInitialization() throws HyracksException {
    IntersectOperatorDescriptor operatorDescriptor = new IntersectOperatorDescriptor(mockRegistry, nInputs, compareFields, normalizedKeyFactory, comparatorFactory, outRecordDescriptor);
    assertEquals(nInputs, operatorDescriptor.getInputArity());
}
Also used : IntersectOperatorDescriptor(org.apache.hyracks.dataflow.std.intersect.IntersectOperatorDescriptor) Test(org.junit.Test)

Aggregations

IntersectOperatorDescriptor (org.apache.hyracks.dataflow.std.intersect.IntersectOperatorDescriptor)2 AlgebricksException (org.apache.hyracks.algebricks.common.exceptions.AlgebricksException)1 IntersectOperator (org.apache.hyracks.algebricks.core.algebra.operators.logical.IntersectOperator)1 INormalizedKeyComputerFactoryProvider (org.apache.hyracks.algebricks.data.INormalizedKeyComputerFactoryProvider)1 IBinaryComparatorFactory (org.apache.hyracks.api.dataflow.value.IBinaryComparatorFactory)1 INormalizedKeyComputerFactory (org.apache.hyracks.api.dataflow.value.INormalizedKeyComputerFactory)1 RecordDescriptor (org.apache.hyracks.api.dataflow.value.RecordDescriptor)1 HyracksException (org.apache.hyracks.api.exceptions.HyracksException)1 IOperatorDescriptorRegistry (org.apache.hyracks.api.job.IOperatorDescriptorRegistry)1 Test (org.junit.Test)1