Java Code Examples for org.apache.kylin.metadata.filter.CompareTupleFilter#getFunction()
The following examples show how to use
org.apache.kylin.metadata.filter.CompareTupleFilter#getFunction() .
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: StreamingBuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private TupleFilter translateCompareTupleFilter(CompareTupleFilter compTupleFilter) { if (compTupleFilter.getFunction() == null || (!(compTupleFilter.getFunction() instanceof BuiltInFunctionTupleFilter))) return null; BuiltInFunctionTupleFilter buildInFunctionTupleFilter = (BuiltInFunctionTupleFilter) compTupleFilter .getFunction(); if (!buildInFunctionTupleFilter.isValid()) return null; return new BuildInFuncCompareTupleFilter(compTupleFilter); }
Example 2
Source File: StreamingBuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 5 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private TupleFilter translateCompareTupleFilter(CompareTupleFilter compTupleFilter) { if (compTupleFilter.getFunction() == null || (!(compTupleFilter.getFunction() instanceof BuiltInFunctionTupleFilter))) return null; BuiltInFunctionTupleFilter buildInFunctionTupleFilter = (BuiltInFunctionTupleFilter) compTupleFilter .getFunction(); if (!buildInFunctionTupleFilter.isValid()) return null; return new BuildInFuncCompareTupleFilter(compTupleFilter); }
Example 3
Source File: BuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private TupleFilter translateCompareTupleFilter(CompareTupleFilter compTupleFilter) { if (compTupleFilter.getFunction() == null || (!(compTupleFilter.getFunction() instanceof BuiltInFunctionTupleFilter))) return null; BuiltInFunctionTupleFilter builtInFunctionTupleFilter = (BuiltInFunctionTupleFilter) compTupleFilter .getFunction(); if (!builtInFunctionTupleFilter.isValid()) return null; TblColRef columnRef = builtInFunctionTupleFilter.getColumn(); if (columnRef == null) { return null; } Dictionary<?> dict = dimEncMap.getDictionary(columnRef); if (dict == null) return null; CompareTupleFilter translated = new CompareTupleFilter( builtInFunctionTupleFilter.isReversed() ? FilterOperatorEnum.NOTIN : FilterOperatorEnum.IN); translated.addChild(new ColumnTupleFilter(columnRef)); try { Collection<Object> inValues = Lists.newArrayList(); for (int i = dict.getMinId(); i <= dict.getMaxId(); i++) { Object dictVal = dict.getValueFromId(i); Object computedVal = builtInFunctionTupleFilter.invokeFunction(dictVal); Class clazz = Primitives.wrap(computedVal.getClass()); Object targetVal = compTupleFilter.getFirstValue(); if (Primitives.isWrapperType(clazz)) targetVal = clazz.cast(clazz.getDeclaredMethod("valueOf", String.class).invoke(null, compTupleFilter.getFirstValue())); int comp = ((Comparable) computedVal).compareTo(targetVal); boolean compResult = false; switch (compTupleFilter.getOperator()) { case EQ: compResult = comp == 0; break; case NEQ: compResult = comp != 0; break; case LT: compResult = comp < 0; break; case LTE: compResult = comp <= 0; break; case GT: compResult = comp > 0; break; case GTE: compResult = comp >= 0; break; case IN: compResult = compTupleFilter.getValues().contains(computedVal.toString()); break; case NOTIN: compResult = !compTupleFilter.getValues().contains(computedVal.toString()); break; default: break; } if (compResult) { inValues.add(dictVal); } } translated.addChild(new ConstantTupleFilter(inValues)); } catch (Exception e) { logger.debug(e.getMessage()); return null; } return translated; }
Example 4
Source File: StreamingBuiltInFunctionTransformer.java From kylin-on-parquet-v2 with Apache License 2.0 | 4 votes |
protected BuildInFuncCompareTupleFilter(CompareTupleFilter delegate) { super(new ArrayList<>(delegate.getChildren()), delegate.getOperator()); this.delegate = delegate; this.buildInFunctionTupleFilter = (BuiltInFunctionTupleFilter) delegate.getFunction(); }
Example 5
Source File: BuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 4 votes |
@SuppressWarnings({ "unchecked", "rawtypes" }) private TupleFilter translateCompareTupleFilter(CompareTupleFilter compTupleFilter) { if (compTupleFilter.getFunction() == null || (!(compTupleFilter.getFunction() instanceof BuiltInFunctionTupleFilter))) return null; BuiltInFunctionTupleFilter builtInFunctionTupleFilter = (BuiltInFunctionTupleFilter) compTupleFilter .getFunction(); if (!builtInFunctionTupleFilter.isValid()) return null; TblColRef columnRef = builtInFunctionTupleFilter.getColumn(); if (columnRef == null) { return null; } Dictionary<?> dict = dimEncMap.getDictionary(columnRef); if (dict == null) return null; CompareTupleFilter translated = new CompareTupleFilter( builtInFunctionTupleFilter.isReversed() ? FilterOperatorEnum.NOTIN : FilterOperatorEnum.IN); translated.addChild(new ColumnTupleFilter(columnRef)); try { Collection<Object> inValues = Lists.newArrayList(); for (int i = dict.getMinId(); i <= dict.getMaxId(); i++) { Object dictVal = dict.getValueFromId(i); Object computedVal = builtInFunctionTupleFilter.invokeFunction(dictVal); Class clazz = Primitives.wrap(computedVal.getClass()); Object targetVal = compTupleFilter.getFirstValue(); if (Primitives.isWrapperType(clazz)) targetVal = clazz.cast(clazz.getDeclaredMethod("valueOf", String.class).invoke(null, compTupleFilter.getFirstValue())); int comp = ((Comparable) computedVal).compareTo(targetVal); boolean compResult = false; switch (compTupleFilter.getOperator()) { case EQ: compResult = comp == 0; break; case NEQ: compResult = comp != 0; break; case LT: compResult = comp < 0; break; case LTE: compResult = comp <= 0; break; case GT: compResult = comp > 0; break; case GTE: compResult = comp >= 0; break; case IN: compResult = compTupleFilter.getValues().contains(computedVal.toString()); break; case NOTIN: compResult = !compTupleFilter.getValues().contains(computedVal.toString()); break; default: break; } if (compResult) { inValues.add(dictVal); } } translated.addChild(new ConstantTupleFilter(inValues)); } catch (Exception e) { logger.debug(e.getMessage()); return null; } return translated; }
Example 6
Source File: StreamingBuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 4 votes |
protected BuildInFuncCompareTupleFilter(CompareTupleFilter delegate) { super(new ArrayList<>(delegate.getChildren()), delegate.getOperator()); this.delegate = delegate; this.buildInFunctionTupleFilter = (BuiltInFunctionTupleFilter) delegate.getFunction(); }