当前位置: 首页>>代码示例>>Java>>正文


Java ConstantTupleFilter类代码示例

本文整理汇总了Java中org.apache.kylin.metadata.filter.ConstantTupleFilter的典型用法代码示例。如果您正苦于以下问题:Java ConstantTupleFilter类的具体用法?Java ConstantTupleFilter怎么用?Java ConstantTupleFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ConstantTupleFilter类属于org.apache.kylin.metadata.filter包,在下文中一共展示了ConstantTupleFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: visitLiteral

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
@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));
        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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:OLAPFilterRel.java

示例2: buildInFilter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:27,代码来源:DerivedFilterTranslator.java

示例3: buildRangeFilter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:19,代码来源:DerivedFilterTranslator.java

示例4: verifyConvertFilterConstants3

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
@Test
public void verifyConvertFilterConstants3() {
    GTInfo info = table.getInfo();

    TableDesc extTable = TableDesc.mockup("ext");
    TblColRef extColA = TblColRef.mockup(extTable, 1, "A", "timestamp");
    TblColRef extColB = TblColRef.mockup(extTable, 2, "B", "integer");

    CompareTupleFilter fComp1 = compare(extColA, FilterOperatorEnum.GT, "2015-01-14");
    CompareTupleFilter fComp2 = compare(extColB, FilterOperatorEnum.LTE, "9");
    LogicalTupleFilter filter = and(fComp1, fComp2);

    List<TblColRef> colMapping = Lists.newArrayList();
    colMapping.add(extColA);
    colMapping.add(extColB);

    // $1<="9" round down to FALSE
    TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
    assertEquals(ConstantTupleFilter.FALSE, newFilter);
}
 
开发者ID:apache,项目名称:kylin,代码行数:21,代码来源:DictGridTableTest.java

示例5: buildINCompareFilter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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");
    Date startDate = simpleDateFormat.parse("1970-01-01");
    Date endDate = simpleDateFormat.parse("2100-01-01");
    Calendar start = Calendar.getInstance();
    start.setTime(startDate);
    Calendar end = Calendar.getInstance();
    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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:22,代码来源:FilterBaseTest.java

示例6: visitLiteral

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
@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;
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:21,代码来源:OLAPFilterRel.java

示例7: setup

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
@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();
}
 
开发者ID:KylinOLAP,项目名称:Kylin,代码行数:23,代码来源:EndpointAggregationTest.java

示例8: mergeToInClause

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
CompareTupleFilter mergeToInClause(TupleFilter filter) {
    List<? extends TupleFilter> children = filter.getChildren();
    TblColRef inColumn = null;
    List<Object> inValues = new LinkedList<Object>();
    Map<String, Object> dynamicVariables = new HashMap<>();
    for (TupleFilter child : children) {
        if (child.getOperator() == FilterOperatorEnum.EQ) {
            CompareTupleFilter compFilter = (CompareTupleFilter) child;
            TblColRef column = compFilter.getColumn();
            if (inColumn == null) {
                inColumn = column;
            }

            if (column == null || !column.equals(inColumn)) {
                return null;
            }
            inValues.addAll(compFilter.getValues());
            dynamicVariables.putAll(compFilter.getVariables());
        } else {
            return null;
        }
    }

    children.clear();

    CompareTupleFilter inFilter = new CompareTupleFilter(FilterOperatorEnum.IN);
    inFilter.addChild(new ColumnTupleFilter(inColumn));
    inFilter.addChild(new ConstantTupleFilter(inValues));
    inFilter.getVariables().putAll(dynamicVariables);
    return inFilter;
}
 
开发者ID:apache,项目名称:kylin,代码行数:32,代码来源:OLAPFilterRel.java

示例9: addChild

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:apache,项目名称:kylin,代码行数:28,代码来源:MassInTupleFilter.java

示例10: translateFunctionTupleFilter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:33,代码来源:BuiltInFunctionTransformer.java

示例11: buildTs2010Filter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:StorageMockUtils.java

示例12: buildTs2011Filter

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:StorageMockUtils.java

示例13: buildFilter1

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:StorageMockUtils.java

示例14: buildFilter2

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:StorageMockUtils.java

示例15: buildFilter3

import org.apache.kylin.metadata.filter.ConstantTupleFilter; //导入依赖的package包/类
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;
}
 
开发者ID:apache,项目名称:kylin,代码行数:9,代码来源:StorageMockUtils.java


注:本文中的org.apache.kylin.metadata.filter.ConstantTupleFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。