leventov commented on a change in pull request #6901: Introduce published 
segment cache in broker
URL: https://github.com/apache/incubator-druid/pull/6901#discussion_r265741002
 
 

 ##########
 File path: 
server/src/main/java/org/apache/druid/server/http/MetadataResource.java
 ##########
 @@ -148,14 +149,22 @@ public Response 
getDatabaseSegmentDataSource(@PathParam("dataSourceName") final
   @GET
   @Path("/segments")
   @Produces(MediaType.APPLICATION_JSON)
-  public Response getDatabaseSegments(@Context final HttpServletRequest req)
+  public Response getDatabaseSegments(
+      @Context final HttpServletRequest req,
+      @QueryParam("datasources") final Set<String> datasources
+  )
   {
-    final Collection<ImmutableDruidDataSource> druidDataSources = 
metadataSegmentManager.getDataSources();
+    Collection<ImmutableDruidDataSource> druidDataSources = 
metadataSegmentManager.getDataSources();
+    if (datasources != null && !datasources.isEmpty()) {
+      druidDataSources = druidDataSources.stream()
+                                         .filter(src -> 
datasources.contains(src.getName()))
+                                         .collect(Collectors.toSet());
 
 Review comment:
   @surekhasaharan you don't want to collect ImmutableDruidDataSource objects, 
which are already known to be unique here, into a set. It induces expensive 
O(n) hash code computations (which is also totally unnecessary; 
`ImmutableDruidDataSource.hashCode()` should be cheaper. But that's another 
question.)

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