Java Code Examples for org.apache.kylin.metadata.filter.LogicalTupleFilter#addChild()

The following examples show how to use org.apache.kylin.metadata.filter.LogicalTupleFilter#addChild() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeStorageEngine.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private TupleFilter flattenToOrAndFilter(TupleFilter filter) {
    if (filter == null)
        return null;

    TupleFilter flatFilter = filter.flatFilter();

    // normalize to OR-AND filter
    if (flatFilter.getOperator() == FilterOperatorEnum.AND) {
        LogicalTupleFilter f = new LogicalTupleFilter(FilterOperatorEnum.OR);
        f.addChild(flatFilter);
        flatFilter = f;
    }

    if (flatFilter.getOperator() != FilterOperatorEnum.OR)
        throw new IllegalStateException();

    return flatFilter;
}
 
Example 2
Source File: DerivedFilterTranslator.java    From Kylin with Apache License 2.0 6 votes vote down vote up
private static LogicalTupleFilter buildRangeFilter(TblColRef[] hostCols, Set<Array<String>> satisfyingHostRecords) {
    int hn = hostCols.length;
    String[] min = new String[hn];
    String[] max = new String[hn];
    findMinMax(satisfyingHostRecords, hostCols, min, max);
    LogicalTupleFilter and = new LogicalTupleFilter(FilterOperatorEnum.AND);
    for (int i = 0; i < hn; i++) {
        CompareTupleFilter compMin = new CompareTupleFilter(FilterOperatorEnum.GTE);
        compMin.addChild(new ColumnTupleFilter(hostCols[i]));
        compMin.addChild(new ConstantTupleFilter(min[i]));
        and.addChild(compMin);
        CompareTupleFilter compMax = new CompareTupleFilter(FilterOperatorEnum.LTE);
        compMax.addChild(new ColumnTupleFilter(hostCols[i]));
        compMax.addChild(new ConstantTupleFilter(max[i]));
        and.addChild(compMax);
    }
    return and;
}
 
Example 3
Source File: DerivedFilterTranslator.java    From kylin with Apache License 2.0 6 votes vote down vote up
private static LogicalTupleFilter buildRangeFilter(TblColRef[] hostCols, Set<Array<String>> satisfyingHostRecords) {
    int hn = hostCols.length;
    String[] min = new String[hn];
    String[] max = new String[hn];
    findMinMax(satisfyingHostRecords, hostCols, min, max);
    LogicalTupleFilter and = new LogicalTupleFilter(FilterOperatorEnum.AND);
    for (int i = 0; i < hn; i++) {
        CompareTupleFilter compMin = new CompareTupleFilter(FilterOperatorEnum.GTE);
        compMin.addChild(new ColumnTupleFilter(hostCols[i]));
        compMin.addChild(new ConstantTupleFilter(min[i]));
        and.addChild(compMin);
        CompareTupleFilter compMax = new CompareTupleFilter(FilterOperatorEnum.LTE);
        compMax.addChild(new ColumnTupleFilter(hostCols[i]));
        compMax.addChild(new ConstantTupleFilter(max[i]));
        and.addChild(compMax);
    }
    return and;
}
 
Example 4
Source File: DerivedFilterTranslator.java    From kylin with Apache License 2.0 6 votes vote down vote up
private static TupleFilter buildInFilter(TblColRef[] hostCols, Set<Array<String>> satisfyingHostRecords) {
    if (satisfyingHostRecords.size() == 0) {
        return ConstantTupleFilter.FALSE;
    }

    int hn = hostCols.length;
    if (hn == 1) {
        CompareTupleFilter in = new CompareTupleFilter(FilterOperatorEnum.IN);
        in.addChild(new ColumnTupleFilter(hostCols[0]));
        in.addChild(new ConstantTupleFilter(asValues(satisfyingHostRecords)));
        return in;
    } else {
        LogicalTupleFilter or = new LogicalTupleFilter(FilterOperatorEnum.OR);
        for (Array<String> rec : satisfyingHostRecords) {
            LogicalTupleFilter and = new LogicalTupleFilter(FilterOperatorEnum.AND);
            for (int i = 0; i < hn; i++) {
                CompareTupleFilter eq = new CompareTupleFilter(FilterOperatorEnum.EQ);
                eq.addChild(new ColumnTupleFilter(hostCols[i]));
                eq.addChild(new ConstantTupleFilter(rec.data[i]));
                and.addChild(eq);
            }
            or.addChild(and);
        }
        return or;
    }
}
 
Example 5
Source File: FilterSerializeTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialize10() {
    List<TblColRef> groups = buildGroups();
    TupleFilter orFilter = buildOrFilter(groups);
    TupleFilter andFilter = buildAndFilter(groups);

    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR);
    logicFilter.addChild(orFilter);
    logicFilter.addChild(andFilter);

    assertFilterSerDe(logicFilter);
}
 
Example 6
Source File: FilterBaseTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
protected TupleFilter buildAndFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildEQCompareFilter(columns, 0);
    CompareTupleFilter compareFilter2 = buildEQCompareFilter(columns, 1);
    LogicalTupleFilter andFilter = new LogicalTupleFilter(FilterOperatorEnum.AND);
    andFilter.addChild(compareFilter1);
    andFilter.addChild(compareFilter2);
    return andFilter;
}
 
Example 7
Source File: DictGridTableTest.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static LogicalTupleFilter logic(FilterOperatorEnum op, TupleFilter... children) {
    LogicalTupleFilter result = new LogicalTupleFilter(op);
    for (TupleFilter c : children) {
        result.addChild(c);
    }
    return result;
}
 
Example 8
Source File: StorageMockUtils.java    From kylin with Apache License 2.0 5 votes vote down vote up
public TupleFilter buildAndFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildFilter1(columns.get(0));
    CompareTupleFilter compareFilter2 = buildFilter2(columns.get(1));
    LogicalTupleFilter andFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND);
    andFilter.addChild(compareFilter1);
    andFilter.addChild(compareFilter2);
    return andFilter;
}
 
Example 9
Source File: FilterSerializeTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialize11() {
    List<TblColRef> groups = buildGroups();
    TupleFilter orFilter = buildOrFilter(groups);
    TupleFilter andFilter = buildAndFilter(groups);

    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.AND);
    logicFilter.addChild(orFilter);
    logicFilter.addChild(andFilter);

    assertFilterSerDe(logicFilter);
}
 
Example 10
Source File: FilterSerializeTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialize10() {
    List<TblColRef> groups = buildGroups();
    TupleFilter orFilter = buildOrFilter(groups);
    TupleFilter andFilter = buildAndFilter(groups);

    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR);
    logicFilter.addChild(orFilter);
    logicFilter.addChild(andFilter);

    assertFilterSerDe(logicFilter);
}
 
Example 11
Source File: FilterBaseTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
protected TupleFilter buildOrFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildEQCompareFilter(columns, 0);
    CompareTupleFilter compareFilter2 = buildEQCompareFilter(columns, 1);
    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR);
    logicFilter.addChild(compareFilter1);
    logicFilter.addChild(compareFilter2);
    return logicFilter;
}
 
Example 12
Source File: FilterBaseTest.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
protected TupleFilter buildAndFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildEQCompareFilter(columns, 0);
    CompareTupleFilter compareFilter2 = buildEQCompareFilter(columns, 1);
    LogicalTupleFilter andFilter = new LogicalTupleFilter(FilterOperatorEnum.AND);
    andFilter.addChild(compareFilter1);
    andFilter.addChild(compareFilter2);
    return andFilter;
}
 
Example 13
Source File: StorageMockUtils.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public TupleFilter buildOrFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildFilter1(columns.get(0));
    CompareTupleFilter compareFilter2 = buildFilter2(columns.get(1));
    LogicalTupleFilter logicFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.OR);
    logicFilter.addChild(compareFilter1);
    logicFilter.addChild(compareFilter2);
    return logicFilter;
}
 
Example 14
Source File: StorageTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("unused")
private TupleFilter buildOrFilter(List<TblColRef> columns) {
    CompareTupleFilter compareFilter1 = buildFilter1(columns.get(0));
    CompareTupleFilter compareFilter2 = buildFilter2(columns.get(1));
    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR);
    logicFilter.addChild(compareFilter1);
    logicFilter.addChild(compareFilter2);
    return logicFilter;
}
 
Example 15
Source File: FilterSerializeTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
@Test
public void testSerialize11() {
    List<TblColRef> groups = buildGroups();
    TupleFilter orFilter = buildOrFilter(groups);
    TupleFilter andFilter = buildAndFilter(groups);

    LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.AND);
    logicFilter.addChild(orFilter);
    logicFilter.addChild(andFilter);

    byte[] bytes = TupleFilterSerializer.serialize(logicFilter);
    TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes);

    compareFilter(logicFilter, newFilter);
}
 
Example 16
Source File: GTScannerBenchmark.java    From kylin with Apache License 2.0 4 votes vote down vote up
private LogicalTupleFilter logical(FilterOperatorEnum op, TupleFilter[] filters) {
    LogicalTupleFilter r = new LogicalTupleFilter(op);
    for (TupleFilter f : filters)
        r.addChild(f);
    return r;
}
 
Example 17
Source File: GTScannerBenchmark.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private LogicalTupleFilter logical(FilterOperatorEnum op, TupleFilter[] filters) {
    LogicalTupleFilter r = new LogicalTupleFilter(op);
    for (TupleFilter f : filters)
        r.addChild(f);
    return r;
}
 
Example 18
Source File: GTScannerBenchmark2.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private LogicalTupleFilter logical(FilterOperatorEnum op, TupleFilter[] filters) {
    LogicalTupleFilter r = new LogicalTupleFilter(op);
    for (TupleFilter f : filters)
        r.addChild(f);
    return r;
}
 
Example 19
Source File: TestHelper.java    From kylin with Apache License 2.0 4 votes vote down vote up
public TupleFilter buildLogicalFilter(TupleFilter filter1, TupleFilter filter2, FilterOperatorEnum op) {
    LogicalTupleFilter andFilter = new LogicalTupleFilter(op);
    andFilter.addChild(filter1);
    andFilter.addChild(filter2);
    return andFilter;
}
 
Example 20
Source File: TestHelper.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
public TupleFilter buildLogicalFilter(TupleFilter filter1, TupleFilter filter2, FilterOperatorEnum op) {
    LogicalTupleFilter andFilter = new LogicalTupleFilter(op);
    andFilter.addChild(filter1);
    andFilter.addChild(filter2);
    return andFilter;
}