Search in sources :

Example 1 with AndDescriptor

use of org.apache.asterix.runtime.evaluators.functions.AndDescriptor in project asterixdb by apache.

the class SecondaryIndexOperationsHelper method createFilterNullsSelectOp.

public AlgebricksMetaOperatorDescriptor createFilterNullsSelectOp(JobSpecification spec, int numSecondaryKeyFields, RecordDescriptor secondaryRecDesc) throws AlgebricksException {
    IScalarEvaluatorFactory[] andArgsEvalFactories = new IScalarEvaluatorFactory[numSecondaryKeyFields];
    NotDescriptor notDesc = new NotDescriptor();
    IsUnknownDescriptor isUnknownDesc = new IsUnknownDescriptor();
    for (int i = 0; i < numSecondaryKeyFields; i++) {
        // Access column i, and apply 'is not null'.
        ColumnAccessEvalFactory columnAccessEvalFactory = new ColumnAccessEvalFactory(i);
        IScalarEvaluatorFactory isUnknownEvalFactory = isUnknownDesc.createEvaluatorFactory(new IScalarEvaluatorFactory[] { columnAccessEvalFactory });
        IScalarEvaluatorFactory notEvalFactory = notDesc.createEvaluatorFactory(new IScalarEvaluatorFactory[] { isUnknownEvalFactory });
        andArgsEvalFactories[i] = notEvalFactory;
    }
    IScalarEvaluatorFactory selectCond;
    if (numSecondaryKeyFields > 1) {
        // Create conjunctive condition where all secondary index keys must
        // satisfy 'is not null'.
        AndDescriptor andDesc = new AndDescriptor();
        selectCond = andDesc.createEvaluatorFactory(andArgsEvalFactories);
    } else {
        selectCond = andArgsEvalFactories[0];
    }
    StreamSelectRuntimeFactory select = new StreamSelectRuntimeFactory(selectCond, null, BinaryBooleanInspector.FACTORY, false, -1, null);
    AlgebricksMetaOperatorDescriptor asterixSelectOp = new AlgebricksMetaOperatorDescriptor(spec, 1, 1, new IPushRuntimeFactory[] { select }, new RecordDescriptor[] { secondaryRecDesc });
    AlgebricksPartitionConstraintHelper.setPartitionConstraintInJobSpec(spec, asterixSelectOp, primaryPartitionConstraint);
    return asterixSelectOp;
}
Also used : AndDescriptor(org.apache.asterix.runtime.evaluators.functions.AndDescriptor) StreamSelectRuntimeFactory(org.apache.hyracks.algebricks.runtime.operators.std.StreamSelectRuntimeFactory) NotDescriptor(org.apache.asterix.runtime.evaluators.functions.NotDescriptor) AlgebricksMetaOperatorDescriptor(org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor) ColumnAccessEvalFactory(org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory) IsUnknownDescriptor(org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor) AlgebricksPartitionConstraint(org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint) IScalarEvaluatorFactory(org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)

Aggregations

AndDescriptor (org.apache.asterix.runtime.evaluators.functions.AndDescriptor)1 IsUnknownDescriptor (org.apache.asterix.runtime.evaluators.functions.IsUnknownDescriptor)1 NotDescriptor (org.apache.asterix.runtime.evaluators.functions.NotDescriptor)1 AlgebricksPartitionConstraint (org.apache.hyracks.algebricks.common.constraints.AlgebricksPartitionConstraint)1 IScalarEvaluatorFactory (org.apache.hyracks.algebricks.runtime.base.IScalarEvaluatorFactory)1 ColumnAccessEvalFactory (org.apache.hyracks.algebricks.runtime.evaluators.ColumnAccessEvalFactory)1 AlgebricksMetaOperatorDescriptor (org.apache.hyracks.algebricks.runtime.operators.meta.AlgebricksMetaOperatorDescriptor)1 StreamSelectRuntimeFactory (org.apache.hyracks.algebricks.runtime.operators.std.StreamSelectRuntimeFactory)1