You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kylin.apache.org by nj...@apache.org on 2016/04/18 08:34:47 UTC

[05/50] kylin git commit: KYLIN-1387 should support empty segment

KYLIN-1387 should support empty segment

Project: http://git-wip-us.apache.org/repos/asf/kylin/repo
Commit: http://git-wip-us.apache.org/repos/asf/kylin/commit/9e3fd7a0
Tree: http://git-wip-us.apache.org/repos/asf/kylin/tree/9e3fd7a0
Diff: http://git-wip-us.apache.org/repos/asf/kylin/diff/9e3fd7a0

Branch: refs/heads/1.4-rc
Commit: 9e3fd7a0136ae34fd99d2896481669b0e4e9c9f7
Parents: c0f1e6e
Author: shaofengshi <sh...@apache.org>
Authored: Tue Feb 16 09:42:34 2016 +0800
Committer: shaofengshi <sh...@apache.org>
Committed: Tue Feb 16 09:42:34 2016 +0800

----------------------------------------------------------------------
 .../hbase/steps/SequenceFileCuboidWriter.java   | 48 +++++++++++---------
 1 file changed, 26 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kylin/blob/9e3fd7a0/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/steps/SequenceFileCuboidWriter.java
----------------------------------------------------------------------
diff --git a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/steps/SequenceFileCuboidWriter.java b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/steps/SequenceFileCuboidWriter.java
index 4d76522..8c2d5e4 100644
--- a/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/steps/SequenceFileCuboidWriter.java
+++ b/storage-hbase/src/main/java/org/apache/kylin/storage/hbase/steps/SequenceFileCuboidWriter.java
@@ -25,35 +25,39 @@ public class SequenceFileCuboidWriter extends KVGTRecordWriter {
 
     public SequenceFileCuboidWriter(CubeDesc cubeDesc, CubeSegment segment) {
         super(cubeDesc, segment);
+        try {
+            initiate();
+        } catch (IOException e) {
+           throw new RuntimeException(e);
+        }
     }
 
-
-    @Override
-    protected void writeAsKeyValue(ByteArrayWritable key, ByteArrayWritable value) throws IOException {
+    protected void initiate() throws IOException {
         if (writer == null) {
-            synchronized (SequenceFileCuboidWriter.class) {
-                if (writer == null) {
-                    JobBuilderSupport jobBuilderSupport = new JobBuilderSupport(cubeSegment, "SYSTEM");
-                    String cuboidRoot = jobBuilderSupport.getCuboidRootPath(cubeSegment);
-                    Path cuboidPath = new Path(cuboidRoot);
-                    FileSystem fs = HadoopUtil.getFileSystem(cuboidRoot);
-                    try {
-                        if (fs.exists(cuboidPath)) {
-                            fs.delete(cuboidPath, true);
-                        }
-
-                        fs.mkdirs(cuboidPath);
-                    } finally {
-                        IOUtils.closeQuietly(fs);
-                    }
-
-                    Path cuboidFile = new Path(cuboidPath, "data.seq");
-                    logger.debug("Cuboid is written to " + cuboidFile);
-                    writer = SequenceFile.createWriter(HadoopUtil.getCurrentConfiguration(), SequenceFile.Writer.file(cuboidFile), SequenceFile.Writer.keyClass(Text.class), SequenceFile.Writer.valueClass(Text.class));
+            JobBuilderSupport jobBuilderSupport = new JobBuilderSupport(cubeSegment, "SYSTEM");
+            String cuboidRoot = jobBuilderSupport.getCuboidRootPath(cubeSegment);
+            Path cuboidPath = new Path(cuboidRoot);
+            FileSystem fs = HadoopUtil.getFileSystem(cuboidRoot);
+            try {
+                if (fs.exists(cuboidPath)) {
+                    fs.delete(cuboidPath, true);
                 }
+
+                fs.mkdirs(cuboidPath);
+            } finally {
+                IOUtils.closeQuietly(fs);
             }
+
+            Path cuboidFile = new Path(cuboidPath, "data.seq");
+            logger.debug("Cuboid is written to " + cuboidFile);
+            writer = SequenceFile.createWriter(HadoopUtil.getCurrentConfiguration(), SequenceFile.Writer.file(cuboidFile), SequenceFile.Writer.keyClass(Text.class), SequenceFile.Writer.valueClass(Text.class));
         }
 
+    }
+
+    @Override
+    protected void writeAsKeyValue(ByteArrayWritable key, ByteArrayWritable value) throws IOException {
+       
         Text outputValue = new Text();
         Text outputKey = new Text();
         outputKey.set(key.array(), key.offset(), key.length());