本文整理汇总了Java中org.apache.kylin.metadata.filter.CompareTupleFilter类的典型用法代码示例。如果您正苦于以下问题:Java CompareTupleFilter类的具体用法?Java CompareTupleFilter怎么用?Java CompareTupleFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CompareTupleFilter类属于org.apache.kylin.metadata.filter包,在下文中一共展示了CompareTupleFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: bindVariable
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
private void bindVariable(TupleFilter filter, DataContext dataContext) {
if (filter == null) {
return;
}
for (TupleFilter childFilter : filter.getChildren()) {
bindVariable(childFilter, dataContext);
}
if (filter instanceof CompareTupleFilter && dataContext != null) {
CompareTupleFilter compFilter = (CompareTupleFilter) filter;
for (Map.Entry<String, Object> entry : compFilter.getVariables().entrySet()) {
String variable = entry.getKey();
Object value = dataContext.get(variable);
if (value != null) {
String str = value.toString();
if (compFilter.getColumn().getType().isDateTimeFamily())
str = String.valueOf(DateFormat.stringToMillis(str));
compFilter.bindVariable(variable, str);
}
}
}
}
示例2: buildInFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的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;
}
}
示例3: buildRangeFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的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;
}
示例4: findSingleValueColumns
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected Set<TblColRef> findSingleValueColumns(TupleFilter filter) {
Set<CompareTupleFilter> compareTupleFilterSet = findSingleValuesCompFilters(filter);
// expand derived
Set<TblColRef> resultD = Sets.newHashSet();
for (CompareTupleFilter compFilter : compareTupleFilterSet) {
TblColRef tblColRef = compFilter.getColumn();
if (cubeDesc.isExtendedColumn(tblColRef)) {
throw new CubeDesc.CannotFilterExtendedColumnException(tblColRef);
}
if (cubeDesc.isDerived(compFilter.getColumn())) {
DeriveInfo hostInfo = cubeDesc.getHostInfo(tblColRef);
if (hostInfo.isOneToOne) {
for (TblColRef hostCol : hostInfo.columns) {
resultD.add(hostCol);
}
}
//if not one2one, it will be pruned
} else {
resultD.add(compFilter.getColumn());
}
}
return resultD;
}
示例5: findSingleValuesCompFilters
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
protected Set<CompareTupleFilter> findSingleValuesCompFilters(TupleFilter filter) {
Collection<? extends TupleFilter> toCheck;
if (filter instanceof CompareTupleFilter) {
toCheck = Collections.singleton(filter);
} else if (filter instanceof LogicalTupleFilter && filter.getOperator() == FilterOperatorEnum.AND) {
toCheck = filter.getChildren();
} else {
return (Set<CompareTupleFilter>) Collections.EMPTY_SET;
}
Set<CompareTupleFilter> result = Sets.newHashSet();
for (TupleFilter f : toCheck) {
if (f instanceof CompareTupleFilter) {
CompareTupleFilter compFilter = (CompareTupleFilter) f;
// is COL=const ?
if (compFilter.getOperator() == FilterOperatorEnum.EQ && compFilter.getValues().size() == 1
&& compFilter.getColumn() != null) {
result.add(compFilter);
}
}
}
return result;
}
示例6: translateDerived
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@SuppressWarnings("unchecked")
protected TupleFilter translateDerived(TupleFilter filter, Set<TblColRef> collector) {
if (filter == null)
return filter;
if (filter instanceof CompareTupleFilter) {
return translateDerivedInCompare((CompareTupleFilter) filter, collector);
}
List<TupleFilter> children = (List<TupleFilter>) filter.getChildren();
List<TupleFilter> newChildren = Lists.newArrayListWithCapacity(children.size());
boolean modified = false;
for (TupleFilter child : children) {
TupleFilter translated = translateDerived(child, collector);
newChildren.add(translated);
if (child != translated)
modified = true;
}
if (modified) {
filter = replaceChildren(filter, newChildren);
}
return filter;
}
示例7: translateDerivedInCompare
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
private TupleFilter translateDerivedInCompare(CompareTupleFilter compf, Set<TblColRef> collector) {
if (compf.getColumn() == null)
return compf;
TblColRef derived = compf.getColumn();
if (cubeDesc.isExtendedColumn(derived)) {
throw new CubeDesc.CannotFilterExtendedColumnException(derived);
}
if (cubeDesc.isDerived(derived) == false)
return compf;
DeriveInfo hostInfo = cubeDesc.getHostInfo(derived);
LookupStringTable lookup = cubeDesc.getHostInfo(derived).type == CubeDesc.DeriveType.PK_FK ? null
: getLookupStringTableForDerived(derived, hostInfo);
Pair<TupleFilter, Boolean> translated = DerivedFilterTranslator.translate(lookup, hostInfo, compf);
TupleFilter translatedFilter = translated.getFirst();
boolean loosened = translated.getSecond();
if (loosened) {
collectColumnsRecursively(translatedFilter, collector);
}
return translatedFilter;
}
示例8: verifyScanWithUnevaluatableFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
public void verifyScanWithUnevaluatableFilter() throws IOException {
GTInfo info = table.getInfo();
CompareTupleFilter fComp = compare(info.colRef(0), FilterOperatorEnum.GT, enc(info, 0, "2015-01-14"));
ExtractTupleFilter fUnevaluatable = unevaluatable(info.colRef(1));
LogicalTupleFilter fNotPlusUnevaluatable = not(unevaluatable(info.colRef(1)));
LogicalTupleFilter filter = and(fComp, fUnevaluatable, fNotPlusUnevaluatable);
GTScanRequest req = new GTScanRequestBuilder().setInfo(info).setRanges(null).setDimensions(null)
.setAggrGroupBy(setOf(0)).setAggrMetrics(setOf(3)).setAggrMetricsFuncs(new String[] { "sum" })
.setFilterPushDown(filter).createGTScanRequest();
// note the unEvaluatable column 1 in filter is added to group by
assertEquals(
"GTScanRequest [range=[[null, null]-[null, null]], columns={0, 1, 3}, filterPushDown=AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], [null], [null]], aggrGroupBy={0, 1}, aggrMetrics={3}, aggrMetricsFuncs=[sum]]",
req.toString());
doScanAndVerify(table, useDeserializedGTScanRequest(req), "[1421280000000, 20, null, 20, null]",
"[1421280000000, 30, null, 10, null]", "[1421366400000, 20, null, 20, null]",
"[1421366400000, 30, null, 20, null]", "[1421452800000, 10, null, 10, null]");
}
示例9: verifyScanWithEvaluatableFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
public void verifyScanWithEvaluatableFilter() throws IOException {
GTInfo info = table.getInfo();
CompareTupleFilter fComp1 = compare(info.colRef(0), FilterOperatorEnum.GT, enc(info, 0, "2015-01-14"));
CompareTupleFilter fComp2 = compare(info.colRef(1), FilterOperatorEnum.GT, enc(info, 1, "10"));
LogicalTupleFilter filter = and(fComp1, fComp2);
GTScanRequest req = new GTScanRequestBuilder().setInfo(info).setRanges(null).setDimensions(null)
.setAggrGroupBy(setOf(0)).setAggrMetrics(setOf(3)).setAggrMetricsFuncs(new String[] { "sum" })
.setFilterPushDown(filter).createGTScanRequest();
// note the evaluatable column 1 in filter is added to returned columns but not in group by
assertEquals(
"GTScanRequest [range=[[null, null]-[null, null]], columns={0, 1, 3}, filterPushDown=AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 GT [\\x00]], aggrGroupBy={0}, aggrMetrics={3}, aggrMetricsFuncs=[sum]]",
req.toString());
doScanAndVerify(table, useDeserializedGTScanRequest(req), "[1421280000000, 20, null, 30, null]",
"[1421366400000, 20, null, 40, null]");
}
示例10: testFilterScannerPerf
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
@Ignore
public void testFilterScannerPerf() throws IOException {
GridTable table = newTestPerfTable();
GTInfo info = table.getInfo();
CompareTupleFilter fComp1 = compare(info.colRef(0), FilterOperatorEnum.GT, enc(info, 0, "2015-01-14"));
CompareTupleFilter fComp2 = compare(info.colRef(1), FilterOperatorEnum.GT, enc(info, 1, "10"));
LogicalTupleFilter filter = and(fComp1, fComp2);
FilterResultCache.ENABLED = false;
testFilterScannerPerfInner(table, info, filter);
FilterResultCache.ENABLED = true;
testFilterScannerPerfInner(table, info, filter);
FilterResultCache.ENABLED = false;
testFilterScannerPerfInner(table, info, filter);
FilterResultCache.ENABLED = true;
testFilterScannerPerfInner(table, info, filter);
}
示例11: verifyConvertFilterConstants1
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
public void verifyConvertFilterConstants1() {
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.EQ, "10");
LogicalTupleFilter filter = and(fComp1, fComp2);
List<TblColRef> colMapping = Lists.newArrayList();
colMapping.add(extColA);
colMapping.add(extColB);
TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
assertEquals(
"AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 EQ [\\x00]]",
newFilter.toString());
}
示例12: verifyConvertFilterConstants2
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
public void verifyConvertFilterConstants2() {
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.LT, "9");
LogicalTupleFilter filter = and(fComp1, fComp2);
List<TblColRef> colMapping = Lists.newArrayList();
colMapping.add(extColA);
colMapping.add(extColB);
// $1<"9" round up to $1<"10"
TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
assertEquals(
"AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 LT [\\x00]]",
newFilter.toString());
}
示例13: verifyConvertFilterConstants3
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的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);
}
示例14: verifyConvertFilterConstants4
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的package包/类
@Test
public void verifyConvertFilterConstants4() {
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.IN, "9", "10", "15");
LogicalTupleFilter filter = and(fComp1, fComp2);
List<TblColRef> colMapping = Lists.newArrayList();
colMapping.add(extColA);
colMapping.add(extColB);
// $1 in ("9", "10", "15") has only "10" left
TupleFilter newFilter = GTUtil.convertFilterColumnsAndConstants(filter, info, colMapping, null);
assertEquals(
"AND [UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.0 GT [\\x00\\x00\\x01J\\xE5\\xBD\\x5C\\x00], UNKNOWN_MODEL:NULL.GT_MOCKUP_TABLE.1 IN [\\x00]]",
newFilter.toString());
}
示例15: buildINCompareFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入依赖的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;
}