org.apache.kylin.metadata.filter.ConstantTupleFilter Java Examples
The following examples show how to use
org.apache.kylin.metadata.filter.ConstantTupleFilter.
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: TupleFilterVisitor.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Override public TupleFilter visitLiteral(RexLiteral literal) { String strValue = null; Object literalValue = literal.getValue(); if (literalValue instanceof NlsString) { strValue = ((NlsString) literalValue).getValue(); } else if (literalValue instanceof GregorianCalendar) { GregorianCalendar g = (GregorianCalendar) literalValue; strValue = Long.toString(g.getTimeInMillis()); } else if (literalValue instanceof TimeUnitRange) { // Extract(x from y) in where clause strValue = ((TimeUnitRange) literalValue).name(); } else if (literalValue == null) { strValue = null; } else { strValue = literalValue.toString(); } TupleFilter filter = new ConstantTupleFilter(strValue); return filter; }
Example #2
Source File: EndpointAggregationTest.java From Kylin with Apache License 2.0 | 6 votes |
@Before public void setup() throws IOException { this.createTestMetadata(); this.ii = IIManager.getInstance(getTestConfig()).getII("test_kylin_ii"); this.tableRecordInfo = new TableRecordInfo(ii.getFirstSegment()); factTableDesc = MetadataManager.getInstance(getTestConfig()).getTableDesc("DEFAULT.TEST_KYLIN_FACT"); TblColRef formatName = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "LSTG_FORMAT_NAME"); TblColRef siteId = this.ii.getDescriptor().findColumnRef("DEFAULT.TEST_KYLIN_FACT", "LSTG_SITE_ID"); Collection<TblColRef> dims = new HashSet<>(); dims.add(formatName); projector = CoprocessorProjector.makeForEndpoint(tableRecordInfo, dims); aggregators = EndpointAggregators.fromFunctions(tableRecordInfo, buildAggregations()); CompareTupleFilter rawFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); rawFilter.addChild(new ColumnTupleFilter(siteId)); rawFilter.addChild(new ConstantTupleFilter("0")); filter = CoprocessorFilter.fromFilter(this.ii.getFirstSegment(), rawFilter); aggCache = new EndpointAggregationCache(aggregators); tableData = mockTable(); }
Example #3
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 #4
Source File: SegmentPrunerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Test public void testPruneSegWithFilterIN() { // legacy cube segments does not have DimensionRangeInfo, but with TSRange can do some pruning CubeInstance cube = CubeManager.getInstance(getTestConfig()) .getCube("test_kylin_cube_without_slr_left_join_ready_2_segments"); TblColRef col = cube.getModel().findColumn("TEST_KYLIN_FACT.CAL_DT"); CubeSegment seg = cube.getSegments(SegmentStatusEnum.READY).get(0); TSRange tsRange = seg.getTSRange(); String start = DateFormat.formatToTimeStr(tsRange.start.v, "yyyy-MM-dd"); CubeSegment seg2 = cube.getSegments(SegmentStatusEnum.READY).get(1); TSRange tsRange2 = seg2.getTSRange(); try (SetAndUnsetSystemProp sns = new SetAndUnsetSystemProp("kylin.query.skip-empty-segments", "false")) { { TupleFilter inFilter = new ConstantTupleFilter(Sets.newHashSet(start, DateFormat.formatToTimeStr(tsRange2.end.v + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"))); TupleFilter filter = compare(col, FilterOperatorEnum.IN, inFilter); SegmentPruner segmentPruner = new SegmentPruner(filter); Assert.assertTrue(segmentPruner.check(seg)); Assert.assertFalse(segmentPruner.check(seg2)); } } }
Example #5
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 #6
Source File: FilterBaseTest.java From kylin-on-parquet-v2 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 #7
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 #8
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 #9
Source File: TupleExpressionSerializerTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testSerialization() { TblColRef colD = TblColRef.mockup(t, 1, "C1", "string"); TblColRef colM = TblColRef.mockup(t, 2, "C2", "decimal"); BigDecimal value = BigDecimal.valueOf(10L); ColumnTupleFilter colFilter = new ColumnTupleFilter(colD); ConstantTupleFilter constFilter = new ConstantTupleFilter("col"); CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); compareFilter.addChild(colFilter); compareFilter.addChild(constFilter); ColumnTupleExpression colTuple = new ColumnTupleExpression(colM); ConstantTupleExpression constTuple = new ConstantTupleExpression(value); Pair<TupleFilter, TupleExpression> whenEntry = new Pair<TupleFilter, TupleExpression>(compareFilter, colTuple); CaseTupleExpression caseTuple = new CaseTupleExpression(Lists.newArrayList(whenEntry), constTuple); byte[] result = TupleExpressionSerializer.serialize(caseTuple, StringCodeSystem.INSTANCE); TupleExpression desTuple = TupleExpressionSerializer.deserialize(result, StringCodeSystem.INSTANCE); assertEquals(caseTuple, desTuple); }
Example #10
Source File: SegmentPrunerTest.java From kylin with Apache License 2.0 | 6 votes |
@Test public void testPruneSegWithFilterIN() { // legacy cube segments does not have DimensionRangeInfo, but with TSRange can do some pruning CubeInstance cube = CubeManager.getInstance(getTestConfig()) .getCube("test_kylin_cube_without_slr_left_join_ready_2_segments"); TblColRef col = cube.getModel().findColumn("TEST_KYLIN_FACT.CAL_DT"); CubeSegment seg = cube.getSegments(SegmentStatusEnum.READY).get(0); TSRange tsRange = seg.getTSRange(); String start = DateFormat.formatToTimeStr(tsRange.start.v, "yyyy-MM-dd"); CubeSegment seg2 = cube.getSegments(SegmentStatusEnum.READY).get(1); TSRange tsRange2 = seg2.getTSRange(); try (SetAndUnsetSystemProp sns = new SetAndUnsetSystemProp("kylin.query.skip-empty-segments", "false")) { { TupleFilter inFilter = new ConstantTupleFilter(Sets.newHashSet(start, DateFormat.formatToTimeStr(tsRange2.end.v + 1000 * 60 * 60 * 24L, "yyyy-MM-dd"))); TupleFilter filter = compare(col, FilterOperatorEnum.IN, inFilter); SegmentPruner segmentPruner = new SegmentPruner(filter); Assert.assertTrue(segmentPruner.check(seg)); Assert.assertFalse(segmentPruner.check(seg2)); } } }
Example #11
Source File: InvertIndexSearcher.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
public EvalResult doEval(TupleFilter filter) { if (filter == null) return EvalResult.ALL_MATCH; if (filter instanceof LogicalTupleFilter) return doEvalLogical((LogicalTupleFilter) filter); if (filter instanceof CompareTupleFilter) return doEvalCompare((CompareTupleFilter) filter); if (filter instanceof ConstantTupleFilter) { if (filter.getValues().size() == 0) { return new EvalResult(); } else if (filter.getValues().size() > 0) { return EvalResult.ALL_MATCH; } } return EvalResult.ALL_MATCH; // unable to evaluate }
Example #12
Source File: InvertIndexSearcher.java From kylin with Apache License 2.0 | 6 votes |
public EvalResult doEval(TupleFilter filter) { if (filter == null) return EvalResult.ALL_MATCH; if (filter instanceof LogicalTupleFilter) return doEvalLogical((LogicalTupleFilter) filter); if (filter instanceof CompareTupleFilter) return doEvalCompare((CompareTupleFilter) filter); if (filter instanceof ConstantTupleFilter) { if (filter.getValues().size() == 0) { return new EvalResult(); } else if (filter.getValues().size() > 0) { return EvalResult.ALL_MATCH; } } return EvalResult.ALL_MATCH; // unable to evaluate }
Example #13
Source File: TupleExpressionSerializerTest.java From kylin-on-parquet-v2 with Apache License 2.0 | 6 votes |
@Test public void testSerialization() { TblColRef colD = TblColRef.mockup(t, 1, "C1", "decimal"); TblColRef colM = TblColRef.mockup(t, 2, "C2", "string"); BigDecimal value = BigDecimal.valueOf(10L); ColumnTupleFilter colFilter = new ColumnTupleFilter(colD); ConstantTupleFilter constFilter = new ConstantTupleFilter("col"); CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.EQ); compareFilter.addChild(colFilter); compareFilter.addChild(constFilter); ColumnTupleExpression colTuple = new ColumnTupleExpression(colM); NumberTupleExpression constTuple = new NumberTupleExpression(value); Pair<TupleFilter, TupleExpression> whenEntry = new Pair<TupleFilter, TupleExpression>(compareFilter, colTuple); CaseTupleExpression caseTuple = new CaseTupleExpression(Lists.newArrayList(whenEntry), constTuple); byte[] result = TupleExpressionSerializer.serialize(caseTuple, StringCodeSystem.INSTANCE); TupleExpression desTuple = TupleExpressionSerializer.deserialize(result, StringCodeSystem.INSTANCE); assertEquals(caseTuple, desTuple); }
Example #14
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 #15
Source File: OLAPFilterRel.java From Kylin with Apache License 2.0 | 6 votes |
@Override public TupleFilter visitLiteral(RexLiteral literal) { String strValue = null; Object literalValue = literal.getValue(); if (literalValue instanceof NlsString) { strValue = ((NlsString) literalValue).getValue(); } else if (literalValue instanceof GregorianCalendar) { GregorianCalendar g = (GregorianCalendar) literalValue; strValue = "" + g.get(Calendar.YEAR) + "-" + normToTwoDigits(g.get(Calendar.MONTH) + 1) + "-" + normToTwoDigits(g.get(Calendar.DAY_OF_MONTH)); } else if (literalValue instanceof SqlFunctions.TimeUnitRange) { // Extract(x from y) in where clause strValue = ((SqlFunctions.TimeUnitRange) literalValue).name(); } else if (literalValue == null) { strValue = null; } else { strValue = literalValue.toString(); } TupleFilter filter = new ConstantTupleFilter(strValue); return filter; }
Example #16
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 #17
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 #18
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 #19
Source File: BuiltInFunctionTransformer.java From kylin with Apache License 2.0 | 5 votes |
private TupleFilter translateFunctionTupleFilter(BuiltInFunctionTupleFilter builtInFunctionTupleFilter) { if (!builtInFunctionTupleFilter.isValid()) return null; TblColRef columnRef = builtInFunctionTupleFilter.getColumn(); 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 { int translatedInClauseMaxSize = KylinConfig.getInstanceFromEnv().getTranslatedInClauseMaxSize(); for (int i = dict.getMinId(); i <= dict.getMaxId(); i++) { Object dictVal = dict.getValueFromId(i); if ((Boolean) builtInFunctionTupleFilter.invokeFunction(dictVal)) { translated.addChild(new ConstantTupleFilter(dictVal)); if (translated.getChildren().size() > translatedInClauseMaxSize) { return null; } } } logger.debug("getting a in clause with {} children", translated.getChildren().size()); } catch (Exception e) { logger.debug(e.getMessage()); return null; } return translated; }
Example #20
Source File: StorageMockUtils.java From kylin with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildTs2010Filter(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT); ColumnTupleFilter columnFilter1 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter1); ConstantTupleFilter constantFilter1 = new ConstantTupleFilter("2010-01-01"); compareFilter.addChild(constantFilter1); return compareFilter; }
Example #21
Source File: MassInTupleFilter.java From kylin with Apache License 2.0 | 5 votes |
@Override public void addChild(TupleFilter child) { if (child instanceof ColumnTupleFilter) { super.addChild(child); ColumnTupleFilter columnFilter = (ColumnTupleFilter) child; if (this.column != null) { throw new IllegalStateException("Duplicate columns! old is " + column.getName() + " and new is " + columnFilter.getColumn().getName()); } this.column = columnFilter.getColumn(); } else if (child instanceof ConstantTupleFilter) { // super.addChild(child) is omitted because the filter table name is useless at storage side, // we'll extract the useful filterTableResourceIdentifier,filterTableType etc and save it at the MassInTupleFilter itself if (filterTableName == null) { filterTableName = (String) child.getValues().iterator().next(); ExternalFilterDesc externalFilterDesc = TableMetadataManager.getInstance(KylinConfig.getInstanceFromEnv()).getExtFilterDesc(filterTableName); if (externalFilterDesc == null) { throw new IllegalArgumentException("External filter named " + filterTableName + " is not found"); } filterTableType = externalFilterDesc.getFilterTableType(); filterTableResourceIdentifier = externalFilterDesc.getFilterResourceIdentifier(); } } else { throw new IllegalStateException("MassInTupleFilter only has two children: one ColumnTupleFilter and one ConstantTupleFilter"); } }
Example #22
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 #23
Source File: OLAPAggregateRel.java From kylin with Apache License 2.0 | 5 votes |
private TupleFilter getIsNotNullFilterFromExpression(TupleExpression tupleExpr) { TupleFilter filter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.ISNOTNULL); if (tupleExpr instanceof ColumnTupleExpression) { filter.addChild(new ColumnTupleFilter(((ColumnTupleExpression) tupleExpr).getColumn())); } else if (tupleExpr instanceof ConstantTupleExpression) { filter.addChild(new ConstantTupleFilter(((ConstantTupleExpression) tupleExpr).getValue())); } else { logger.warn("Cannot get IsNullFilter from Expression {}", tupleExpr); filter = null; } return filter; }
Example #24
Source File: StorageMockUtils.java From kylin with Apache License 2.0 | 5 votes |
public CompareTupleFilter buildTs2011Filter(TblColRef column) { CompareTupleFilter compareFilter = new CompareTupleFilter(TupleFilter.FilterOperatorEnum.GT); ColumnTupleFilter columnFilter1 = new ColumnTupleFilter(column); compareFilter.addChild(columnFilter1); ConstantTupleFilter constantFilter1 = new ConstantTupleFilter("2011-01-01"); compareFilter.addChild(constantFilter1); return compareFilter; }
Example #25
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 #26
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 #27
Source File: GTScannerBenchmark2.java From kylin 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 #28
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 #29
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 #30
Source File: GTScannerBenchmark.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; }