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_r263144931
##########
File path:
server/src/main/java/org/apache/druid/server/coordinator/DruidCoordinatorRuntimeParams.java
##########
@@ -346,22 +352,35 @@ public Builder
withDataSources(Collection<ImmutableDruidDataSource> dataSourcesC
return this;
}
+ /** This method must be used in test code only. */
@VisibleForTesting
- public Builder withAvailableSegments(DataSegment... availableSegments)
+ public Builder withAvailableSegmentsInTest(DataSegment...
availableSegments)
{
- this.availableSegments.addAll(Arrays.asList(availableSegments));
- return this;
+ return withAvailableSegmentsInTest(Arrays.asList(availableSegments));
}
- public Builder withAvailableSegments(Collection<DataSegment>
availableSegments)
+ /** This method must be used in test code only. */
+ @VisibleForTesting
+ public Builder withAvailableSegmentsInTest(Collection<DataSegment>
availableSegments)
{
-
this.availableSegments.addAll(Collections.unmodifiableCollection(availableSegments));
+ TreeSet<DataSegment> availableSegmentSet = createAvailableSegmentsSet();
+ availableSegmentSet.addAll(availableSegments);
+ return setAvailableSegments(availableSegmentSet);
+ }
+
+ public Builder setAvailableSegments(TreeSet<DataSegment> availableSegments)
Review comment:
Semantics of `withAvailableSegments()` are different from
`setAvailableSegments()`: the former makes a (defensive) copy of the passed
collection. The latter doesn't. Those who call `setAvailableSegments()` should
be aware that if they modify the collection that they passed into this method
afterwards, the "internal" set of segments for Params will be updated too
(simply because this is the same object).
I'll add a Javadoc comment.
----------------------------------------------------------------
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]