jon-wei commented on a change in pull request #7547: Add support minor 
compaction with segment locking
URL: https://github.com/apache/incubator-druid/pull/7547#discussion_r297428870
 
 

 ##########
 File path: 
core/src/main/java/org/apache/druid/timeline/VersionedIntervalTimeline.java
 ##########
 @@ -453,39 +485,60 @@ private boolean addAtKey(
     }
 
     while (entryInterval != null && currKey != null && 
currKey.overlaps(entryInterval)) {
-      Interval nextKey = timeline.higherKey(currKey);
+      final Interval nextKey = timeline.higherKey(currKey);
 
-      int versionCompare = versionComparator.compare(
+      final int versionCompare = versionComparator.compare(
           entry.getVersion(),
           timeline.get(currKey).getVersion()
       );
 
       if (versionCompare < 0) {
+        // since the entry version is lower than the existing one, the 
existing one overwrites the given entry if overlapped.
         if (currKey.contains(entryInterval)) {
+          // the version of the entry of currKey is larger than that of the 
given entry. Discard it
           return true;
         } else if (currKey.getStart().isBefore(entryInterval.getStart())) {
+          //     | cur |
+          //       | entry |
+          // =>        |new|
           entryInterval = new Interval(currKey.getEnd(), 
entryInterval.getEnd());
         } else {
+          //     | entry |
+          //         | cur |
+          // =>  |new|
           addIntervalToTimeline(new Interval(entryInterval.getStart(), 
currKey.getStart()), entry, timeline);
 
+          //     |   entry   |
 
 Review comment:
   I like the pictorial comments here :+1:
   
   For the last case, I think it would be helpful if there were an additional 
comment about how there may or may not be a portion of `entryInterval` that 
goes past `currKey`, and I think the `discard this entry` comment below would 
be more clear if it's something along the lines of "there is no portion of the 
entry interval that goes past the end of the curr key interval"

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to