本文整理汇总了Java中org.apache.kylin.metadata.model.FunctionDesc.getRewriteFieldName方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionDesc.getRewriteFieldName方法的具体用法?Java FunctionDesc.getRewriteFieldName怎么用?Java FunctionDesc.getRewriteFieldName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.metadata.model.FunctionDesc
的用法示例。
在下文中一共展示了FunctionDesc.getRewriteFieldName方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRewriteColumn
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
TblColRef buildRewriteColumn(FunctionDesc aggFunc) {
TblColRef colRef;
if (aggFunc.needRewriteField()) {
String colName = aggFunc.getRewriteFieldName();
colRef = this.context.firstTableScan.makeRewriteColumn(colName);
} else {
throw new IllegalStateException("buildRewriteColumn on a aggrFunc that does not need rewrite " + aggFunc);
}
return colRef;
}
示例2: listSourceColumns
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
private List<ColumnDesc> listSourceColumns() {
ProjectManager mgr = ProjectManager.getInstance(olapSchema.getConfig());
List<ColumnDesc> tableColumns = mgr.listExposedColumns(olapSchema.getProjectName(), sourceTable, exposeMore);
List<ColumnDesc> metricColumns = Lists.newArrayList();
List<MeasureDesc> countMeasures = mgr.listEffectiveRewriteMeasures(olapSchema.getProjectName(),
sourceTable.getIdentity());
HashSet<String> metFields = new HashSet<String>();
for (MeasureDesc m : countMeasures) {
FunctionDesc func = m.getFunction();
String fieldName = func.getRewriteFieldName();
if (!metFields.contains(fieldName)) {
metFields.add(fieldName);
ColumnDesc fakeCountCol = func.newFakeRewriteColumn(sourceTable);
metricColumns.add(fakeCountCol);
}
}
Collections.sort(tableColumns, new Comparator<ColumnDesc>() {
@Override
public int compare(ColumnDesc o1, ColumnDesc o2) {
return o1.getZeroBasedIndex() - o2.getZeroBasedIndex();
}
});
return Lists.newArrayList(Iterables.concat(tableColumns, metricColumns));
}
示例3: buildColumnRowType
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
ColumnRowType buildColumnRowType() {
buildGroups();
buildAggregations();
ColumnRowType inputColumnRowType = ((OLAPRel) getInput()).getColumnRowType();
List<TblColRef> columns = new ArrayList<TblColRef>(this.rowType.getFieldCount());
columns.addAll(this.groups);
// Add group column indicators
if (indicator) {
final Set<String> containedNames = Sets.newHashSet();
for (TblColRef groupCol : groups) {
String base = "i$" + groupCol.getName();
String name = base;
int i = 0;
while (containedNames.contains(name)) {
name = base + "_" + i++;
}
containedNames.add(name);
TblColRef indicatorCol = TblColRef.newInnerColumn(name, TblColRef.InnerDataTypeEnum.LITERAL);
columns.add(indicatorCol);
}
}
for (int i = 0; i < this.aggregations.size(); i++) {
FunctionDesc aggFunc = this.aggregations.get(i);
String aggOutName;
if (aggFunc != null) {
aggOutName = aggFunc.getRewriteFieldName();
} else {
AggregateCall aggCall = this.rewriteAggCalls.get(i);
int index = aggCall.getArgList().get(0);
aggOutName = getSqlFuncName(aggCall) + "_"
+ inputColumnRowType.getColumnByIndex(index).getIdentity().replace('.', '_') + "_";
}
TblColRef aggOutCol = TblColRef.newInnerColumn(aggOutName, TblColRef.InnerDataTypeEnum.LITERAL);
aggOutCol.getColumnDesc().setId("" + (i + 1)); // mark the index of aggregation
columns.add(aggOutCol);
}
return new ColumnRowType(columns);
}
示例4: 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());
}
};
}
示例5: CubeTupleConverter
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
public CubeTupleConverter(CubeSegment cubeSeg, Cuboid cuboid, //
Set<TblColRef> selectedDimensions, Set<FunctionDesc> selectedMetrics, int[] gtColIdx, TupleInfo returnTupleInfo) {
this.cubeSeg = cubeSeg;
this.cuboid = cuboid;
this.gtColIdx = gtColIdx;
this.tupleInfo = returnTupleInfo;
this.derivedColFillers = Lists.newArrayList();
nSelectedDims = selectedDimensions.size();
tupleIdx = new int[selectedDimensions.size() + selectedMetrics.size()];
// measure types don't have this many, but aligned length make programming easier
measureTypes = new MeasureType[selectedDimensions.size() + selectedMetrics.size()];
advMeasureFillers = Lists.newArrayListWithCapacity(1);
advMeasureIndexInGTValues = Lists.newArrayListWithCapacity(1);
////////////
int i = 0;
// pre-calculate dimension index mapping to tuple
for (TblColRef dim : selectedDimensions) {
tupleIdx[i] = tupleInfo.hasColumn(dim) ? tupleInfo.getColumnIndex(dim) : -1;
i++;
}
for (FunctionDesc metric : selectedMetrics) {
if (metric.needRewrite()) {
String rewriteFieldName = metric.getRewriteFieldName();
tupleIdx[i] = tupleInfo.hasField(rewriteFieldName) ? tupleInfo.getFieldIndex(rewriteFieldName) : -1;
} else {
// a non-rewrite metrics (like sum, or dimension playing as metrics) is like a dimension column
TblColRef col = metric.getParameter().getColRefs().get(0);
tupleIdx[i] = tupleInfo.hasColumn(col) ? tupleInfo.getColumnIndex(col) : -1;
}
MeasureType<?> measureType = metric.getMeasureType();
if (measureType.needAdvancedTupleFilling()) {
Map<TblColRef, Dictionary<String>> dictionaryMap = buildDictionaryMap(measureType.getColumnsNeedDictionary(metric));
advMeasureFillers.add(measureType.getAdvancedTupleFiller(metric, returnTupleInfo, dictionaryMap));
advMeasureIndexInGTValues.add(i);
} else {
measureTypes[i] = measureType;
}
i++;
}
// prepare derived columns and filler
Map<Array<TblColRef>, List<DeriveInfo>> hostToDerivedInfo = cuboid.getCubeDesc().getHostToDerivedInfo(cuboid.getColumns(), null);
for (Entry<Array<TblColRef>, List<DeriveInfo>> entry : hostToDerivedInfo.entrySet()) {
TblColRef[] hostCols = entry.getKey().data;
for (DeriveInfo deriveInfo : entry.getValue()) {
IDerivedColumnFiller filler = newDerivedColumnFiller(hostCols, deriveInfo);
if (filler != null) {
derivedColFillers.add(filler);
}
}
}
}