Java Code Examples for org.apache.kylin.cube.model.RowKeyColDesc#isUsingDictionary()

The following examples show how to use org.apache.kylin.cube.model.RowKeyColDesc#isUsingDictionary() . 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: RowRecordReader.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
private Map<String, DimensionEncoding> getDimensionEncodings(FragmentMetaInfo fragmentMetaInfo,
        List<DimensionMetaInfo> allDimensions, FSDataInputStream dictInputStream) throws IOException {
    Map<String, Dictionary> dictionaryMap = readAllDimensionsDictionary(fragmentMetaInfo, dictInputStream);

    Map<String, DimensionEncoding> result = Maps.newHashMap();
    for (DimensionMetaInfo dimension : allDimensions) {
        TblColRef col = cubeDesc.getModel().findColumn(dimension.getName());
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
        if (colDesc.isUsingDictionary()) {
            @SuppressWarnings({ "unchecked" })
            Dictionary<String> dict = dictionaryMap.get(dimension.getName());
            if (dict == null) {
                logger.error("No dictionary found for dict-encoding column " + col);
                throw new RuntimeException("No dictionary found for dict-encoding column " + col);
            } else {
                result.put(dimension.getName(), new DictionaryDimEnc(dict));
            }
        } else {
            result.put(
                    dimension.getName(),
                    DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(),
                            colDesc.getEncodingVersion()));
        }
    }
    return result;
}
 
Example 2
Source File: CubeDimEncMap.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
@Override
public DimensionEncoding get(TblColRef col) {
    DimensionEncoding result = encMap.get(col);
    if (result == null) {
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
        if (colDesc.isUsingDictionary()) {
            // special dictionary encoding
            Dictionary<String> dict = getDictionary(col);
            if (dict == null) {
                logger.warn("No dictionary found for dict-encoding column " + col + ", segment " + seg);
                result = new FixedLenDimEnc(0);
            } else {
                result = new DictionaryDimEnc(dict);
            }
        } else {
            // normal case
            result = DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(), colDesc.getEncodingVersion());
        }
        encMap.put(col, result);
    }
    return result;
}
 
Example 3
Source File: ParsedStreamingCubeInfo.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
public static DimensionEncoding[] getDimensionEncodings(CubeDesc cubeDesc, TblColRef[] dimensions,
        Map<TblColRef, Dictionary<String>> dimDictMap) {
    DimensionEncoding[] result = new DimensionEncoding[dimensions.length];
    for (int i = 0; i < dimensions.length; i++) {
        TblColRef dimension = dimensions[i];
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(dimension);
        if (colDesc.isUsingDictionary()) {
            @SuppressWarnings({ "unchecked" })
            Dictionary<String> dict = dimDictMap.get(dimension);
            if (dict == null) {
                throw new RuntimeException("No dictionary found for dict-encoding column " + dimension);
            } else {
                result[i] = new DictionaryDimEnc(dict);
            }
        } else {
            result[i] = DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(),
                    colDesc.getEncodingVersion());
        }
    }
    return result;
}
 
Example 4
Source File: RowRecordReader.java    From kylin with Apache License 2.0 6 votes vote down vote up
private Map<String, DimensionEncoding> getDimensionEncodings(FragmentMetaInfo fragmentMetaInfo,
        List<DimensionMetaInfo> allDimensions, FSDataInputStream dictInputStream) throws IOException {
    Map<String, Dictionary> dictionaryMap = readAllDimensionsDictionary(fragmentMetaInfo, dictInputStream);

    Map<String, DimensionEncoding> result = Maps.newHashMap();
    for (DimensionMetaInfo dimension : allDimensions) {
        TblColRef col = cubeDesc.getModel().findColumn(dimension.getName());
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
        if (colDesc.isUsingDictionary()) {
            @SuppressWarnings({ "unchecked" })
            Dictionary<String> dict = dictionaryMap.get(dimension.getName());
            if (dict == null) {
                logger.error("No dictionary found for dict-encoding column " + col);
                throw new RuntimeException("No dictionary found for dict-encoding column " + col);
            } else {
                result.put(dimension.getName(), new DictionaryDimEnc(dict));
            }
        } else {
            result.put(
                    dimension.getName(),
                    DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(),
                            colDesc.getEncodingVersion()));
        }
    }
    return result;
}
 
Example 5
Source File: CubeDimEncMap.java    From kylin with Apache License 2.0 6 votes vote down vote up
@Override
public DimensionEncoding get(TblColRef col) {
    DimensionEncoding result = encMap.get(col);
    if (result == null) {
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(col);
        if (colDesc.isUsingDictionary()) {
            // special dictionary encoding
            Dictionary<String> dict = getDictionary(col);
            if (dict == null) {
                logger.warn("No dictionary found for dict-encoding column " + col + ", segment " + seg);
                result = new FixedLenDimEnc(0);
            } else {
                result = new DictionaryDimEnc(dict);
            }
        } else {
            // normal case
            result = DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(), colDesc.getEncodingVersion());
        }
        encMap.put(col, result);
    }
    return result;
}
 
Example 6
Source File: ParsedStreamingCubeInfo.java    From kylin with Apache License 2.0 6 votes vote down vote up
public static DimensionEncoding[] getDimensionEncodings(CubeDesc cubeDesc, TblColRef[] dimensions,
        Map<TblColRef, Dictionary<String>> dimDictMap) {
    DimensionEncoding[] result = new DimensionEncoding[dimensions.length];
    for (int i = 0; i < dimensions.length; i++) {
        TblColRef dimension = dimensions[i];
        RowKeyColDesc colDesc = cubeDesc.getRowkey().getColDesc(dimension);
        if (colDesc.isUsingDictionary()) {
            @SuppressWarnings({ "unchecked" })
            Dictionary<String> dict = dimDictMap.get(dimension);
            if (dict == null) {
                throw new RuntimeException("No dictionary found for dict-encoding column " + dimension);
            } else {
                result[i] = new DictionaryDimEnc(dict);
            }
        } else {
            result[i] = DimensionEncodingFactory.create(colDesc.getEncodingName(), colDesc.getEncodingArgs(),
                    colDesc.getEncodingVersion());
        }
    }
    return result;
}