You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2019/04/05 20:41:21 UTC

[GitHub] [incubator-druid] egor-ryashin commented on a change in pull request #7306: Reconcile terminology and method naming to 'used/unused segments'; Rename MetadataSegmentManager to MetadataSegments

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


With regards,
Apache Git Services

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