Package htsjdk.samtools.util

# Class SAMRecordPrefetchingIterator

java.lang.Object
htsjdk.samtools.util.SAMRecordPrefetchingIterator

All Implemented Interfaces:
  `CloseableIterator<SAMRecord>`, `Closeable`, `AutoCloseable`, `Iterator<SAMRecord>`

public class SAMRecordPrefetchingIterator extends Object implements CloseableIterator<SAMRecord>
Iterator that uses a dedicated background thread to prefetch SAMRecords, reading ahead by a set number of bases to improve throughput.

Note that this implementation is not synchronized. If multiple threads access an instance concurrently, it must be synchronized externally.

## Constructor Summary

Constructors
Constructor
Description
`SAMRecordPrefetchingIterator(CloseableIterator<SAMRecord> iterator, int basePrefetchLimit)`
Creates a new iterator that traverses the given iterator on a background thread

## Method Summary

Modifier and Type
Method
Description
`void`
`close()`
Should be implemented to close/release any underlying resources.
`boolean`
`hasNext()`
`SAMRecord`
`next()`
`protected int`
`readsInQueue()`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface htsjdk.samtools.util.CloseableIterator

`stream, toList`

### Methods inherited from interface java.util.Iterator

`forEachRemaining, remove`

## Constructor Details

### SAMRecordPrefetchingIterator

public SAMRecordPrefetchingIterator(CloseableIterator<SAMRecord> iterator, int basePrefetchLimit)
Creates a new iterator that traverses the given iterator on a background thread

Parameters:
  `iterator` - the iterator to traverse
  `basePrefetchLimit` - the number of bases to prefetch

## Method Details

### close

public void close()
Description copied from interface: `CloseableIterator`
Should be implemented to close/release any underlying resources.

Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `CloseableIterator<SAMRecord>`

### hasNext

public boolean hasNext()

Specified by:
  `hasNext` in interface `Iterator<SAMRecord>`

### next

public SAMRecord next()

Specified by:
  `next` in interface `Iterator<SAMRecord>`

### readsInQueue

protected int readsInQueue()