egor-ryashin 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_r272737017
 
 

 ##########
 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 been trying to understand if it's correct which led me to 
`TimelineObjectHolder` with confusing fields `interval` and `trueInterval` 
without description. Could you provide a description for those?

----------------------------------------------------------------
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