indexing-service/src/main/java/org/apache/druid/indexing/input/DruidSegmentReader.java
/**
   * @param sequence    A sequence of intermediate rows generated from a sequence of
   *                    cursors in {@link #intermediateRowIterator()}
   * @param segmentFile The underlying segment file containing the row data
   *
   * @return A CloseableIterator from a sequence of intermediate rows, closing the underlying segment file
   * when the iterator is closed.
   */
@param sequence    A sequence of intermediate rows generated from a sequence of
cursors in  #intermediateRowIterator()
@param segmentFile The underlying segment file containing the row data

@return A CloseableIterator from a sequence of intermediate rows, closing the underlying segment file
when the iterator is closed.
@param sequence A sequence of intermediate rows generated from a sequence of cursors in #intermediateRowIterator () @param segmentFile The underlying segment file containing the row data @return A CloseableIterator from a sequence of intermediate rows closing the underlying segment file when the iterator is closed .
@VisibleForTesting
  static CloseableIterator<Map<String, Object>> makeCloseableIteratorFromSequenceAndSegmentFile(
      final Sequence<Map<String, Object>> sequence,
      final CleanableFile segmentFile
  )
  {
    return new CloseableIterator<Map<String, Object>>()
    {
      Yielder<Map<String, Object>> rowYielder = Yielders.each(sequence);
      @Override
      public boolean hasNext()
      {
        return !rowYielder.isDone();
      }
      @Override
      public Map<String, Object> next()
      {
        final Map<String, Object> row = rowYielder.get();
        rowYielder = rowYielder.next(null);
        return row;
      }
      @Override
      public void close() throws IOException
      {
        CloseableUtils.closeAll(rowYielder, segmentFile);
      }
    };
  }
@ VisibleForTesting static CloseableIterator < Map < String , Object > > makeCloseableIteratorFromSequenceAndSegmentFile ( final Sequence < Map < String , Object > > sequence , final CleanableFile segmentFile ) { return new CloseableIterator < Map < String , Object > > ( ) { Yielder < Map < String , Object > > rowYielder = Yielders . each ( sequence ) ; @ Override public boolean hasNext ( ) { return ! rowYielder . isDone ( ) ; } @ Override public Map < String , Object > next ( ) { final Map < String , Object > row = rowYielder . get ( ) ; rowYielder = rowYielder . next ( null ) ; return row ; } @ Override public void close ( ) throws IOException { CloseableUtils . closeAll ( rowYielder , segmentFile ) ; } } ; }
@param sequence    A sequence of intermediate rows generated from a sequence of
                    cursors in {@link #intermediateRowIterator()}
 @param segmentFile The underlying segment file containing the row data
@param sequence A sequence of intermediate rows generated from a sequence of cursors in { @link #intermediateRowIterator () } @param segmentFile The underlying segment file containing the row data