leventov commented on a change in pull request #7595: Optimize overshadowed segments computation URL: https://github.com/apache/incubator-druid/pull/7595#discussion_r288704366
########## File path: server/src/main/java/org/apache/druid/metadata/SQLMetadataSegmentManager.java ########## @@ -615,29 +619,30 @@ public ImmutableDruidDataSource getDataSource(String dataSourceName) @Nullable public Collection<ImmutableDruidDataSource> getDataSources() { - return Optional.ofNullable(dataSources) - .map(m -> - m.values() - .stream() - .map(DruidDataSource::toImmutableDruidDataSource) - .collect(Collectors.toList()) - ) - .orElse(null); + return Optional.ofNullable(dataSourcesSnapshot).map(m -> m.getDataSources()).orElse(null); } @Override @Nullable public Iterable<DataSegment> iterateAllSegments() { - final ConcurrentHashMap<String, DruidDataSource> dataSourcesSnapshot = dataSources; - if (dataSourcesSnapshot == null) { + final Collection<ImmutableDruidDataSource> dataSources = Optional.ofNullable(dataSourcesSnapshot) + .map(m -> m.getDataSources()) + .orElse(null); + if (dataSources == null) { return null; } - return () -> dataSourcesSnapshot.values() - .stream() - .flatMap(dataSource -> dataSource.getSegments().stream()) - .iterator(); + return () -> dataSources.stream() + .flatMap(dataSource -> dataSource.getSegments().stream()) + .iterator(); + } + + @Override + @Nullable + public Set<SegmentId> getOvershadowedSegments() Review comment: Just wrapping/unwrapping objects into snapshot doesn't magically eliminate the race. You have to pass around the snapshot. ---------------------------------------------------------------- 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