本文整理汇总了Java中org.apache.kylin.metadata.model.FunctionDesc.getMeasureType方法的典型用法代码示例。如果您正苦于以下问题:Java FunctionDesc.getMeasureType方法的具体用法?Java FunctionDesc.getMeasureType怎么用?Java FunctionDesc.getMeasureType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.kylin.metadata.model.FunctionDesc
的用法示例。
在下文中一共展示了FunctionDesc.getMeasureType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: implementRewrite
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Override
public void implementRewrite(RewriteImplementor implementor) {
// only rewrite the innermost aggregation
if (needRewrite()) {
translateAggregation();
buildRewriteFieldsAndMetricsColumns();
}
implementor.visitChild(this, getInput());
// only rewrite the innermost aggregation
if (needRewrite()) {
// rewrite the aggCalls
this.rewriteAggCalls = new ArrayList<AggregateCall>(aggCalls.size());
for (int i = 0; i < this.aggCalls.size(); i++) {
AggregateCall aggCall = this.aggCalls.get(i);
FunctionDesc cubeFunc = this.context.aggregations.get(i);
// filter needn,t rewrite aggfunc
// if it's not a cube, then the "needRewriteField func" should not resort to any rewrite fields,
// which do not exist at all
if (!(noPrecaculatedFieldsAvailable() && cubeFunc.needRewriteField())) {
if (cubeFunc.needRewrite()) {
aggCall = rewriteAggregateCall(aggCall, cubeFunc);
}
//if not dim as measure (using some measure), differentiate it with a new class
if (cubeFunc.getMeasureType() != null &&
// DimCountDistinct case
cubeFunc.getMeasureType().needRewriteField()) {
aggCall = new KylinAggregateCall(aggCall, cubeFunc);
}
} else {
logger.info(aggCall + "skip rewriteAggregateCall because no pre-aggregated field available");
}
this.rewriteAggCalls.add(aggCall);
this.context.aggrSqlCalls.add(toSqlCall(aggCall));
}
}
// rebuild rowType & columnRowType
this.rowType = this.deriveRowType();
this.columnRowType = this.buildColumnRowType();
}
示例2: 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);
}
}
}
}
示例3: testReducerOnlyAggrInBaseCuboid
import org.apache.kylin.metadata.model.FunctionDesc; //导入方法依赖的package包/类
@Test
public void testReducerOnlyAggrInBaseCuboid() throws Exception {
reduceDriver.getConfiguration().set(BatchConstants.CFG_CUBE_NAME, "test_kylin_cube_with_slr_ready");
reduceDriver.getConfiguration().setInt(BatchConstants.CFG_CUBE_CUBOID_LEVEL, 1);
CubeDesc cubeDesc = CubeManager.getInstance(getTestConfig()).getCube("test_kylin_cube_with_slr_ready").getDescriptor();
MeasureDesc measureDesc = cubeDesc.getMeasures().get(0);
FunctionDesc functionDesc = measureDesc.getFunction();
Field field = FunctionDesc.class.getDeclaredField("measureType");
field.setAccessible(true);
MeasureType origMeasureType = functionDesc.getMeasureType();
field.set(functionDesc, new MockUpMeasureType(origMeasureType));
BufferedMeasureCodec codec = new BufferedMeasureCodec(cubeDesc.getMeasures());
Text key1 = new Text("72010ustech");
List<Text> values1 = new ArrayList<Text>();
values1.add(newValueText(codec, "15.09", "15.09", "15.09", 1, 100));
values1.add(newValueText(codec, "20.34", "20.34", "20.34", 1, 200));
values1.add(newValueText(codec, "10", "10", "10", 1, 300));
Text key2 = new Text("1tech");
List<Text> values2 = new ArrayList<Text>();
values2.add(newValueText(codec, "15.09", "15.09", "15.09", 1, 500));
values2.add(newValueText(codec, "20.34", "20.34", "20.34", 1, 1000));
Text key3 = new Text("0");
List<Text> values3 = new ArrayList<Text>();
values3.add(newValueText(codec, "146.52", "146.52", "146.52", 0, 0));
reduceDriver.withInput(key1, values1);
reduceDriver.withInput(key2, values2);
reduceDriver.withInput(key3, values3);
List<Pair<Text, Text>> result = reduceDriver.run();
Pair<Text, Text> p1 = new Pair<Text, Text>(new Text("72010ustech"), newValueText(codec, "0", "10", "20.34", 3, 600));
Pair<Text, Text> p2 = new Pair<Text, Text>(new Text("1tech"), newValueText(codec, "0", "15.09", "20.34", 2, 1500));
Pair<Text, Text> p3 = new Pair<Text, Text>(new Text("0"), newValueText(codec, "0", "146.52", "146.52", 0, 0));
assertEquals(3, result.size());
assertTrue(result.contains(p1));
assertTrue(result.contains(p2));
assertTrue(result.contains(p3));
}