docs: private Set<DataSegment> refreshSegmentsForDataSource(final String dataSource, final Set<DataSegment> segments)
        throws IOException
    {
      log.debug("Refreshing metadata for dataSource[%s].", dataSource);
  
      final long startTime = System.currentTimeMillis();
  
      // Segment id -> segment object.
      final Map<String, DataSegment> segmentMap = Maps.uniqueIndex(segments, segment -> segment.getId().toString());
  
      final Set<DataSegment> retVal = new HashSet<>();
      final Sequence<SegmentAnalysis> sequence = runSegmentMetadataQuery(
          queryLifecycleFactory,
          Iterables.limit(segments, MAX_SEGMENTS_PER_QUERY),
          escalator.createEscalatedAuthenticationResult()
      );
  
      Yielder<SegmentAnalysis> yielder = Yielders.each(sequence);
  
      try {
        while (!yielder.isDone()) {
          final SegmentAnalysis analysis = yielder.get();
          final DataSegment segment = segmentMap.get(analysis.getId());
  
          if (segment == null) {
            log.warn("Got analysis for segment[%s] we didn't ask for, ignoring.", analysis.getId());
          } else {
            synchronized (lock) {
              final RowSignature rowSignature = analysisToRowSignature(analysis);
              log.debug("Segment[%s] has signature[%s].", segment.getId(), rowSignature);
              final Map<DataSegment, AvailableSegmentMetadata> dataSourceSegments =
                  segmentMetadataInfo.get(segment.getDataSource());
              if (dataSourceSegments == null) {
                log.warn("No segment map found with datasource[%s], skipping refresh", segment.getDataSource());
              } else {
                final AvailableSegmentMetadata segmentMetadata = dataSourceSegments.get(segment);
                if (segmentMetadata == null) {
                  log.warn(
                      "No segment[%s] found, skipping refresh",
                      segment.getId()
                  );
                } else {
                  final AvailableSegmentMetadata updatedSegmentMetadata = AvailableSegmentMetadata
                      .from(segmentMetadata)
                      .withRowSignature(rowSignature)
                      .withNumRows(analysis.getNumRows())
                      .build();
                  dataSourceSegments.put(segment, updatedSegmentMetadata);
                  setAvailableSegmentMetadata(segment, updatedSegmentMetadata);
                  retVal.add(segment);
                }
              }
            }
          }
  
          yielder = yielder.next(null);
        }
      }
      finally {
        yielder.close();
      }
  
      log.info(
          "Refreshed metadata for dataSource[%s] in %,d ms (%d segments queried, %d segments left).",
          dataSource,
          System.currentTimeMillis() - startTime,
          retVal.size(),
          segments.size() - retVal.size()
      );
  
      return retVal;
    }