本文整理汇总了Java中org.apache.kylin.metadata.model.FunctionDesc类的典型用法代码示例。如果您正苦于以下问题:Java FunctionDesc类的具体用法?Java FunctionDesc怎么用?Java FunctionDesc使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FunctionDesc类属于org.apache.kylin.metadata.model包,在下文中一共展示了FunctionDesc类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMeasureSum
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public static MeasureDesc getMeasureSum(String column, String dataType) {
ParameterDesc parameterDesc = new ParameterDesc();
parameterDesc.setValue(column);
parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_COLUMN);
FunctionDesc function = new FunctionDesc();
function.setExpression(FunctionDesc.FUNC_SUM);
function.setParameter(parameterDesc);
function.setReturnType(dataType.equals(HiveTableCreator.HiveTypeEnum.HDOUBLE.toString())
? HiveTableCreator.HiveTypeEnum.HDECIMAL.toString()
: dataType);
MeasureDesc result = new MeasureDesc();
result.setName(column + "_SUM");
result.setFunction(function);
return result;
}
示例2: adjustSqlDigest
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
@Override
public void adjustSqlDigest(List<MeasureDesc> measureDescs, SQLDigest sqlDigest) {
for (MeasureDesc measureDesc : measureDescs) {
if (!sqlDigest.involvedMeasure.contains(measureDesc)) {
continue;
}
FunctionDesc extendColumnFunc = measureDesc.getFunction();
List<TblColRef> hosts = getExtendedColumnHosts(extendColumnFunc);
TblColRef extended = getExtendedColumn(extendColumnFunc);
if (!sqlDigest.groupbyColumns.contains(extended)) {
continue;
}
sqlDigest.aggregations.add(extendColumnFunc);
sqlDigest.groupbyColumns.remove(extended);
sqlDigest.groupbyColumns.addAll(hosts);
sqlDigest.metricColumns.add(extended);
}
}
示例3: influenceCapabilityCheck
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
@Override
public CapabilityResult.CapabilityInfluence influenceCapabilityCheck(Collection<TblColRef> unmatchedDimensions, Collection<FunctionDesc> unmatchedAggregations, SQLDigest digest, final MeasureDesc measureDesc) {
TblColRef extendedCol = getExtendedColumn(measureDesc.getFunction());
if (!unmatchedDimensions.contains(extendedCol)) {
return null;
}
if (digest.filterColumns.contains(extendedCol)) {
return null;
}
unmatchedDimensions.remove(extendedCol);
return new CapabilityResult.CapabilityInfluence() {
@Override
public double suggestCostMultiplier() {
return 0.9;
}
@Override
public MeasureDesc getInvolvedMeasure() {
return measureDesc;
}
};
}
示例4: validate
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
@Override
public void validate(FunctionDesc functionDesc) throws IllegalArgumentException {
DataType rtype = dataType;
if (funcName.equals(FunctionDesc.FUNC_SUM)) {
if (rtype.isNumberFamily() == false) {
throw new IllegalArgumentException("Return type for function " + funcName + " must be one of " + DataType.NUMBER_FAMILY);
}
} else if (funcName.equals(FunctionDesc.FUNC_COUNT)) {
if (rtype.isIntegerFamily() == false) {
throw new IllegalArgumentException("Return type for function " + funcName + " must be one of " + DataType.INTEGER_FAMILY);
}
} else if (funcName.equals(FunctionDesc.FUNC_MAX) || funcName.equals(FunctionDesc.FUNC_MIN)) {
if (rtype.isNumberFamily() == false) {
throw new IllegalArgumentException("Return type for function " + funcName + " must be one of " + DataType.NUMBER_FAMILY);
}
} else {
KylinConfig config = KylinConfig.getInstanceFromEnv();
if (config.isQueryIgnoreUnknownFunction() == false)
throw new IllegalArgumentException("Unrecognized function: [" + funcName + "]");
}
}
示例5: registerUDAF
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
private static void registerUDAF(MeasureTypeFactory<?> factory) {
MeasureType<?> type = factory.createMeasureType(factory.getAggrFunctionName(),
DataType.getType(factory.getAggrDataTypeName()));
Map<String, Class<?>> udafs = type.getRewriteCalciteAggrFunctions();
if (type.needRewrite() == false || udafs == null)
return;
for (String udaf : udafs.keySet()) {
udaf = udaf.toUpperCase();
if (udaf.equals(FunctionDesc.FUNC_COUNT_DISTINCT))
continue; // skip built-in function
if (udafFactories.containsKey(udaf))
throw new IllegalStateException(
"UDAF '" + udaf + "' was dup declared by " + udafFactories.get(udaf) + " and " + factory);
udafFactories.put(udaf, factory);
udafMap.put(udaf, udafs.get(udaf));
}
}
示例6: isTopNCompatibleSum
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
private boolean isTopNCompatibleSum(FunctionDesc topN, FunctionDesc sum) {
if (sum == null)
return false;
if (!isTopN(topN))
return false;
TblColRef topnNumCol = getTopNNumericColumn(topN);
if (topnNumCol == null) {
if (sum.isCount())
return true;
return false;
}
if (sum.isSum() == false)
return false;
if (sum.getParameter() == null || sum.getParameter().getColRefs() == null
|| sum.getParameter().getColRefs().size() == 0)
return false;
TblColRef sumCol = sum.getParameter().getColRefs().get(0);
return sumCol.equals(topnNumCol);
}
示例7: influenceCapabilityCheck
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public CapabilityResult.CapabilityInfluence influenceCapabilityCheck(Collection<TblColRef> unmatchedDimensions, Collection<FunctionDesc> unmatchedAggregations, SQLDigest digest, final MeasureDesc measureDesc) {
//is raw query
if (!digest.isRawQuery)
return null;
TblColRef rawColumn = getRawColumn(measureDesc.getFunction());
if (!digest.allColumns.isEmpty() && !digest.allColumns.contains(rawColumn)) {
return null;
}
unmatchedAggregations.remove(measureDesc.getFunction());
//contain one raw measure : cost * 0.9
return new CapabilityResult.CapabilityInfluence() {
@Override
public double suggestCostMultiplier() {
return 0.9;
}
@Override
public MeasureDesc getInvolvedMeasure() {
return measureDesc;
}
};
}
示例8: initMeasureColumns
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
@SuppressWarnings("deprecation")
private void initMeasureColumns() {
if (measures == null || measures.isEmpty()) {
return;
}
for (MeasureDesc m : measures) {
m.setName(m.getName().toUpperCase());
if (m.getDependentMeasureRef() != null) {
m.setDependentMeasureRef(m.getDependentMeasureRef().toUpperCase());
}
FunctionDesc func = m.getFunction();
func.init(model);
allColumns.addAll(func.getParameter().getColRefs());
if (ExtendedColumnMeasureType.FUNC_EXTENDED_COLUMN.equalsIgnoreCase(m.getFunction().getExpression())) {
FunctionDesc functionDesc = m.getFunction();
List<TblColRef> hosts = ExtendedColumnMeasureType.getExtendedColumnHosts(functionDesc);
TblColRef extendedColumn = ExtendedColumnMeasureType.getExtendedColumn(functionDesc);
initExtendedColumnMap(hosts.toArray(new TblColRef[hosts.size()]), extendedColumn);
}
}
}
示例9: MeasureAggregators
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public MeasureAggregators(MeasureDesc... measureDescs) {
descLength = measureDescs.length;
aggs = new MeasureAggregator[descLength];
Map<String, Integer> measureIndexMap = new HashMap<String, Integer>();
for (int i = 0; i < descLength; i++) {
FunctionDesc func = measureDescs[i].getFunction();
aggs[i] = func.getMeasureType().newAggregator();
measureIndexMap.put(measureDescs[i].getName(), i);
}
// fill back dependent aggregator
for (int i = 0; i < descLength; i++) {
String depMsrRef = measureDescs[i].getDependentMeasureRef();
if (depMsrRef != null) {
int index = measureIndexMap.get(depMsrRef);
aggs[i].setDependentAggregator(aggs[index]);
}
}
}
示例10: listEffectiveRewriteMeasures
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public List<MeasureDesc> listEffectiveRewriteMeasures(String project, String table, boolean onlyRewriteMeasure) {
Set<IRealization> realizations = getRealizationsByTable(project, table);
List<MeasureDesc> result = Lists.newArrayList();
for (IRealization r : realizations) {
if (!r.isReady())
continue;
for (MeasureDesc m : r.getMeasures()) {
FunctionDesc func = m.getFunction();
if (belongToTable(func, table, r.getModel())) {
if (!onlyRewriteMeasure || func.needRewrite()) {
result.add(m);
}
}
}
}
return result;
}
示例11: search
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
private int search(List<TblColRef> groups, List<FunctionDesc> aggregations, TupleFilter filter, StorageContext context) {
int count = 0;
ITupleIterator iterator = null;
try {
SQLDigest sqlDigest = new SQLDigest("default.test_kylin_fact", /*allCol*/ Collections.<TblColRef> emptySet(), /*join*/ null, //
groups, /*subqueryJoinParticipants*/ Sets.<TblColRef> newHashSet(), //
/*metricCol*/ Collections.<TblColRef> emptySet(), aggregations, /*aggrSqlCalls*/ Collections.<SQLCall> emptyList(), //
/*filter col*/ Collections.<TblColRef> emptySet(), filter, null, //
/*sortCol*/ new ArrayList<TblColRef>(), new ArrayList<SQLDigest.OrderEnum>(), false, new HashSet<MeasureDesc>());
iterator = storageEngine.search(context, sqlDigest, mockup.newTupleInfo(groups, aggregations));
while (iterator.hasNext()) {
ITuple tuple = iterator.next();
System.out.println("Tuple = " + tuple);
count++;
}
} finally {
if (iterator != null)
iterator.close();
}
return count;
}
示例12: SegmentCubeTupleIterator
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public SegmentCubeTupleIterator(CubeSegmentScanner scanner, Cuboid cuboid, Set<TblColRef> selectedDimensions, //
Set<FunctionDesc> selectedMetrics, TupleInfo returnTupleInfo, StorageContext context) {
this.scanner = scanner;
this.cuboid = cuboid;
this.selectedDimensions = selectedDimensions;
this.selectedMetrics = selectedMetrics;
this.tupleInfo = returnTupleInfo;
this.tuple = new Tuple(returnTupleInfo);
this.context = context;
CuboidToGridTableMapping mapping = cuboid.getCuboidToGridTableMapping();
int[] gtDimsIdx = mapping.getDimIndexes(selectedDimensions);
int[] gtMetricsIdx = mapping.getMetricsIndexes(selectedMetrics);
// gtColIdx = gtDimsIdx + gtMetricsIdx
int[] gtColIdx = new int[gtDimsIdx.length + gtMetricsIdx.length];
System.arraycopy(gtDimsIdx, 0, gtColIdx, 0, gtDimsIdx.length);
System.arraycopy(gtMetricsIdx, 0, gtColIdx, gtDimsIdx.length, gtMetricsIdx.length);
this.gtValues = getGTValuesIterator(scanner.iterator(), scanner.getScanRequest(), gtDimsIdx, gtMetricsIdx);
this.cubeTupleConverter = ((GTCubeStorageQueryBase) context.getStorageQuery()).newCubeTupleConverter(
scanner.cubeSeg, cuboid, selectedDimensions, selectedMetrics, gtColIdx, tupleInfo);
}
示例13: SequentialCubeTupleIterator
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public SequentialCubeTupleIterator(List<CubeSegmentScanner> scanners, Cuboid cuboid, Set<TblColRef> selectedDimensions, //
Set<TblColRef> groups, Set<FunctionDesc> selectedMetrics, TupleInfo returnTupleInfo, StorageContext context, SQLDigest sqlDigest) {
this.context = context;
this.scanners = scanners;
segmentCubeTupleIterators = Lists.newArrayList();
for (CubeSegmentScanner scanner : scanners) {
segmentCubeTupleIterators.add(new SegmentCubeTupleIterator(scanner, cuboid, selectedDimensions, selectedMetrics, returnTupleInfo, context));
}
if (context.mergeSortPartitionResults() && !sqlDigest.isRawQuery) {
//query with limit
logger.info("Using SortedIteratorMergerWithLimit to merge segment results");
Iterator<Iterator<ITuple>> transformed = (Iterator<Iterator<ITuple>>) (Iterator<?>) segmentCubeTupleIterators.iterator();
tupleIterator = new SortedIteratorMergerWithLimit<ITuple>(transformed, context.getFinalPushDownLimit(), getTupleDimensionComparator(cuboid, groups, returnTupleInfo)).getIterator();
} else {
//normal case
logger.info("Using Iterators.concat to merge segment results");
tupleIterator = Iterators.concat(segmentCubeTupleIterators.iterator());
}
}
示例14: buildValueOf
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
private Object buildValueOf(int idxOfMeasure, String[] row) {
MeasureDesc measure = measureDescs[idxOfMeasure];
FunctionDesc function = measure.getFunction();
int[] colIdxOnFlatTable = flatDesc.getMeasureColumnIndexes()[idxOfMeasure];
int paramCount = function.getParameterCount();
String[] inputToMeasure = new String[paramCount];
// pick up parameter values
ParameterDesc param = function.getParameter();
int paramColIdx = 0; // index among parameters of column type
for (int i = 0; i < paramCount; i++, param = param.getNextParameter()) {
String value;
if (function.isCount()) {
value = "1";
} else if (param.isColumnType()) {
value = row[colIdxOnFlatTable[paramColIdx++]];
} else {
value = param.getValue();
}
inputToMeasure[i] = value;
}
return measureIngesters[idxOfMeasure].valueOf(inputToMeasure, measure, dictionaryMap);
}
示例15: makeAggrFuncs
import org.apache.kylin.metadata.model.FunctionDesc; //导入依赖的package包/类
public String[] makeAggrFuncs(Collection<FunctionDesc> metrics) {
//metrics are represented in ImmutableBitSet, which loses order information
//sort the aggrFuns to align with metrics natural order
List<FunctionDesc> metricList = Lists.newArrayList(metrics);
Collections.sort(metricList, new Comparator<FunctionDesc>() {
@Override
public int compare(FunctionDesc o1, FunctionDesc o2) {
int a = CuboidToGridTableMapping.this.getIndexOf(o1);
int b = CuboidToGridTableMapping.this.getIndexOf(o2);
return a - b;
}
});
String[] result = new String[metricList.size()];
int i = 0;
for (FunctionDesc metric : metricList) {
result[i++] = metric.getExpression();
}
return result;
}