leventov commented on a change in pull request #7306: Reconcile terminology and
method naming to 'used/unused segments'; Rename MetadataSegmentManager to
MetadataSegments
URL: https://github.com/apache/incubator-druid/pull/7306#discussion_r274540701
##########
File path:
server/src/main/java/org/apache/druid/server/coordinator/helper/DruidCoordinatorLogger.java
##########
@@ -263,28 +259,25 @@ public DruidCoordinatorRuntimeParams
run(DruidCoordinatorRuntimeParams params)
);
// Emit segment metrics
- final Stream<DataSegment> allSegments = params
- .getDataSources()
- .values()
- .stream()
- .flatMap(timeline ->
timeline.getAllTimelineEntries().values().stream())
- .flatMap(entryMap -> entryMap.values().stream())
- .flatMap(entry ->
StreamSupport.stream(entry.getPartitionHolder().spliterator(), false))
- .map(PartitionChunk::getObject);
-
- allSegments
- .collect(Collectors.groupingBy(DataSegment::getDataSource))
- .forEach((final String name, final List<DataSegment> segments) -> {
- final long size =
segments.stream().mapToLong(DataSegment::getSize).sum();
+ params.getDataSourcesWithUsedSegments().forEach(
+ (String dataSource, VersionedIntervalTimeline<String, DataSegment>
dataSourceWithUsedSegments) -> {
+ long totalSizeOfUsedSegments = dataSourceWithUsedSegments
+ .iterateAllObjects()
+ .stream()
+ .mapToLong(DataSegment::getSize)
+ .sum();
emitter.emit(
- new
ServiceMetricEvent.Builder().setDimension(DruidMetrics.DATASOURCE,
name).build("segment/size", size)
+ new ServiceMetricEvent.Builder()
+ .setDimension(DruidMetrics.DATASOURCE, dataSource)
+ .build("segment/size", totalSizeOfUsedSegments)
);
emitter.emit(
new ServiceMetricEvent.Builder()
- .setDimension(DruidMetrics.DATASOURCE, name)
- .build("segment/count", segments.size())
+ .setDimension(DruidMetrics.DATASOURCE, dataSource)
+ .build("segment/count",
dataSourceWithUsedSegments.getNumObjects())
Review comment:
I would keep it this way. The alternative, collecting LongSummaryStatistics
and extracting the count and the sum from it, looks more cumbersome to me to
not justify the tiny increase in consistency.
----------------------------------------------------------------
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]