Java Code Examples for org.apache.kylin.metadata.model.MeasureDesc#setFunction()

The following examples show how to use org.apache.kylin.metadata.model.MeasureDesc#setFunction() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: BaseCuboidBuilder.java    From kylin with Apache License 2.0 6 votes vote down vote up
private void checkHiveGlobalDictionaryColumn(){
    Set<String> mrDictColumnSet = new HashSet<>();
    if (kylinConfig.getMrHiveDictColumns() != null) {
        Collections.addAll(mrDictColumnSet, kylinConfig.getMrHiveDictColumns());
    }

    for (MeasureDesc measure : measureDescList) {
        if (measure.getFunction().getExpression().equalsIgnoreCase(FunctionDesc.FUNC_COUNT_DISTINCT)) {
            FunctionDesc functionDesc = measure.getFunction();
            TblColRef colRef = functionDesc.getParameter().getColRefs().get(0);
            if (mrDictColumnSet.contains(JoinedFlatTable.colName(colRef, true))) {
                functionDesc.setMrDict(true);
                logger.info("Enable hive global dictionary for {}", colRef);
                measure.setFunction(functionDesc);
            }
        }
    }
}
 
Example 3
Source File: BaseCuboidBuilder.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private void checkMrDictClolumn(){
    Set<String> mrDictColumnSet = new HashSet<>();
    if (kylinConfig.getMrHiveDictColumns() != null) {
        Collections.addAll(mrDictColumnSet, kylinConfig.getMrHiveDictColumns());
    }

    for (MeasureDesc measure : measureDescList) {
        if (measure.getFunction().getExpression().equalsIgnoreCase(FunctionDesc.FUNC_COUNT_DISTINCT)) {
            FunctionDesc functionDesc = measure.getFunction();
            TblColRef colRef = functionDesc.getParameter().getColRefs().get(0);
            if (mrDictColumnSet.contains(JoinedFlatTable.colName(colRef, true))) {
                functionDesc.setMrDict(true);
                logger.info("setMrDict for {}", colRef);
                measure.setFunction(functionDesc);
            }
        }
    }
}
 
Example 4
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: MeasureCodecTest.java    From Kylin with Apache License 2.0 5 votes vote down vote up
private MeasureDesc measure(String returnType) {
    MeasureDesc desc = new MeasureDesc();
    FunctionDesc func = new FunctionDesc();
    func.setReturnType(returnType);
    desc.setFunction(func);
    return desc;
}
 
Example 6
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureCount() {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue("1");
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_CONSTANT);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(FunctionDesc.FUNC_COUNT);
    function.setParameter(parameterDesc);
    function.setReturnType(HiveTableCreator.HiveTypeEnum.HBIGINT.toString());

    MeasureDesc result = new MeasureDesc();
    result.setName("_COUNT_");
    result.setFunction(function);
    return result;
}
 
Example 7
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasurePercentile(String column) {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue(column);
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_COLUMN);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(PercentileMeasureType.FUNC_PERCENTILE);
    function.setParameter(parameterDesc);
    function.setReturnType("percentile(100)");

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_PERCENTILE");
    result.setFunction(function);
    return result;
}
 
Example 8
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureHLL(String column) {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue(column);
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_COLUMN);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(FunctionDesc.FUNC_COUNT_DISTINCT);
    function.setParameter(parameterDesc);
    function.setReturnType("hllc12");

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_HLL");
    result.setFunction(function);
    return result;
}
 
Example 9
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureMin(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_MIN);
    function.setParameter(parameterDesc);
    function.setReturnType(dataType);

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_MIN");
    result.setFunction(function);
    return result;
}
 
Example 10
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureMax(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_MAX);
    function.setParameter(parameterDesc);
    function.setReturnType(dataType);

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_MAX");
    result.setFunction(function);
    return result;
}
 
Example 11
Source File: CubeDescCreator.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureCount() {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue("1");
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_CONSTANT);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(FunctionDesc.FUNC_COUNT);
    function.setParameter(parameterDesc);
    function.setReturnType(HiveTableCreator.HiveTypeEnum.HBIGINT.toString());

    MeasureDesc result = new MeasureDesc();
    result.setName("_COUNT_");
    result.setFunction(function);
    return result;
}
 
Example 12
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasurePercentile(String column) {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue(column);
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_COLUMN);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(PercentileMeasureType.FUNC_PERCENTILE);
    function.setParameter(parameterDesc);
    function.setReturnType("percentile(100)");

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_PERCENTILE");
    result.setFunction(function);
    return result;
}
 
Example 13
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureHLL(String column) {
    ParameterDesc parameterDesc = new ParameterDesc();
    parameterDesc.setValue(column);
    parameterDesc.setType(FunctionDesc.PARAMETER_TYPE_COLUMN);

    FunctionDesc function = new FunctionDesc();
    function.setExpression(FunctionDesc.FUNC_COUNT_DISTINCT);
    function.setParameter(parameterDesc);
    function.setReturnType("hllc12");

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_HLL");
    result.setFunction(function);
    return result;
}
 
Example 14
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureMin(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_MIN);
    function.setParameter(parameterDesc);
    function.setReturnType(dataType);

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_MIN");
    result.setFunction(function);
    return result;
}
 
Example 15
Source File: CubeDescCreator.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static MeasureDesc getMeasureMax(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_MAX);
    function.setParameter(parameterDesc);
    function.setReturnType(dataType);

    MeasureDesc result = new MeasureDesc();
    result.setName(column + "_MAX");
    result.setFunction(function);
    return result;
}
 
Example 16
Source File: MeasureCodecTest.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
private MeasureDesc measure(String returnType) {
    MeasureDesc desc = new MeasureDesc();
    FunctionDesc func = FunctionDesc.newInstance(null, null, returnType);
    desc.setFunction(func);
    return desc;
}
 
Example 17
Source File: MeasureCodecTest.java    From kylin with Apache License 2.0 4 votes vote down vote up
private MeasureDesc measure(String returnType) {
    MeasureDesc desc = new MeasureDesc();
    FunctionDesc func = FunctionDesc.newInstance(null, null, returnType);
    desc.setFunction(func);
    return desc;
}