Java Code Examples for org.apache.kylin.metadata.filter.TupleFilter#isEvaluable()
The following examples show how to use
org.apache.kylin.metadata.filter.TupleFilter#isEvaluable() .
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: GTUtil.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public TupleFilter onSerialize(TupleFilter filter) { if (filter == null) return null; // In case of NOT(unEvaluatableFilter), we should immediately replace it as TRUE, // Otherwise, unEvaluatableFilter will later be replace with TRUE and NOT(unEvaluatableFilter) // will always return FALSE. if (filter.getOperator() == FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(filter)) { TupleFilter.collectColumns(filter, unevaluatableColumnCollector); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!filter.isEvaluable()) { TupleFilter.collectColumns(filter, unevaluatableColumnCollector); return ConstantTupleFilter.TRUE; } // map to column onto grid table if (colMapping != null && filter instanceof ColumnTupleFilter) { ColumnTupleFilter colFilter = (ColumnTupleFilter) filter; int gtColIdx = mapCol(colFilter.getColumn()); return new ColumnTupleFilter(info.colRef(gtColIdx)); } // encode constants if (useEncodeConstants && filter instanceof CompareTupleFilter) { return encodeConstants((CompareTupleFilter) filter); } return filter; }
Example 2
Source File: StreamingBuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public TupleFilter transform(TupleFilter tupleFilter) { TupleFilter translated = null; if (tupleFilter instanceof CompareTupleFilter) { //normal case translated = translateCompareTupleFilter((CompareTupleFilter) tupleFilter); if (translated != null) { logger.info("Translated {" + tupleFilter + "}"); } } else if (tupleFilter instanceof BuiltInFunctionTupleFilter) { //like case translated = translateFunctionTupleFilter((BuiltInFunctionTupleFilter) tupleFilter); if (translated != null) { logger.info("Translated {" + tupleFilter + "}"); } } else if (tupleFilter instanceof LogicalTupleFilter) { @SuppressWarnings("unchecked") ListIterator<TupleFilter> childIterator = (ListIterator<TupleFilter>) tupleFilter.getChildren() .listIterator(); while (childIterator.hasNext()) { TupleFilter transformed = transform(childIterator.next()); if (transformed != null) childIterator.set(transformed); } } TupleFilter result = translated == null ? tupleFilter : translated; if (result.getOperator() == TupleFilter.FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(result)) { TupleFilter.collectColumns(result, unEvaluableColumns); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!result.isEvaluable()) { TupleFilter.collectColumns(result, unEvaluableColumns); return ConstantTupleFilter.TRUE; } return result; }
Example 3
Source File: FragmentFileSearcher.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@Override public TupleFilter transform(TupleFilter filter) { if (filter.getOperator() == TupleFilter.FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(filter)) { TupleFilter.collectColumns(filter, unEvaluableColumnCollector); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!filter.isEvaluable()) { TupleFilter.collectColumns(filter, unEvaluableColumnCollector); return ConstantTupleFilter.TRUE; } if (filter instanceof CompareTupleFilter) { return translateCompareFilter((CompareTupleFilter) filter); } else if (filter instanceof LogicalTupleFilter) { @SuppressWarnings("unchecked") ListIterator<TupleFilter> childIterator = (ListIterator<TupleFilter>) filter.getChildren().listIterator(); while (childIterator.hasNext()) { TupleFilter transformed = transform(childIterator.next()); if (transformed != null) { childIterator.set(transformed); } else { throw new IllegalStateException("Should not be null"); } } } return filter; }
Example 4
Source File: GTUtil.java From kylin with Apache License 2.0 | 5 votes |
@Override public TupleFilter onSerialize(TupleFilter filter) { if (filter == null) return null; // In case of NOT(unEvaluatableFilter), we should immediately replace it as TRUE, // Otherwise, unEvaluatableFilter will later be replace with TRUE and NOT(unEvaluatableFilter) // will always return FALSE. if (filter.getOperator() == FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(filter)) { TupleFilter.collectColumns(filter, unevaluatableColumnCollector); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!filter.isEvaluable()) { TupleFilter.collectColumns(filter, unevaluatableColumnCollector); return ConstantTupleFilter.TRUE; } // map to column onto grid table if (colMapping != null && filter instanceof ColumnTupleFilter) { ColumnTupleFilter colFilter = (ColumnTupleFilter) filter; int gtColIdx = mapCol(colFilter.getColumn()); return new ColumnTupleFilter(info.colRef(gtColIdx)); } // encode constants if (useEncodeConstants && filter instanceof CompareTupleFilter) { return encodeConstants((CompareTupleFilter) filter); } return filter; }
Example 5
Source File: StreamingBuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 5 votes |
@Override public TupleFilter transform(TupleFilter tupleFilter) { TupleFilter translated = null; if (tupleFilter instanceof CompareTupleFilter) { //normal case translated = translateCompareTupleFilter((CompareTupleFilter) tupleFilter); if (translated != null) { logger.info("Translated {" + tupleFilter + "}"); } } else if (tupleFilter instanceof BuiltInFunctionTupleFilter) { //like case translated = translateFunctionTupleFilter((BuiltInFunctionTupleFilter) tupleFilter); if (translated != null) { logger.info("Translated {" + tupleFilter + "}"); } } else if (tupleFilter instanceof LogicalTupleFilter) { @SuppressWarnings("unchecked") ListIterator<TupleFilter> childIterator = (ListIterator<TupleFilter>) tupleFilter.getChildren() .listIterator(); while (childIterator.hasNext()) { TupleFilter transformed = transform(childIterator.next()); if (transformed != null) childIterator.set(transformed); } } TupleFilter result = translated == null ? tupleFilter : translated; if (result.getOperator() == TupleFilter.FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(result)) { TupleFilter.collectColumns(result, unEvaluableColumns); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!result.isEvaluable()) { TupleFilter.collectColumns(result, unEvaluableColumns); return ConstantTupleFilter.TRUE; } return result; }
Example 6
Source File: FragmentFileSearcher.java From kylin with Apache License 2.0 | 5 votes |
@Override public TupleFilter transform(TupleFilter filter) { if (filter.getOperator() == TupleFilter.FilterOperatorEnum.NOT && !TupleFilter.isEvaluableRecursively(filter)) { TupleFilter.collectColumns(filter, unEvaluableColumnCollector); return ConstantTupleFilter.TRUE; } // shortcut for unEvaluatable filter if (!filter.isEvaluable()) { TupleFilter.collectColumns(filter, unEvaluableColumnCollector); return ConstantTupleFilter.TRUE; } if (filter instanceof CompareTupleFilter) { return translateCompareFilter((CompareTupleFilter) filter); } else if (filter instanceof LogicalTupleFilter) { @SuppressWarnings("unchecked") ListIterator<TupleFilter> childIterator = (ListIterator<TupleFilter>) filter.getChildren().listIterator(); while (childIterator.hasNext()) { TupleFilter transformed = transform(childIterator.next()); if (transformed != null) { childIterator.set(transformed); } else { throw new IllegalStateException("Should not be null"); } } } return filter; }
Example 7
Source File: CubeStorageEngine.java From Kylin with Apache License 2.0 | 5 votes |
private void collectNonEvaluable(TupleFilter filter, Set<TblColRef> collector) { if (filter == null) return; if (filter.isEvaluable()) { for (TupleFilter child : filter.getChildren()) collectNonEvaluable(child, collector); } else { collectColumnsRecursively(filter, collector); } }
Example 8
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 9
Source File: FilterDecorator.java From kylin 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"); } } }