Java Code Examples for org.apache.kylin.metadata.filter.TupleFilter#evaluate()
The following examples show how to use
org.apache.kylin.metadata.filter.TupleFilter#evaluate() .
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: StreamingDataQueryPlanner.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
private boolean canSkipForAndFilter(TupleFilter andFilter, CompareFilterTimeRangeChecker timeRangeChecker) { for (TupleFilter filter : andFilter.getChildren()) { if (!(filter instanceof CompareTupleFilter)) { if (filter instanceof ConstantTupleFilter && !filter.evaluate(null, null)) { return true; } else { continue; } } CompareTupleFilter comp = (CompareTupleFilter) filter; TblColRef column = comp.getColumn(); if (column == null || !TimeDerivedColumnType.isTimeDerivedColumn(column.getName())) { continue; } TimeDerivedColumnType timeDerivedColumnType = TimeDerivedColumnType.getTimeDerivedColumnType(column .getName()); CheckResult checkResult = timeRangeChecker.check(comp, timeDerivedColumnType, timezoneOffset); if (checkResult == CheckResult.EXCLUDED) { return true; } else { continue; } } return false; }
Example 2
Source File: StreamingBuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public boolean evaluate(IEvaluatableTuple tuple, IFilterCodeSystem cs) { // extract tuple value Object tupleValue = null; for (TupleFilter filter : this.children) { if (!isConstant(filter)) { filter.evaluate(tuple, cs); tupleValue = filter.getValues().iterator().next(); } } if (tupleValue == null || cs.isNull(tupleValue)) { return false; } try { return (Boolean) buildInFunctionTupleFilter.invokeFunction(tupleValue); } catch (Exception e) { logger.error("error when invoke build in function", e); return false; } }
Example 3
Source File: StreamingDataQueryPlanner.java From kylin with Apache License 2.0 | 6 votes |
private boolean canSkipForAndFilter(TupleFilter andFilter, CompareFilterTimeRangeChecker timeRangeChecker) { for (TupleFilter filter : andFilter.getChildren()) { if (!(filter instanceof CompareTupleFilter)) { if (filter instanceof ConstantTupleFilter && !filter.evaluate(null, null)) { return true; } else { continue; } } CompareTupleFilter comp = (CompareTupleFilter) filter; TblColRef column = comp.getColumn(); if (column == null || !TimeDerivedColumnType.isTimeDerivedColumn(column.getName())) { continue; } TimeDerivedColumnType timeDerivedColumnType = TimeDerivedColumnType.getTimeDerivedColumnType(column .getName()); CheckResult checkResult = timeRangeChecker.check(comp, timeDerivedColumnType, timezoneOffset); if (checkResult == CheckResult.EXCLUDED) { return true; } else { continue; } } return false; }
Example 4
Source File: StreamingBuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 6 votes |
@Override public boolean evaluate(IEvaluatableTuple tuple, IFilterCodeSystem cs) { // extract tuple value Object tupleValue = null; for (TupleFilter filter : this.children) { if (!isConstant(filter)) { filter.evaluate(tuple, cs); tupleValue = filter.getValues().iterator().next(); } } if (tupleValue == null || cs.isNull(tupleValue)) { return false; } try { return (Boolean) buildInFunctionTupleFilter.invokeFunction(tupleValue); } catch (Exception e) { logger.error("error when invoke build in function", e); return false; } }
Example 5
Source File: FilterBaseTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
protected int evaluateTuples(Collection<Tuple> tuples, TupleFilter filter) { int match = 0; for (Tuple t : tuples) { if (filter.evaluate(t, CS)) { match++; } } return match; }
Example 6
Source File: ScanRangePlannerBase.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
private Collection<ColumnRange> translateToAndDimRanges(List<? extends TupleFilter> andFilters) { Map<TblColRef, ColumnRange> rangeMap = new HashMap<TblColRef, ColumnRange>(); for (TupleFilter filter : andFilters) { if ((filter instanceof CompareTupleFilter) == false) { if (filter instanceof ConstantTupleFilter && !filter.evaluate(null, null)) { return null; } else { continue; } } CompareTupleFilter comp = (CompareTupleFilter) filter; if (comp.getColumn() == null) { continue; } @SuppressWarnings("unchecked") ColumnRange newRange = new ColumnRange(comp.getColumn(), (Set<ByteArray>) comp.getValues(), comp.getOperator()); ColumnRange existing = rangeMap.get(newRange.column); if (existing == null) { rangeMap.put(newRange.column, newRange); } else { existing.andMerge(newRange); } } return rangeMap.values(); }
Example 7
Source File: FilterBaseTest.java From kylin with Apache License 2.0 | 5 votes |
protected int evaluateTuples(Collection<Tuple> tuples, TupleFilter filter) { int match = 0; for (Tuple t : tuples) { if (filter.evaluate(t, CS)) { match++; } } return match; }
Example 8
Source File: ScanRangePlannerBase.java From kylin with Apache License 2.0 | 5 votes |
private Collection<ColumnRange> translateToAndDimRanges(List<? extends TupleFilter> andFilters) { Map<TblColRef, ColumnRange> rangeMap = new HashMap<TblColRef, ColumnRange>(); for (TupleFilter filter : andFilters) { if ((filter instanceof CompareTupleFilter) == false) { if (filter instanceof ConstantTupleFilter && !filter.evaluate(null, null)) { return null; } else { continue; } } CompareTupleFilter comp = (CompareTupleFilter) filter; if (comp.getColumn() == null) { continue; } @SuppressWarnings("unchecked") ColumnRange newRange = new ColumnRange(comp.getColumn(), (Set<ByteArray>) comp.getValues(), comp.getOperator()); ColumnRange existing = rangeMap.get(newRange.column); if (existing == null) { rangeMap.put(newRange.column, newRange); } else { existing.andMerge(newRange); } } return rangeMap.values(); }
Example 9
Source File: StreamingBuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@Override public boolean evaluate(IEvaluatableTuple tuple, IFilterCodeSystem cs) { // extract tuple value Object tupleValue = null; for (TupleFilter filter : this.buildInFunctionTupleFilter.getChildren()) { if (!isConstant(filter)) { filter.evaluate(tuple, cs); tupleValue = filter.getValues().iterator().next(); } } // consider null case if (cs.isNull(tupleValue)) { if (operator == FilterOperatorEnum.ISNULL) return true; else return false; } if (operator == FilterOperatorEnum.ISNOTNULL) { return true; } if (delegate.getFirstValue() == null || cs.isNull(delegate.getFirstValue())) { return false; } // tricky here -- order is ensured by string compare (even for number columns) // because it's row key ID (not real value) being compared Object computedVal = tupleValue; try { computedVal = buildInFunctionTupleFilter.invokeFunction(tupleValue); } catch (Exception e) { logger.error("exception when invoke buildIn function", e); } int comp = cs.compare(computedVal, delegate.getFirstValue()); boolean result; switch (operator) { case EQ: result = comp == 0; break; case NEQ: result = comp != 0; break; case LT: result = comp < 0; break; case LTE: result = comp <= 0; break; case GT: result = comp > 0; break; case GTE: result = comp >= 0; break; case IN: result = delegate.getValues().contains(computedVal); break; case NOTIN: result = !delegate.getValues().contains(computedVal); break; default: result = false; } return result; }
Example 10
Source File: StreamingBuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 4 votes |
@Override public boolean evaluate(IEvaluatableTuple tuple, IFilterCodeSystem cs) { // extract tuple value Object tupleValue = null; for (TupleFilter filter : this.buildInFunctionTupleFilter.getChildren()) { if (!isConstant(filter)) { filter.evaluate(tuple, cs); tupleValue = filter.getValues().iterator().next(); } } // consider null case if (cs.isNull(tupleValue)) { if (operator == FilterOperatorEnum.ISNULL) return true; else return false; } if (operator == FilterOperatorEnum.ISNOTNULL) { return true; } if (delegate.getFirstValue() == null || cs.isNull(delegate.getFirstValue())) { return false; } // tricky here -- order is ensured by string compare (even for number columns) // because it's row key ID (not real value) being compared Object computedVal = tupleValue; try { computedVal = buildInFunctionTupleFilter.invokeFunction(tupleValue); } catch (Exception e) { logger.error("exception when invoke buildIn function", e); } int comp = cs.compare(computedVal, delegate.getFirstValue()); boolean result; switch (operator) { case EQ: result = comp == 0; break; case NEQ: result = comp != 0; break; case LT: result = comp < 0; break; case LTE: result = comp <= 0; break; case GT: result = comp > 0; break; case GTE: result = comp >= 0; break; case IN: result = delegate.getValues().contains(computedVal); break; case NOTIN: result = !delegate.getValues().contains(computedVal); break; default: result = false; } return result; }