leventov commented on a change in pull request #7185: Avoid many unnecessary 
materializations of collections of 'all segments in cluster' cardinality
URL: https://github.com/apache/incubator-druid/pull/7185#discussion_r264413165
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/metadata/MetadataSegmentManager.java
 ##########
 @@ -59,6 +60,8 @@
 
   Collection<ImmutableDruidDataSource> getDataSources();
 
+  Iterable<DataSegment> iterateAllSegments();
 
 Review comment:
   Creation of the iterable is cheap, but the creation of the underlying 
*iteration* is not cheap. This method discourages iterating twice on the 
result, and, in fact, even storing the result in a variable, but rather 
immediately consuming it, as it happens in all use cases: they look either like
   ```java
   for (DataSegment s : iterateAllSegments()) {
     ..
   }
   ```
   or
   ```java
   iterateAllSegments().forEach(s -> ...);
   ```
   or feeded into `Iterables.transform()`, which happens in 
`DruidCoordinatorSegmentInfoLoader`.
   
   I think the prefix `iterate` reflects this sense of discouragement well. 
People may feel a little uncomfortable storing an iterable returned from such 
method in a variable, but the constructions above look perfectly OK. 
`getIterable()` doesn't such sense of uncomfortableness.

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