Search in sources :

Example 1 with IncrementallyUpdatedFilterPredicate

use of org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate in project parquet-mr by apache.

the class TestIncrementallyUpdatedFilterPredicateEvaluator method testShortCircuit.

@Test
public void testShortCircuit() {
    ValueInspector neverCalled = new ValueInspector() {

        @Override
        public boolean accept(Visitor visitor) {
            throw new ShortCircuitException();
        }
    };
    try {
        evaluate(neverCalled);
        fail("this should throw");
    } catch (ShortCircuitException e) {
    // 
    }
    // T || X should evaluate to true without inspecting X
    ValueInspector v = intIsEven();
    v.update(10);
    IncrementallyUpdatedFilterPredicate or = new Or(v, neverCalled);
    assertTrue(evaluate(or));
    v.reset();
    // F && X should evaluate to false without inspecting X
    v.update(11);
    IncrementallyUpdatedFilterPredicate and = new And(v, neverCalled);
    assertFalse(evaluate(and));
    v.reset();
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) Or(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.Or) And(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.And) Test(org.junit.Test)

Example 2 with IncrementallyUpdatedFilterPredicate

use of org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate in project parquet-mr by apache.

the class TestIncrementallyUpdatedFilterPredicateResetter method testReset.

@Test
public void testReset() {
    ValueInspector intIsNull = intIsNull();
    ValueInspector intIsEven = intIsEven();
    ValueInspector doubleMoreThan10 = doubleMoreThan10();
    IncrementallyUpdatedFilterPredicate pred = new Or(intIsNull, new And(intIsEven, doubleMoreThan10));
    intIsNull.updateNull();
    intIsEven.update(11);
    doubleMoreThan10.update(20.0D);
    assertTrue(intIsNull.isKnown());
    assertTrue(intIsEven.isKnown());
    assertTrue(doubleMoreThan10.isKnown());
    IncrementallyUpdatedFilterPredicateResetter.reset(pred);
    assertFalse(intIsNull.isKnown());
    assertFalse(intIsEven.isKnown());
    assertFalse(doubleMoreThan10.isKnown());
    intIsNull.updateNull();
    assertTrue(intIsNull.isKnown());
    assertFalse(intIsEven.isKnown());
    assertFalse(doubleMoreThan10.isKnown());
    IncrementallyUpdatedFilterPredicateResetter.reset(pred);
    assertFalse(intIsNull.isKnown());
    assertFalse(intIsEven.isKnown());
    assertFalse(doubleMoreThan10.isKnown());
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) Or(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.Or) And(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.And) Test(org.junit.Test)

Example 3 with IncrementallyUpdatedFilterPredicate

use of org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate in project parquet-mr by apache.

the class MessageColumnIO method getRecordReader.

public <T> RecordReader<T> getRecordReader(final PageReadStore columns, final RecordMaterializer<T> recordMaterializer, final Filter filter) {
    checkNotNull(columns, "columns");
    checkNotNull(recordMaterializer, "recordMaterializer");
    checkNotNull(filter, "filter");
    if (leaves.isEmpty()) {
        return new EmptyRecordReader<T>(recordMaterializer);
    }
    return filter.accept(new Visitor<RecordReader<T>>() {

        @Override
        public RecordReader<T> visit(FilterPredicateCompat filterPredicateCompat) {
            FilterPredicate predicate = filterPredicateCompat.getFilterPredicate();
            IncrementallyUpdatedFilterPredicateBuilder builder = new IncrementallyUpdatedFilterPredicateBuilder(leaves);
            IncrementallyUpdatedFilterPredicate streamingPredicate = builder.build(predicate);
            RecordMaterializer<T> filteringRecordMaterializer = new FilteringRecordMaterializer<T>(recordMaterializer, leaves, builder.getValueInspectorsByColumn(), streamingPredicate);
            return new RecordReaderImplementation<T>(MessageColumnIO.this, filteringRecordMaterializer, validating, new ColumnReadStoreImpl(columns, filteringRecordMaterializer.getRootConverter(), getType(), createdBy));
        }

        @Override
        public RecordReader<T> visit(UnboundRecordFilterCompat unboundRecordFilterCompat) {
            return new FilteredRecordReader<T>(MessageColumnIO.this, recordMaterializer, validating, new ColumnReadStoreImpl(columns, recordMaterializer.getRootConverter(), getType(), createdBy), unboundRecordFilterCompat.getUnboundRecordFilter(), columns.getRowCount());
        }

        @Override
        public RecordReader<T> visit(NoOpFilter noOpFilter) {
            return new RecordReaderImplementation<T>(MessageColumnIO.this, recordMaterializer, validating, new ColumnReadStoreImpl(columns, recordMaterializer.getRootConverter(), getType(), createdBy));
        }
    });
}
Also used : ColumnReadStoreImpl(org.apache.parquet.column.impl.ColumnReadStoreImpl) NoOpFilter(org.apache.parquet.filter2.compat.FilterCompat.NoOpFilter) FilteringRecordMaterializer(org.apache.parquet.filter2.recordlevel.FilteringRecordMaterializer) RecordMaterializer(org.apache.parquet.io.api.RecordMaterializer) FilterPredicateCompat(org.apache.parquet.filter2.compat.FilterCompat.FilterPredicateCompat) IncrementallyUpdatedFilterPredicateBuilder(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicateBuilder) FilterPredicate(org.apache.parquet.filter2.predicate.FilterPredicate) IncrementallyUpdatedFilterPredicate(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate) UnboundRecordFilterCompat(org.apache.parquet.filter2.compat.FilterCompat.UnboundRecordFilterCompat) IncrementallyUpdatedFilterPredicate(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate)

Aggregations

And (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.And)2 Or (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.Or)2 ValueInspector (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector)2 Test (org.junit.Test)2 ColumnReadStoreImpl (org.apache.parquet.column.impl.ColumnReadStoreImpl)1 FilterPredicateCompat (org.apache.parquet.filter2.compat.FilterCompat.FilterPredicateCompat)1 NoOpFilter (org.apache.parquet.filter2.compat.FilterCompat.NoOpFilter)1 UnboundRecordFilterCompat (org.apache.parquet.filter2.compat.FilterCompat.UnboundRecordFilterCompat)1 FilterPredicate (org.apache.parquet.filter2.predicate.FilterPredicate)1 FilteringRecordMaterializer (org.apache.parquet.filter2.recordlevel.FilteringRecordMaterializer)1 IncrementallyUpdatedFilterPredicate (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate)1 IncrementallyUpdatedFilterPredicateBuilder (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicateBuilder)1 RecordMaterializer (org.apache.parquet.io.api.RecordMaterializer)1