shaofengshi commented on a change in pull request #408: KYLIN-3655 reinitialize 
CubeInstance when clear segments
URL: https://github.com/apache/kylin/pull/408#discussion_r243721883
 
 

 ##########
 File path: core-cube/src/main/java/org/apache/kylin/cube/CubeManager.java
 ##########
 @@ -256,6 +256,23 @@ public CubeInstance createCube(CubeInstance cube, String 
projectName, String own
         }
     }
 
+    /**
+     * when clear all segments, it's supposed to reinitialize the CubeInstance
+     */
+    public CubeInstance clearSegments(CubeInstance cube) throws IOException {
+        try (AutoLock lock = cubeMapLock.lockForWrite()) {
+            cube = cube.latestCopyForWrite(); // get a latest copy
+            CubeUpdate update = new CubeUpdate(cube);
+            update.setToRemoveSegs(cube.getSegments().toArray(new 
CubeSegment[cube.getSegments().size()]));
+            update.setCuboids(Maps.<Long, Long> newHashMap());
+            update.setCuboidsRecommend(Sets.<Long> newHashSet());
+            update.setUpdateTableSnapshotPath(Maps.<String, String> 
newHashMap());
+            update.setCreateTimeUTC(System.currentTimeMillis());
 
 Review comment:
   What's the reason to update the "createTimeUTC"? 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to