本文整理汇总了Java中org.apache.kylin.metadata.filter.CompareTupleFilter.getOperator方法的典型用法代码示例。如果您正苦于以下问题:Java CompareTupleFilter.getOperator方法的具体用法?Java CompareTupleFilter.getOperator怎么用?Java CompareTupleFilter.getOperator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.metadata.filter.CompareTupleFilter
的用法示例。
在下文中一共展示了CompareTupleFilter.getOperator方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: translateToAndDimRanges
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
private Collection<ColumnValueRange> translateToAndDimRanges(List<? extends TupleFilter> andFilters, CubeSegment cubeSegment) {
Map<TblColRef, ColumnValueRange> rangeMap = new HashMap<TblColRef, ColumnValueRange>();
for (TupleFilter filter : andFilters) {
if ((filter instanceof CompareTupleFilter) == false) {
continue;
}
CompareTupleFilter comp = (CompareTupleFilter) filter;
if (comp.getColumn() == null) {
continue;
}
ColumnValueRange range = new ColumnValueRange(comp.getColumn(), comp.getValues(), comp.getOperator());
andMerge(range, rangeMap);
}
return rangeMap.values();
}
示例3: evalCompare
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
private ConciseSet evalCompare(CompareTupleFilter filter) {
switch (filter.getOperator()) {
case ISNULL:
return evalCompareIsNull(filter);
case ISNOTNULL:
return evalCompareIsNotNull(filter);
case EQ:
return evalCompareEqual(filter);
case NEQ:
return evalCompareNotEqual(filter);
case IN:
return evalCompareIn(filter);
case NOTIN:
return evalCompareNotIn(filter);
case LT:
return evalCompareLT(filter);
case LTE:
return evalCompareLTE(filter);
case GT:
return evalCompareGT(filter);
case GTE:
return evalCompareGTE(filter);
default:
throw new IllegalStateException("Unsupported operator " + filter.getOperator());
}
}
示例4: translateToAndDimRanges
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
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();
}
示例5: findSingleValueColumns
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private Set<TblColRef> findSingleValueColumns(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<TblColRef>) Collections.EMPTY_SET;
}
Set<TblColRef> 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.getColumn());
}
}
}
// expand derived
Set<TblColRef> resultD = Sets.newHashSet();
for (TblColRef col : result) {
if (cubeDesc.isDerived(col)) {
DeriveInfo hostInfo = cubeDesc.getHostInfo(col);
if (hostInfo.isOneToOne) {
for (TblColRef hostCol : hostInfo.columns) {
resultD.add(hostCol);
}
}
//if not one2one, it will be pruned
} else {
resultD.add(col);
}
}
return resultD;
}
示例6: translateCompareTupleFilter
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
@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();
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;
}
示例7: extractTsConditionInternal
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
private static Range<Long> extractTsConditionInternal(TupleFilter filter, TblColRef colRef) {
if (filter == null) {
return Range.all();
}
if (filter instanceof LogicalTupleFilter) {
if (filter.getOperator() == TupleFilter.FilterOperatorEnum.AND) {
Range<Long> ret = Range.all();
for (TupleFilter child : filter.getChildren()) {
Range childRange = extractTsConditionInternal(child, colRef);
if (childRange != null) {
if (ret.isConnected(childRange) && !ret.intersection(childRange).isEmpty()) {
ret = ret.intersection(childRange);
} else {
return null;
}
} else {
return null;
}
}
return ret.isEmpty() ? null : ret;
} else {
//for conditions like date > DATE'2000-11-11' OR date < DATE '1999-01-01'
//we will use Ranges.all() rather than two ranges to represent them
return Range.all();
}
}
if (filter instanceof CompareTupleFilter) {
CompareTupleFilter compareTupleFilter = (CompareTupleFilter) filter;
if (compareTupleFilter.getColumn() == null)// column will be null at filters like " 1<>1"
return Range.all();
if (compareTupleFilter.getColumn().equals(colRef)) {
Object firstValue = compareTupleFilter.getFirstValue();
long t;
switch (compareTupleFilter.getOperator()) {
case EQ:
t = DateFormat.stringToMillis((String) firstValue);
return Range.closed(t, t);
case LT:
t = DateFormat.stringToMillis((String) firstValue);
return Range.lessThan(t);
case LTE:
t = DateFormat.stringToMillis((String) firstValue);
return Range.atMost(t);
case GT:
t = DateFormat.stringToMillis((String) firstValue);
return Range.greaterThan(t);
case GTE:
t = DateFormat.stringToMillis((String) firstValue);
return Range.atLeast(t);
case NEQ:
case IN://not handled for now
break;
default:
}
}
}
return Range.all();
}
示例8: onSerialize
import org.apache.kylin.metadata.filter.CompareTupleFilter; //导入方法依赖的package包/类
@Override
public TupleFilter onSerialize(TupleFilter filter) {
if (filter == null)
return null;
BuiltInFunctionTransformer translator = new BuiltInFunctionTransformer(dimEncMap);
filter = translator.transform(filter);
// un-evaluatable filter is replaced with TRUE
if (!filter.isEvaluable()) {
TupleFilter.collectColumns(filter, inevaluableColumns);
return ConstantTupleFilter.TRUE;
}
if (!(filter instanceof CompareTupleFilter))
return filter;
// double check all internal of CompareTupleFilter is evaluatable
if (!TupleFilter.isEvaluableRecursively(filter)) {
TupleFilter.collectColumns(filter, inevaluableColumns);
return ConstantTupleFilter.TRUE;
}
if (filterConstantsTreatment == FilterConstantsTreatment.AS_IT_IS) {
return filter;
} else {
// extract ColumnFilter & ConstantFilter
CompareTupleFilter compareFilter = (CompareTupleFilter) filter;
TblColRef col = compareFilter.getColumn();
if (col == null) {
return filter;
}
Collection<String> constValues = (Collection<String>) compareFilter.getValues();
if (constValues == null || constValues.isEmpty()) {
return filter;
}
CompareTupleFilter newCompareFilter = new CompareTupleFilter(compareFilter.getOperator());
newCompareFilter.addChild(new ColumnTupleFilter(col));
if (filterConstantsTreatment == FilterConstantsTreatment.REPLACE_WITH_GLOBAL_DICT) {
return replaceConstantsWithGlobalDict(compareFilter, newCompareFilter);
} else if (filterConstantsTreatment == FilterConstantsTreatment.REPLACE_WITH_LOCAL_DICT) {
return replaceConstantsWithLocalDict(compareFilter, newCompareFilter);
} else {
throw new RuntimeException("should not reach here");
}
}
}