本文整理汇总了Java中org.apache.kylin.metadata.model.FunctionDesc.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionDesc.newInstance方法的具体用法?Java FunctionDesc.newInstance怎么用?Java FunctionDesc.newInstance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.metadata.model.FunctionDesc
的用法示例。
在下文中一共展示了FunctionDesc.newInstance方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: adjustSqlDigest
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Override
public void adjustSqlDigest(List<MeasureDesc> measureDescs, SQLDigest sqlDigest) {
if (sqlDigest.isRawQuery) {
for (MeasureDesc measureDesc : measureDescs) {
if (!sqlDigest.involvedMeasure.contains(measureDesc)) {
continue;
}
TblColRef col = this.getRawColumn(measureDesc.getFunction());
ParameterDesc colParameter = ParameterDesc.newInstance(col);
FunctionDesc rawFunc = FunctionDesc.newInstance("RAW", colParameter, null);
if (sqlDigest.allColumns.contains(col)) {
if (measureDesc.getFunction().equals(rawFunc)) {
FunctionDesc sumFunc = FunctionDesc.newInstance("SUM", colParameter, null);
sqlDigest.aggregations.remove(sumFunc);
sqlDigest.aggregations.add(rawFunc);
logger.info("Add RAW measure on column " + col);
}
if (!sqlDigest.metricColumns.contains(col)) {
sqlDigest.metricColumns.add(col);
}
}
}
}
}
示例2: buildAggregations
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
public List<FunctionDesc> buildAggregations() {
List<FunctionDesc> functions = new ArrayList<FunctionDesc>();
TblColRef priceCol = model.findColumn("DEFAULT.TEST_KYLIN_FACT.PRICE");
TblColRef sellerCol = model.findColumn("DEFAULT.TEST_KYLIN_FACT.SELLER_ID");
FunctionDesc f1 = FunctionDesc.newInstance("SUM", //
ParameterDesc.newInstance(priceCol), "decimal(19,4)");
functions.add(f1);
FunctionDesc f2 = FunctionDesc.newInstance("COUNT_DISTINCT", //
ParameterDesc.newInstance(sellerCol), "hllc(10)");
functions.add(f2);
return functions;
}
示例3: buildAggregations
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
void buildAggregations() {
ColumnRowType inputColumnRowType = ((OLAPRel) getInput()).getColumnRowType();
this.aggregations = new ArrayList<FunctionDesc>();
for (AggregateCall aggCall : this.rewriteAggCalls) {
ParameterDesc parameter = null;
// By default all args are included, UDFs can define their own in getParamAsMeasureCount method.
if (!aggCall.getArgList().isEmpty()) {
List<TblColRef> columns = Lists.newArrayList();
String funcName = getSqlFuncName(aggCall);
int columnsCount = aggCall.getArgList().size();
if (AGGR_FUNC_PARAM_AS_MEASURE_MAP.containsKey(funcName)) {
int asMeasureCnt = AGGR_FUNC_PARAM_AS_MEASURE_MAP.get(funcName);
if (asMeasureCnt > 0) {
columnsCount = asMeasureCnt;
} else {
columnsCount += asMeasureCnt;
}
}
for (Integer index : aggCall.getArgList().subList(0, columnsCount)) {
TblColRef column = inputColumnRowType.getColumnByIndex(index);
columns.add(column);
}
if (!columns.isEmpty()) {
parameter = ParameterDesc.newInstance(columns.toArray(new TblColRef[columns.size()]));
}
}
String expression = getAggrFuncName(aggCall);
FunctionDesc aggFunc = FunctionDesc.newInstance(expression, parameter, null);
this.aggregations.add(aggFunc);
}
}
示例4: buildAggregations1
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
public List<FunctionDesc> buildAggregations1() {
List<FunctionDesc> functions = new ArrayList<FunctionDesc>();
TblColRef priceCol = model.findColumn("DEFAULT.TEST_KYLIN_FACTPRICE");
FunctionDesc f1 = FunctionDesc.newInstance("SUM", //
ParameterDesc.newInstance(priceCol), "decimal(19,4)");
functions.add(f1);
return functions;
}
示例5: getAdvancedTupleFiller
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Override
public IAdvMeasureFiller getAdvancedTupleFiller(FunctionDesc function, TupleInfo tupleInfo,
Map<TblColRef, Dictionary<String>> dictionaryMap) {
final List<TblColRef> literalCols = getTopNLiteralColumn(function);
final TblColRef numericCol = getTopNNumericColumn(function);
final int[] literalTupleIdx = new int[literalCols.size()];
final DimensionEncoding[] dimensionEncodings = getDimensionEncodings(function, literalCols, dictionaryMap);
for (int i = 0; i < literalCols.size(); i++) {
TblColRef colRef = literalCols.get(i);
literalTupleIdx[i] = tupleInfo.hasColumn(colRef) ? tupleInfo.getColumnIndex(colRef) : -1;
}
// for TopN, the aggr must be SUM
final int numericTupleIdx;
if (numericCol != null) {
FunctionDesc sumFunc = FunctionDesc.newInstance(FunctionDesc.FUNC_SUM,
ParameterDesc.newInstance(numericCol), numericCol.getType().toString());
String sumFieldName = sumFunc.getRewriteFieldName();
numericTupleIdx = tupleInfo.hasField(sumFieldName) ? tupleInfo.getFieldIndex(sumFieldName) : -1;
} else {
FunctionDesc countFunction = FunctionDesc.newInstance(FunctionDesc.FUNC_COUNT,
ParameterDesc.newInstance("1"), "bigint");
numericTupleIdx = tupleInfo.getFieldIndex(countFunction.getRewriteFieldName());
}
return new IAdvMeasureFiller() {
private TopNCounter<ByteArray> topNCounter;
private Iterator<Counter<ByteArray>> topNCounterIterator;
private int expectRow = 0;
@SuppressWarnings("unchecked")
@Override
public void reload(Object measureValue) {
this.topNCounter = (TopNCounter<ByteArray>) measureValue;
this.topNCounterIterator = topNCounter.iterator();
this.expectRow = 0;
}
@Override
public int getNumOfRows() {
return topNCounter.size();
}
@Override
public void fillTuple(Tuple tuple, int row) {
if (expectRow++ != row)
throw new IllegalStateException();
Counter<ByteArray> counter = topNCounterIterator.next();
int offset = counter.getItem().offset();
for (int i = 0; i < dimensionEncodings.length; i++) {
String colValue = dimensionEncodings[i].decode(counter.getItem().array(), offset,
dimensionEncodings[i].getLengthOfEncoding());
tuple.setDimensionValue(literalTupleIdx[i], colValue);
offset += dimensionEncodings[i].getLengthOfEncoding();
}
tuple.setMeasureValue(numericTupleIdx, counter.getCount());
}
};
}
示例6: measure
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
private MeasureDesc measure(String returnType) {
MeasureDesc desc = new MeasureDesc();
FunctionDesc func = FunctionDesc.newInstance(null, null, returnType);
desc.setFunction(func);
return desc;
}