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

 ##########
 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:
   Now the mapping of CubeDesc & CubeInstance is one to one. It may not be 
necessary to have create time UTC for CubeInstance. Here, the create time UTC 
is regarded as the reinitialization time.

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to