Java Code Examples for org.apache.kylin.metadata.filter.CompareTupleFilter#addChild()
The following examples show how to use
org.apache.kylin.metadata.filter.CompareTupleFilter#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: DerivedFilterTranslator.java From Kylin with Apache License 2.0 | 6 votes |
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 2
Source File: FilterBaseTest.java From kylin with Apache License 2.0 | 6 votes |
protected CompareTupleFilter buildINCompareFilter(TblColRef dateColumn) throws ParseException { CompareTupleFilter compareFilter = new CompareTupleFilter(FilterOperatorEnum.IN); ColumnTupleFilter columnFilter = new ColumnTupleFilter(dateColumn); compareFilter.addChild(columnFilter); List<String> inValues = Lists.newArrayList(); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd", Locale.ROOT); Date startDate = simpleDateFormat.parse("1970-01-01"); Date endDate = simpleDateFormat.parse("2100-01-01"); Calendar start = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ROOT); start.setTime(startDate); Calendar end = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ROOT); end.setTime(endDate); for (Date date = start.getTime(); start.before(end); start.add(Calendar.DATE, 1), date = start.getTime()) { inValues.add(simpleDateFormat.format(date)); } ConstantTupleFilter constantFilter = new ConstantTupleFilter(inValues); compareFilter.addChild(constantFilter); return compareFilter; }
Example 3
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 4
Source File: DerivedFilterTranslator.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
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 5
Source File: StorageMockUtils.java From kylin with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildFilter3(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); ColumnTupleFilter columnFilter1 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter1); ConstantTupleFilter constantFilter1 = new ConstantTupleFilter("2012-05-23"); compareFilter.addChild(constantFilter1); return compareFilter; }
Example 6
Source File: FilterBaseTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
protected CompareTupleFilter buildCompareDynamicFilter(List<TblColRef> groups, FilterOperatorEnum operator) { CompareTupleFilter compareFilter = new CompareTupleFilter(operator); compareFilter.addChild(new ColumnTupleFilter(groups.get(0))); compareFilter.addChild(new DynamicTupleFilter("?0")); compareFilter.bindVariable("?0", "abc"); return compareFilter; }
Example 7
Source File: FilterBaseTest.java From kylin with Apache License 2.0 | 5 votes |
protected CompareTupleFilter buildCompareDynamicFilter(List<TblColRef> groups, FilterOperatorEnum operator) { CompareTupleFilter compareFilter = new CompareTupleFilter(operator); compareFilter.addChild(new ColumnTupleFilter(groups.get(0))); compareFilter.addChild(new DynamicTupleFilter("?0")); compareFilter.bindVariable("?0", "abc"); return compareFilter; }
Example 8
Source File: StorageMockUtils.java From kylin with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildFilter1(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE); ColumnTupleFilter columnFilter1 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter1); ConstantTupleFilter constantFilter1 = new ConstantTupleFilter("2012-05-23"); compareFilter.addChild(constantFilter1); return compareFilter; }
Example 9
Source File: StorageMockUtils.java From kylin with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildFilter2(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); ColumnTupleFilter columnFilter2 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter2); ConstantTupleFilter constantFilter2 = new ConstantTupleFilter("ClothinShoes & Accessories"); compareFilter.addChild(constantFilter2); return compareFilter; }
Example 10
Source File: GTScannerBenchmark2.java From kylin with Apache License 2.0 | 5 votes |
private CompareTupleFilter eq(ColumnTupleFilter col, int... values) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.IN); r.addChild(col); List<ByteArray> list = Lists.newArrayList(); for (int v : values) { int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); list.add(bytes); } r.addChild(new ConstantTupleFilter(list)); return r; }
Example 11
Source File: StorageMockUtils.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildFilter2(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); ColumnTupleFilter columnFilter2 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter2); ConstantTupleFilter constantFilter2 = new ConstantTupleFilter("ClothinShoes & Accessories"); compareFilter.addChild(constantFilter2); return compareFilter; }
Example 12
Source File: StorageMockUtils.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildFilter1(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.LTE); ColumnTupleFilter columnFilter1 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter1); ConstantTupleFilter constantFilter1 = new ConstantTupleFilter("2012-05-23"); compareFilter.addChild(constantFilter1); return compareFilter; }
Example 13
Source File: GTScannerBenchmark2.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private CompareTupleFilter gt(ColumnTupleFilter col, int v) { CompareTupleFilter r = new CompareTupleFilter(FilterOperatorEnum.GT); r.addChild(col); int c = col.getColumn().getColumnDesc().getZeroBasedIndex(); int len = info.getCodeSystem().maxCodeLength(c); ByteArray bytes = new ByteArray(len); BytesUtil.writeLong(v, bytes.array(), bytes.offset(), len); r.addChild(new ConstantTupleFilter(bytes)); return r; }
Example 14
Source File: TestHelper.java From kylin with Apache License 2.0 | 5 votes |
public TupleFilter buildLowerFilter(String columnName, FilterOperatorEnum op, String value) { CompareTupleFilter compareFilter = new CompareTupleFilter(op); ColumnTupleFilter columnFilter1 = buildColumnFilter(columnName); BuiltInFunctionTupleFilter lowerFilter = new BuiltInFunctionTupleFilter("lower"); lowerFilter.addChild(columnFilter1); compareFilter.addChild(lowerFilter); compareFilter.addChild(new ConstantTupleFilter(value)); return compareFilter; }
Example 15
Source File: FragmentFileSearcher.java From kylin with Apache License 2.0 | 4 votes |
private TupleFilter newCompareFilter(FilterOperatorEnum op, TblColRef col, ByteArray code) { CompareTupleFilter r = new CompareTupleFilter(op); r.addChild(new ColumnTupleFilter(col)); r.addChild(new ConstantTupleFilter(code)); return r; }
Example 16
Source File: FilterDecorator.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public TupleFilter onSerialize(TupleFilter filter) { if (filter == null) return null; BuiltInFunctionTransformer translator = new BuiltInFunctionTransformer(dimEncMap); filter = translator.transform(filter); // un-evaluatable filter is replaced with TRUE if (!filter.isEvaluable()) { TupleFilter.collectColumns(filter, inevaluableColumns); return ConstantTupleFilter.TRUE; } if (!(filter instanceof CompareTupleFilter)) return filter; // double check all internal of CompareTupleFilter is evaluatable if (!TupleFilter.isEvaluableRecursively(filter)) { TupleFilter.collectColumns(filter, inevaluableColumns); return ConstantTupleFilter.TRUE; } if (filterConstantsTreatment == FilterConstantsTreatment.AS_IT_IS) { return filter; } else { // extract ColumnFilter & ConstantFilter CompareTupleFilter compareFilter = (CompareTupleFilter) filter; TblColRef col = compareFilter.getColumn(); if (col == null) { return filter; } Collection<String> constValues = (Collection<String>) compareFilter.getValues(); if (constValues == null || constValues.isEmpty()) { return filter; } CompareTupleFilter newCompareFilter = new CompareTupleFilter(compareFilter.getOperator()); newCompareFilter.addChild(new ColumnTupleFilter(col)); if (filterConstantsTreatment == FilterConstantsTreatment.REPLACE_WITH_GLOBAL_DICT) { return replaceConstantsWithGlobalDict(compareFilter, newCompareFilter); } else if (filterConstantsTreatment == FilterConstantsTreatment.REPLACE_WITH_LOCAL_DICT) { return replaceConstantsWithLocalDict(compareFilter, newCompareFilter); } else { throw new RuntimeException("should not reach here"); } } }
Example 17
Source File: GTUtil.java From kylin with Apache License 2.0 | 4 votes |
private TupleFilter newCompareFilter(TupleFilter.FilterOperatorEnum op, TblColRef col) { CompareTupleFilter r = new CompareTupleFilter(op); r.addChild(new ColumnTupleFilter(col)); return r; }
Example 18
Source File: DictGridTableTest.java From kylin with Apache License 2.0 | 4 votes |
public static CompareTupleFilter compare(TblColRef col, FilterOperatorEnum op, Object... value) { CompareTupleFilter result = new CompareTupleFilter(op); result.addChild(new ColumnTupleFilter(col)); result.addChild(new ConstantTupleFilter(Arrays.asList(value))); return result; }
Example 19
Source File: FragmentFileSearcher.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private TupleFilter newCompareFilter(FilterOperatorEnum op, TblColRef col, ByteArray code) { CompareTupleFilter r = new CompareTupleFilter(op); r.addChild(new ColumnTupleFilter(col)); r.addChild(new ConstantTupleFilter(code)); return r; }
Example 20
Source File: GTUtil.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
private TupleFilter newCompareFilter(FilterOperatorEnum op, TblColRef col, ByteArray code) { CompareTupleFilter r = new CompareTupleFilter(op); r.addChild(new ColumnTupleFilter(col)); r.addChild(new ConstantTupleFilter(code)); return r; }