Java Code Examples for org.apache.kylin.common.util.HadoopUtil#setCurrentConfiguration()

The following examples show how to use org.apache.kylin.common.util.HadoopUtil#setCurrentConfiguration() . 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: AbstractHadoopJob.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
public static KylinConfig loadKylinConfigFromHdfs(SerializableConfiguration conf, String uri) {
    HadoopUtil.setCurrentConfiguration(conf.get());
    KylinConfig config = loadKylinConfigFromHdfs(uri);

    // This is a bad example where the thread local KylinConfig cannot be auto-closed due to
    // limitation of MR API. It works because MR task runs its own process. Do not copy.
    @SuppressWarnings("unused")
    SetAndUnsetThreadLocalConfig shouldAutoClose = KylinConfig.setAndUnsetThreadLocalConfig(config);

    return config;
}
 
Example 2
Source File: NGlobalDictionaryV2Test.java    From kylin-on-parquet-v2 with Apache License 2.0 5 votes vote down vote up
private void initFs() {
    DebugFilesystem.clearOpenStreams();
    Configuration conf = new Configuration();
    conf.set("fs.file.impl", DebugFilesystem.class.getCanonicalName());
    conf.set("fs.file.impl.disable.cache", "true");
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 3
Source File: AbstractHadoopJob.java    From kylin with Apache License 2.0 5 votes vote down vote up
public static KylinConfig loadKylinConfigFromHdfs(SerializableConfiguration conf, String uri) {
    HadoopUtil.setCurrentConfiguration(conf.get());
    KylinConfig config = loadKylinConfigFromHdfs(uri);

    // This is a bad example where the thread local KylinConfig cannot be auto-closed due to
    // limitation of MR API. It works because MR task runs its own process. Do not copy.
    @SuppressWarnings("unused")
    SetAndUnsetThreadLocalConfig shouldAutoClose = KylinConfig.setAndUnsetThreadLocalConfig(config);

    return config;
}
 
Example 4
Source File: CalculateStatsFromBaseCuboidMapper.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
@Override
protected void doSetup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();
    HadoopUtil.setCurrentConfiguration(conf);
    KylinConfig config = AbstractHadoopJob.loadKylinPropsAndMetadata();

    String cubeName = conf.get(BatchConstants.CFG_CUBE_NAME);
    CubeInstance cube = CubeManager.getInstance(config).getCube(cubeName);
    CubeDesc cubeDesc = cube.getDescriptor();
    CubeSegment cubeSegment = cube.getSegmentById(conf.get(BatchConstants.CFG_CUBE_SEGMENT_ID));

    baseCuboidId = cube.getCuboidScheduler().getBaseCuboidId();
    nRowKey = cubeDesc.getRowkey().getRowKeyColumns().length;

    String cuboidModeName = conf.get(BatchConstants.CFG_CUBOID_MODE);
    Set<Long> cuboidIdSet = cube.getCuboidsByMode(cuboidModeName);

    cuboidIds = cuboidIdSet.toArray(new Long[cuboidIdSet.size()]);
    allCuboidsBitSet = CuboidUtil.getCuboidBitSet(cuboidIds, nRowKey);

    samplingPercentage = Integer
            .parseInt(context.getConfiguration().get(BatchConstants.CFG_STATISTICS_SAMPLING_PERCENT));

    allCuboidsHLL = new HLLCounter[cuboidIds.length];
    for (int i = 0; i < cuboidIds.length; i++) {
        allCuboidsHLL[i] = new HLLCounter(cubeDesc.getConfig().getCubeStatsHLLPrecision());
    }

    //for KYLIN-2518 backward compatibility
    if (KylinVersion.isBefore200(cubeDesc.getVersion())) {
        isUsePutRowKeyToHllNewAlgorithm = false;
        hf = Hashing.murmur3_32();
        logger.info("Found KylinVersion : {}. Use old algorithm for cuboid sampling.", cubeDesc.getVersion());
    } else {
        isUsePutRowKeyToHllNewAlgorithm = true;
        rowHashCodesLong = new long[nRowKey];
        hf = Hashing.murmur3_128();
        logger.info(
                "Found KylinVersion : {}. Use new algorithm for cuboid sampling. About the details of the new algorithm, please refer to KYLIN-2518",
                cubeDesc.getVersion());
    }

    rowKeyDecoder = new RowKeyDecoder(cubeSegment);
}
 
Example 5
Source File: KylinReducer.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
protected void bindCurrentConfiguration(Configuration conf) {
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 6
Source File: KylinMapper.java    From kylin-on-parquet-v2 with Apache License 2.0 4 votes vote down vote up
protected void bindCurrentConfiguration(Configuration conf) {
    logger.info("The conf for current mapper will be " + System.identityHashCode(conf));
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 7
Source File: CalculateStatsFromBaseCuboidMapper.java    From kylin with Apache License 2.0 4 votes vote down vote up
@Override
protected void doSetup(Context context) throws IOException {
    Configuration conf = context.getConfiguration();
    HadoopUtil.setCurrentConfiguration(conf);
    KylinConfig config = AbstractHadoopJob.loadKylinPropsAndMetadata();

    String cubeName = conf.get(BatchConstants.CFG_CUBE_NAME);
    CubeInstance cube = CubeManager.getInstance(config).getCube(cubeName);
    CubeDesc cubeDesc = cube.getDescriptor();
    CubeSegment cubeSegment = cube.getSegmentById(conf.get(BatchConstants.CFG_CUBE_SEGMENT_ID));

    baseCuboidId = cube.getCuboidScheduler().getBaseCuboidId();
    nRowKey = cubeDesc.getRowkey().getRowKeyColumns().length;

    String cuboidModeName = conf.get(BatchConstants.CFG_CUBOID_MODE);
    Set<Long> cuboidIdSet = cube.getCuboidsByMode(cuboidModeName);

    cuboidIds = cuboidIdSet.toArray(new Long[cuboidIdSet.size()]);
    allCuboidsBitSet = CuboidUtil.getCuboidBitSet(cuboidIds, nRowKey);

    samplingPercentage = Integer
            .parseInt(context.getConfiguration().get(BatchConstants.CFG_STATISTICS_SAMPLING_PERCENT));

    allCuboidsHLL = new HLLCounter[cuboidIds.length];
    for (int i = 0; i < cuboidIds.length; i++) {
        allCuboidsHLL[i] = new HLLCounter(cubeDesc.getConfig().getCubeStatsHLLPrecision());
    }

    //for KYLIN-2518 backward compatibility
    if (KylinVersion.isBefore200(cubeDesc.getVersion())) {
        isUsePutRowKeyToHllNewAlgorithm = false;
        hf = Hashing.murmur3_32();
        logger.info("Found KylinVersion : {}. Use old algorithm for cuboid sampling.", cubeDesc.getVersion());
    } else {
        isUsePutRowKeyToHllNewAlgorithm = true;
        rowHashCodesLong = new long[nRowKey];
        hf = Hashing.murmur3_128();
        logger.info(
                "Found KylinVersion : {}. Use new algorithm for cuboid sampling. About the details of the new algorithm, please refer to KYLIN-2518",
                cubeDesc.getVersion());
    }

    rowKeyDecoder = new RowKeyDecoder(cubeSegment);
}
 
Example 8
Source File: KylinReducer.java    From kylin with Apache License 2.0 4 votes vote down vote up
protected void bindCurrentConfiguration(Configuration conf) {
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 9
Source File: KylinMapper.java    From kylin with Apache License 2.0 4 votes vote down vote up
protected void bindCurrentConfiguration(Configuration conf) {
    logger.info("The conf for current mapper will be " + System.identityHashCode(conf));
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 10
Source File: KylinReducer.java    From Kylin with Apache License 2.0 4 votes vote down vote up
protected void publishConfiguration(Configuration conf) {
    HadoopUtil.setCurrentConfiguration(conf);
}
 
Example 11
Source File: KylinMapper.java    From Kylin with Apache License 2.0 4 votes vote down vote up
protected void publishConfiguration(Configuration conf) {
    HadoopUtil.setCurrentConfiguration(conf);
}