package org.apache.kylin.engine.mr.steps;

import java.io.IOException;
import java.util.Map;
import java.util.UUID;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.kylin.measure.hllc.HyperLogLogPlusCounter;
import org.apache.kylin.engine.mr.HadoopUtil;
import org.apache.kylin.engine.mr.common.CuboidStatsUtil;
import org.junit.Test;

import com.google.common.collect.Maps;

/**
 */
public class FactDistinctColumnsReducerTest {

    @Test
    public void testWriteCuboidStatistics() throws IOException {

        final Configuration conf = HadoopUtil.getCurrentConfiguration();
        final Path outputPath = new Path("file:///tmp/kylin/cuboidstatistics/" + UUID.randomUUID().toString());
        if (!FileSystem.getLocal(conf).exists(outputPath)) {
            //            FileSystem.getLocal(conf).create(outputPath);
        }

        System.out.println(outputPath);
        Map<Long, HyperLogLogPlusCounter> cuboidHLLMap = Maps.newHashMap();
        CuboidStatsUtil.writeCuboidStatistics(conf, outputPath, cuboidHLLMap, 100);
        FileSystem.getLocal(conf).delete(outputPath, true);

    }
}

@@ -36,16 +36,37 @@
 steps;%0A%0A
+import java.io.File;%0A
 import j
@@ -695,78 +695,148 @@
     
-final Path outputPath = new Path(%22file:///tmp/kylin/cuboidstatistics/%22
+File tmp = File.createTempFile(%22cuboidstatistics%22, %22%22);%0A        final Path outputPath = new Path(tmp.getParent().toString() + File.separator
  + U

fix hardcoded path in FactDistinctColumnsReducerTest.java