jtuglu1 commented on code in PR #19718:
URL: https://github.com/apache/druid/pull/19718#discussion_r3633779034
##########
sql/src/main/java/org/apache/druid/sql/calcite/schema/MetadataSegmentView.java:
##########
@@ -185,12 +189,28 @@ private void poll()
*/
Iterator<SegmentStatusInCluster> getSegments()
{
+ return getSegments(null);
+ }
+
+ /**
+ * Returns published (and, with centralized schema, realtime) segment
metadata, optionally
+ * restricted to {@code dataSources} - a {@code datasource} predicate pushed
down from sys.segments.
+ * The restriction is a cheap membership test applied before the caller's
authorization and row
+ * construction, so segments of non-matching datasources skip that per-row
work.
+ */
+ Iterator<SegmentStatusInCluster> getSegments(@Nullable Set<String>
dataSources)
+ {
+ final Iterator<SegmentStatusInCluster> base;
if (isCacheEnabled) {
Uninterruptibles.awaitUninterruptibly(cachePopulated);
- return publishedSegments.iterator();
+ base = publishedSegments.iterator();
} else {
- return fetchSegmentMetadataFromCoordinator();
+ // Cache disabled: the Coordinator returns all used segments; filter
client-side to preserve semantics.
+ base = fetchSegmentMetadataFromCoordinator();
}
+ return dataSources == null
+ ? base
+ : Iterators.filter(base, s ->
dataSources.contains(s.getDataSegment().getDataSource()));
Review Comment:
sure, something similar will also be added as a follow-up to speed up the
rest of the aggregation queries (mainly UI-issued).
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]