Java Code Examples for org.apache.kylin.metadata.filter.TupleFilter.FilterOperatorEnum#OR
The following examples show how to use
org.apache.kylin.metadata.filter.TupleFilter.FilterOperatorEnum#OR .
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: DerivedFilterTranslator.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
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 2
Source File: StreamingDataQueryPlanner.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
protected 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 3
Source File: CubeStorageEngine.java From Kylin with Apache License 2.0 | 6 votes |
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 4
Source File: DerivedFilterTranslator.java From Kylin with Apache License 2.0 | 6 votes |
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: DerivedFilterTranslator.java From kylin with Apache License 2.0 | 6 votes |
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 6
Source File: StreamingDataQueryPlanner.java From kylin with Apache License 2.0 | 6 votes |
protected 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 7
Source File: FilterSerializeTest.java From Kylin with Apache License 2.0 | 5 votes |
@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); byte[] bytes = TupleFilterSerializer.serialize(logicFilter); TupleFilter newFilter = TupleFilterSerializer.deserialize(bytes); compareFilter(logicFilter, newFilter); }
Example 8
Source File: TupleFilterTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Test public void flatFilterTest() { TupleFilter topAndFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND); topAndFilter.addChild(createEQFilter("c1", "v1")); TupleFilter orFilter1 = new LogicalTupleFilter(FilterOperatorEnum.OR); TupleFilter andFilter11 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter11.addChild(createEQFilter("c2", "v2")); andFilter11.addChild(createEQFilter("c3", "v3")); TupleFilter andFilter12 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter12.addChild(createEQFilter("c2", "v21")); andFilter12.addChild(createEQFilter("c3", "v31")); orFilter1.addChild(andFilter11); orFilter1.addChild(andFilter12); TupleFilter orFilter2 = new LogicalTupleFilter(FilterOperatorEnum.OR); TupleFilter andFilter21 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter21.addChild(createEQFilter("c4", "v4")); andFilter21.addChild(createEQFilter("c5", "v5")); TupleFilter andFilter22 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter22.addChild(createEQFilter("c4", "v41")); andFilter22.addChild(createEQFilter("c5", "v51")); TupleFilter andFilter23 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter23.addChild(createEQFilter("c4", "v42")); andFilter23.addChild(createEQFilter("c5", "v52")); orFilter2.addChild(andFilter21); orFilter2.addChild(andFilter22); orFilter2.addChild(andFilter23); topAndFilter.addChild(orFilter1); topAndFilter.addChild(orFilter2); TupleFilter flatFilter = topAndFilter.flatFilter(500000); Assert.assertEquals(6, flatFilter.children.size()); }
Example 9
Source File: FilterBaseTest.java From Kylin with Apache License 2.0 | 5 votes |
protected TupleFilter buildOrFilter(List<TblColRef> columns) { CompareTupleFilter compareFilter1 = buildCompareFilter(columns, 0); CompareTupleFilter compareFilter2 = buildCompareFilter(columns, 1); LogicalTupleFilter logicFilter = new LogicalTupleFilter(FilterOperatorEnum.OR); logicFilter.addChild(compareFilter1); logicFilter.addChild(compareFilter2); return logicFilter; }
Example 10
Source File: StorageTest.java From Kylin with Apache License 2.0 | 5 votes |
@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 11
Source File: FilterSerializeTest.java From kylin with Apache License 2.0 | 5 votes |
@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 12
Source File: FilterBaseTest.java From kylin with Apache License 2.0 | 5 votes |
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 13
Source File: TupleFilterTest.java From kylin with Apache License 2.0 | 5 votes |
@Test(expected = IllegalStateException.class) public void flatFilterTooFatTest() { TupleFilter topAndFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND); for (int i = 0; i < 3; i++) { TupleFilter orFilter = new LogicalTupleFilter(FilterOperatorEnum.OR); String col = "col-" + i; for (int j = 0; j < 100; j++) { orFilter.addChild(createEQFilter(col, String.valueOf(j))); } topAndFilter.addChild(orFilter); } TupleFilter flatFilter = topAndFilter.flatFilter(500000); System.out.println(flatFilter); }
Example 14
Source File: TupleFilterTest.java From kylin with Apache License 2.0 | 5 votes |
@Test public void flatFilterTest() { TupleFilter topAndFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND); topAndFilter.addChild(createEQFilter("c1", "v1")); TupleFilter orFilter1 = new LogicalTupleFilter(FilterOperatorEnum.OR); TupleFilter andFilter11 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter11.addChild(createEQFilter("c2", "v2")); andFilter11.addChild(createEQFilter("c3", "v3")); TupleFilter andFilter12 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter12.addChild(createEQFilter("c2", "v21")); andFilter12.addChild(createEQFilter("c3", "v31")); orFilter1.addChild(andFilter11); orFilter1.addChild(andFilter12); TupleFilter orFilter2 = new LogicalTupleFilter(FilterOperatorEnum.OR); TupleFilter andFilter21 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter21.addChild(createEQFilter("c4", "v4")); andFilter21.addChild(createEQFilter("c5", "v5")); TupleFilter andFilter22 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter22.addChild(createEQFilter("c4", "v41")); andFilter22.addChild(createEQFilter("c5", "v51")); TupleFilter andFilter23 = new LogicalTupleFilter(FilterOperatorEnum.AND); andFilter23.addChild(createEQFilter("c4", "v42")); andFilter23.addChild(createEQFilter("c5", "v52")); orFilter2.addChild(andFilter21); orFilter2.addChild(andFilter22); orFilter2.addChild(andFilter23); topAndFilter.addChild(orFilter1); topAndFilter.addChild(orFilter2); TupleFilter flatFilter = topAndFilter.flatFilter(500000); Assert.assertEquals(6, flatFilter.children.size()); }
Example 15
Source File: FilterSerializeTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@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 16
Source File: FilterBaseTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
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 17
Source File: TupleFilterTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Test(expected = IllegalStateException.class) public void flatFilterTooFatTest() { TupleFilter topAndFilter = new LogicalTupleFilter(TupleFilter.FilterOperatorEnum.AND); for (int i = 0; i < 3; i++) { TupleFilter orFilter = new LogicalTupleFilter(FilterOperatorEnum.OR); String col = "col-" + i; for (int j = 0; j < 100; j++) { orFilter.addChild(createEQFilter(col, String.valueOf(j))); } topAndFilter.addChild(orFilter); } TupleFilter flatFilter = topAndFilter.flatFilter(500000); System.out.println(flatFilter); }