leventov commented on a change in pull request #7306: Reconcile terminology and 
method naming to 'used/unused segments'; Rename MetadataSegmentManager to 
MetadataSegments
URL: https://github.com/apache/incubator-druid/pull/7306#discussion_r273615203
 
 

 ##########
 File path: 
core/src/main/java/org/apache/druid/timeline/VersionedIntervalTimeline.java
 ##########
 @@ -115,6 +122,32 @@ public static void addSegments(
     return allTimelineEntries;
   }
 
+  /**
+   * Returns a lazy collection with all objects in this 
VersionedIntervalTimeline to be used for iteration or {@link
+   * Collection#stream()} transformation. The order of objects in this 
collection is unspecified.
+   *
+   * Note: iteration over the returned collection may not be as trivially 
cheap as, for example, iteration over an
+   * ArrayList. Try (to some reasonable extent) to organize the code so that 
it iterates the returned collection only
+   * once rather than several times.
+   */
+  public Collection<ObjectType> iterateAllObjects()
+  {
+    return CollectionUtils.createLazyCollectionFromStream(
+        () -> allTimelineEntries
+            .values()
+            .stream()
+            .flatMap((TreeMap<VersionType, TimelineEntry> entryMap) -> 
entryMap.values().stream())
+            .flatMap((TimelineEntry entry) -> 
StreamSupport.stream(entry.getPartitionHolder().spliterator(), false))
+            .map(PartitionChunk::getObject),
+        numObjects.get()
+    );
 
 Review comment:
   I've factored this method out of `DruidCoordinatorLogger`, see this change: 
https://github.com/apache/incubator-druid/pull/7306/files#diff-b3571a010cbbb3cb648676a89936a51fL266.
 So you don't need to have a deep understanding of `VersionedIntervalTimeline` 
to check it. I don't have such understanding either.
   
   I've raised https://github.com/apache/incubator-druid/issues/7433 about your 
question.

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


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org
For additional commands, e-mail: commits-h...@druid.apache.org

Reply via email to