leventov commented on a change in pull request #7350: Remove unnecessary
collection
URL: https://github.com/apache/incubator-druid/pull/7350#discussion_r274965983
##########
File path:
server/src/main/java/org/apache/druid/server/http/MetadataResource.java
##########
@@ -161,14 +153,11 @@ public Response getDatabaseSegments(
// If we haven't polled the metadata store yet, use an empty list of
datasources.
Collection<ImmutableDruidDataSource> druidDataSources =
Optional.ofNullable(metadataSegmentManager.getDataSources())
.orElse(Collections.emptyList());
-
- if (datasources != null && !datasources.isEmpty()) {
- druidDataSources = druidDataSources.stream()
- .filter(src ->
datasources.contains(src.getName()))
- .collect(Collectors.toSet());
- }
final Stream<DataSegment> metadataSegments = druidDataSources
.stream()
+ .filter((datasources != null && !datasources.isEmpty())
+ ? src -> datasources.contains(src.getName())
+ : src -> true)
Review comment:
This code is not readable.
Please extract a stream variable and apply a filter only if the condition
applies.
----------------------------------------------------------------
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]