本文整理汇总了Java中org.apache.kylin.metadata.model.FunctionDesc.isCount方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionDesc.isCount方法的具体用法?Java FunctionDesc.isCount怎么用?Java FunctionDesc.isCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.metadata.model.FunctionDesc
的用法示例。
在下文中一共展示了FunctionDesc.isCount方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: buildValueOf
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
private Object buildValueOf(int idxOfMeasure, String[] flatRow) {
MeasureDesc measure = cubeDesc.getMeasures().get(idxOfMeasure);
FunctionDesc function = measure.getFunction();
int[] colIdxOnFlatTable = intermediateTableDesc.getMeasureColumnIndexes()[idxOfMeasure];
int paramCount = function.getParameterCount();
String[] inputToMeasure = new String[paramCount];
// pick up parameter values
ParameterDesc param = function.getParameter();
int colParamIdx = 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 = getCell(colIdxOnFlatTable[colParamIdx++], flatRow);
} else {
value = param.getValue();
}
inputToMeasure[i] = value;
}
return aggrIngesters[idxOfMeasure].valueOf(inputToMeasure, measure, dictionaryMap);
}
示例3: 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);
}
示例4: rewriteAggregateCall
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private AggregateCall rewriteAggregateCall(AggregateCall aggCall, FunctionDesc func) {
// rebuild function
String callName = getSqlFuncName(aggCall);
RelDataType fieldType = aggCall.getType();
SqlAggFunction newAgg = aggCall.getAggregation();
Map<String, Class<?>> udafMap = func.getMeasureType().getRewriteCalciteAggrFunctions();
if (func.isCount()) {
newAgg = SqlStdOperatorTable.SUM0;
} else if (udafMap != null && udafMap.containsKey(callName)) {
newAgg = createCustomAggFunction(callName, fieldType, udafMap.get(callName));
}
// rebuild parameters
List<Integer> newArgList = Lists.newArrayList(aggCall.getArgList());
if (udafMap != null && udafMap.containsKey(callName)) {
newArgList = truncArgList(newArgList, udafMap.get(callName));
}
if (func.needRewriteField()) {
RelDataTypeField field = getInput().getRowType().getField(func.getRewriteFieldName(), true, false);
if (newArgList.isEmpty()) {
newArgList.add(field.getIndex());
} else {
// TODO: only the first column got overwritten
newArgList.set(0, field.getIndex());
}
}
// rebuild aggregate call
AggregateCall newAggCall = new AggregateCall(newAgg, false, newArgList, fieldType, callName);
return newAggCall;
}
示例5: adjustSqlDigest
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Override
public void adjustSqlDigest(List<MeasureDesc> measureDescs, SQLDigest sqlDigest) {
if (sqlDigest.aggregations.size() > 1) {
return;
}
for (MeasureDesc measureDesc : measureDescs) {
if (!sqlDigest.involvedMeasure.contains(measureDesc)) {
continue;
}
FunctionDesc topnFunc = measureDesc.getFunction();
List<TblColRef> topnLiteralCol = getTopNLiteralColumn(topnFunc);
if (sqlDigest.groupbyColumns.containsAll(topnLiteralCol) == false) {
continue;
}
if (sqlDigest.aggregations.size() > 0) {
FunctionDesc origFunc = sqlDigest.aggregations.iterator().next();
if (origFunc.isSum() == false && origFunc.isCount() == false) {
logger.warn("When query with topN, only SUM/Count function is allowed.");
return;
}
if (isTopNCompatibleSum(measureDesc.getFunction(), origFunc) == false) {
continue;
}
logger.info("Rewrite function " + origFunc + " to " + topnFunc);
}
sqlDigest.aggregations = Lists.newArrayList(topnFunc);
sqlDigest.groupbyColumns.removeAll(topnLiteralCol);
sqlDigest.metricColumns.addAll(topnLiteralCol);
break;
}
}
示例6: tryDimensionAsMeasures
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
private static void tryDimensionAsMeasures(Collection<FunctionDesc> unmatchedAggregations, CapabilityResult result,
Set<TblColRef> dimCols) {
Iterator<FunctionDesc> it = unmatchedAggregations.iterator();
while (it.hasNext()) {
FunctionDesc functionDesc = it.next();
// let calcite handle count
if (functionDesc.isCount()) {
it.remove();
continue;
}
// calcite can do aggregation from columns on-the-fly
ParameterDesc parameterDesc = functionDesc.getParameter();
if (parameterDesc == null) {
continue;
}
List<TblColRef> neededCols = parameterDesc.getColRefs();
if (neededCols.size() > 0 && dimCols.containsAll(neededCols)
&& FunctionDesc.BUILT_IN_AGGREGATIONS.contains(functionDesc.getExpression())) {
result.influences.add(new CapabilityResult.DimensionAsMeasure(functionDesc));
it.remove();
continue;
}
}
}
示例7: validate
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Override
public void validate(CubeDesc cube, ValidateContext context) {
List<MeasureDesc> measures = cube.getMeasures();
if (validateMeasureNamesDuplicated(measures, context)) {
return;
}
List<FunctionDesc> countFuncs = new ArrayList<FunctionDesc>();
Iterator<MeasureDesc> it = measures.iterator();
while (it.hasNext()) {
MeasureDesc measure = it.next();
FunctionDesc func = measure.getFunction();
ParameterDesc parameter = func.getParameter();
if (parameter == null) {
context.addResult(ResultLevel.ERROR, "Must define parameter for function " + func.getExpression() + " in " + measure.getName());
return;
}
String type = func.getParameter().getType();
String value = func.getParameter().getValue();
if (StringUtils.isEmpty(type)) {
context.addResult(ResultLevel.ERROR, "Must define type for parameter type " + func.getExpression() + " in " + measure.getName());
return;
}
if (StringUtils.isEmpty(value)) {
context.addResult(ResultLevel.ERROR, "Must define type for parameter value " + func.getExpression() + " in " + measure.getName());
return;
}
if (StringUtils.isEmpty(func.getReturnType())) {
context.addResult(ResultLevel.ERROR, "Must define return type for function " + func.getExpression() + " in " + measure.getName());
return;
}
if (StringUtils.equalsIgnoreCase(FunctionDesc.PARAMETER_TYPE_COLUMN, type)) {
validateColumnParameter(context, cube, value);
} else if (StringUtils.equals(FunctionDesc.PARAMETER_TYPE_CONSTANT, type)) {
validateCostantParameter(context, cube, value);
}
try {
func.getMeasureType().validate(func);
} catch (IllegalArgumentException ex) {
context.addResult(ResultLevel.ERROR, ex.getMessage());
}
if (func.isCount())
countFuncs.add(func);
if (TopNMeasureType.FUNC_TOP_N.equalsIgnoreCase(func.getExpression())) {
if (parameter.getNextParameter() == null) {
context.addResult(ResultLevel.ERROR, "Must define at least 2 parameters for function " + func.getExpression() + " in " + measure.getName());
return;
}
ParameterDesc groupByCol = parameter.getNextParameter();
List<String> duplicatedCol = Lists.newArrayList();
while (groupByCol != null) {
String embeded_groupby = groupByCol.getValue();
for (DimensionDesc dimensionDesc : cube.getDimensions()) {
if (dimensionDesc.getColumn() != null && dimensionDesc.getColumn().equalsIgnoreCase(embeded_groupby)) {
duplicatedCol.add(embeded_groupby);
}
}
groupByCol = groupByCol.getNextParameter();
}
}
}
if (countFuncs.size() != 1) {
context.addResult(ResultLevel.ERROR, "Must define one and only one count(1) function, but there are " + countFuncs.size() + " -- " + countFuncs);
}
}