private static Map<SegmentId, DataSegment> createLazySegmentsMap(DruidServer server)
  {
    return new AbstractMap<SegmentId, DataSegment>()
    {
      @Override
      public Set<Entry<SegmentId, DataSegment>> entrySet()
      {
        return new AbstractSet<Entry<SegmentId, DataSegment>>()
        {
          @Override
          public Iterator<Entry<SegmentId, DataSegment>> iterator()
          {
            return Iterators.transform(
                server.iterateAllSegments().iterator(),
                segment -> new AbstractMap.SimpleImmutableEntry<>(segment.getId(), segment)
            );
          }

          @Override
          public int size()
          {
            return server.getTotalSegments();
          }
        };
      }
    };
  }
private static Map < SegmentId , DataSegment > createLazySegmentsMap ( DruidServer server ) { return new AbstractMap < SegmentId , DataSegment > ( ) { @ Override public Set < Entry < SegmentId , DataSegment > > entrySet ( ) { return new AbstractSet < Entry < SegmentId , DataSegment > > ( ) { @ Override public Iterator < Entry < SegmentId , DataSegment > > iterator ( ) { return Iterators . transform ( server . iterateAllSegments ( ) . iterator ( ) , segment -> new AbstractMap . SimpleImmutableEntry < > ( segment . getId ( ) , segment ) ) ; } @ Override public int size ( ) { return server . getTotalSegments ( ) ; } } ; } } ; }
Emitting this map with "full" options in this resource is excessive because segment ids are repeated in the keys
*and* values, but is done so for compatibility with the existing HTTP JSON API.

Returns a lazy map suitable for serialization (i. e. entrySet iteration) only, relying on the fact that the
segments returned from {@link DruidServer#iterateAllSegments()} are unique. This is not a part of the {@link
DruidServer} API to not let abuse this map (like trying to get() from it).