Search in sources :

Example 1 with IPredicateEvaluator

use of org.apache.hyracks.api.dataflow.value.IPredicateEvaluator in project asterixdb by apache.

the class PredicateEvaluatorFactoryProvider method getPredicateEvaluatorFactory.

@Override
public IPredicateEvaluatorFactory getPredicateEvaluatorFactory(final int[] keys0, final int[] keys1) {
    return new IPredicateEvaluatorFactory() {

        private static final long serialVersionUID = 1L;

        @Override
        public IPredicateEvaluator createPredicateEvaluator() {
            return new IPredicateEvaluator() {

                @Override
                public boolean evaluate(IFrameTupleAccessor fta0, int tupId0, IFrameTupleAccessor fta1, int tupId1) {
                    int tStart0 = fta0.getTupleStartOffset(tupId0);
                    int fStartOffset0 = fta0.getFieldSlotsLength() + tStart0;
                    for (int k0 : keys0) {
                        int fieldStartIx = fta0.getFieldStartOffset(tupId0, k0);
                        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(fta0.getBuffer().array()[fieldStartIx + fStartOffset0]);
                        if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
                            return false;
                        }
                    }
                    int tStart1 = fta1.getTupleStartOffset(tupId1);
                    int fStartOffset1 = fta1.getFieldSlotsLength() + tStart1;
                    for (int k1 : keys1) {
                        int fieldStartIx = fta1.getFieldStartOffset(tupId1, k1);
                        ATypeTag typeTag = EnumDeserializer.ATYPETAGDESERIALIZER.deserialize(fta1.getBuffer().array()[fieldStartIx + fStartOffset1]);
                        if (typeTag == ATypeTag.MISSING || typeTag == ATypeTag.NULL) {
                            return false;
                        }
                    }
                    //none of the fields (from both sides) is NULL
                    return true;
                }
            };
        }
    };
}
Also used : IPredicateEvaluator(org.apache.hyracks.api.dataflow.value.IPredicateEvaluator) IPredicateEvaluatorFactory(org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory) ATypeTag(org.apache.asterix.om.types.ATypeTag) IFrameTupleAccessor(org.apache.hyracks.api.comm.IFrameTupleAccessor)

Aggregations

ATypeTag (org.apache.asterix.om.types.ATypeTag)1 IFrameTupleAccessor (org.apache.hyracks.api.comm.IFrameTupleAccessor)1 IPredicateEvaluator (org.apache.hyracks.api.dataflow.value.IPredicateEvaluator)1 IPredicateEvaluatorFactory (org.apache.hyracks.api.dataflow.value.IPredicateEvaluatorFactory)1