You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kylin.apache.org by GitBox <gi...@apache.org> on 2018/09/10 08:51:31 UTC

[GitHub] shaofengshi commented on a change in pull request #222: Bug fix 2.5.0

shaofengshi commented on a change in pull request #222: Bug fix 2.5.0
URL: https://github.com/apache/kylin/pull/222#discussion_r215864641
 
 

 ##########
 File path: server-base/src/main/java/org/apache/kylin/rest/job/HybridCubeCLI.java
 ##########
 @@ -188,24 +192,33 @@ private void delete(HybridInstance hybridInstance) throws IOException {
     }
 
     private void checkSegmentOffset(List<RealizationEntry> realizationEntries) {
-        long lastOffset = -1;
+        List<Long> starts = Lists.newArrayList();
+        List<Long> ends = Lists.newArrayList();
+
         for (RealizationEntry entry : realizationEntries) {
             if (entry.getType() != RealizationType.CUBE) {
                 throw new IllegalArgumentException("Wrong realization type: " + entry.getType() + ", only cube supported. ");
             }
 
             CubeInstance cubeInstance = cubeManager.getCube(entry.getRealization());
-            CubeSegment segment = cubeInstance.getLastSegment();
-            if (segment == null)
-                continue;
-            if (lastOffset == -1) {
-                lastOffset = (Long) segment.getSegRange().end.v;
-            } else {
-                if (lastOffset > (Long) segment.getSegRange().start.v) {
-                    throw new IllegalArgumentException("Segments has overlap, could not hybrid. Last Segment End: " + lastOffset + ", Next Segment Start: " + segment.getSegRange().start.v);
+            Segments<CubeSegment> segments = cubeInstance.getSegments();
+
+            for (CubeSegment segment : segments) {
+                starts.add((Long) segment.getSegRange().start.v);
+                ends.add((Long) segment.getSegRange().end.v);
+            }
+        }
 
 Review comment:
   Can we use SegmentRange.overlaps() method to check it? You can get a list of SegmentRanges, sort them, and then check each adjacent segments have overlap? 

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services