Search in sources :

Example 1 with ValueInspector

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

the class FilteringGroupConverter method getConverter.

// When a converter is asked for, we get the real one from the delegate, then wrap it
// in a filtering pass-through proxy.
// TODO: making the assumption that getConverter(i) is only called once, is that valid?
@Override
public Converter getConverter(int fieldIndex) {
    // get the real converter from the delegate
    Converter delegateConverter = checkNotNull(delegate.getConverter(fieldIndex), "delegate converter");
    // determine the indexFieldPath for the converter proxy we're about to make, which is
    // this converter's path + the requested fieldIndex
    List<Integer> newIndexFieldPath = new ArrayList<Integer>(indexFieldPath.size() + 1);
    newIndexFieldPath.addAll(indexFieldPath);
    newIndexFieldPath.add(fieldIndex);
    if (delegateConverter.isPrimitive()) {
        PrimitiveColumnIO columnIO = getColumnIO(newIndexFieldPath);
        ColumnPath columnPath = ColumnPath.get(columnIO.getColumnDescriptor().getPath());
        ValueInspector[] valueInspectors = getValueInspectors(columnPath);
        return new FilteringPrimitiveConverter(delegateConverter.asPrimitiveConverter(), valueInspectors);
    } else {
        return new FilteringGroupConverter(delegateConverter.asGroupConverter(), newIndexFieldPath, valueInspectorsByColumn, columnIOsByIndexFieldPath);
    }
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) ArrayList(java.util.ArrayList) Converter(org.apache.parquet.io.api.Converter) GroupConverter(org.apache.parquet.io.api.GroupConverter) ColumnPath(org.apache.parquet.hadoop.metadata.ColumnPath) PrimitiveColumnIO(org.apache.parquet.io.PrimitiveColumnIO)

Example 2 with ValueInspector

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

the class TestIncrementallyUpdatedFilterPredicateEvaluator method testOr.

@Test
public void testOr() {
    ValueInspector v1 = intIsEven();
    ValueInspector v2 = intIsEven();
    int F = 11;
    int T = 12;
    // F || F == F
    doOrTest(v1, v2, F, F, false);
    // F || T == T
    doOrTest(v1, v2, F, T, true);
    // T || F == T
    doOrTest(v1, v2, T, F, true);
    // T || T == T
    doOrTest(v1, v2, T, T, true);
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) Test(org.junit.Test)

Example 3 with ValueInspector

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

the class TestIncrementallyUpdatedFilterPredicateEvaluator method testValueInspector.

@Test
public void testValueInspector() {
    // known, and set to false criteria, null considered false
    ValueInspector v = intIsEven();
    v.update(11);
    assertFalse(evaluate(v));
    v.reset();
    // known and set to true criteria, null considered false
    v.update(12);
    assertTrue(evaluate(v));
    v.reset();
    // known and set to null, null considered false
    v.updateNull();
    assertFalse(evaluate(v));
    v.reset();
    // known, and set to false criteria, null considered true
    ValueInspector intIsNull = intIsNull();
    intIsNull.update(10);
    assertFalse(evaluate(intIsNull));
    intIsNull.reset();
    // known, and set to false criteria, null considered true
    intIsNull.updateNull();
    assertTrue(evaluate(intIsNull));
    intIsNull.reset();
    // unknown, null considered false
    v.reset();
    assertFalse(evaluate(v));
    // unknown, null considered true
    intIsNull.reset();
    assertTrue(evaluate(intIsNull));
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) Test(org.junit.Test)

Example 4 with ValueInspector

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

the class TestIncrementallyUpdatedFilterPredicateEvaluator method testAnd.

@Test
public void testAnd() {
    ValueInspector v1 = intIsEven();
    ValueInspector v2 = intIsEven();
    int F = 11;
    int T = 12;
    // F && F == F
    doAndTest(v1, v2, F, F, false);
    // F && T == F
    doAndTest(v1, v2, F, T, false);
    // T && F == F
    doAndTest(v1, v2, T, F, false);
    // T && T == T
    doAndTest(v1, v2, T, T, true);
}
Also used : ValueInspector(org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector) Test(org.junit.Test)

Example 5 with ValueInspector

use of org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector 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)

Aggregations

ValueInspector (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.ValueInspector)8 Test (org.junit.Test)7 And (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.And)2 Or (org.apache.parquet.filter2.recordlevel.IncrementallyUpdatedFilterPredicate.Or)2 ArrayList (java.util.ArrayList)1 ColumnPath (org.apache.parquet.hadoop.metadata.ColumnPath)1 PrimitiveColumnIO (org.apache.parquet.io.PrimitiveColumnIO)1 Converter (org.apache.parquet.io.api.Converter)1 GroupConverter (org.apache.parquet.io.api.GroupConverter)1