Class ChunkReader.ChunkIterator
- java.lang.Object
-
- org.openjdk.jmc.flightrecorder.util.ChunkReader.ChunkIterator
-
- All Implemented Interfaces:
java.util.Iterator<byte[]>
- Enclosing class:
- ChunkReader
private static class ChunkReader.ChunkIterator extends java.lang.Object implements java.util.Iterator<byte[]>Chunk iterator for an uncompressed JFR file. Efficiently reads a JFR file, chunk by chunk, into memory as byte arrays by memory mapping the JFR file, finding the chunk boundaries with a minimum of parsing, and then block-transferring the byte arrays. The transfers will be done onIterator.next(), and the resulting byte array will only be reachable for as long as it is referenced. The JFR file must not be zip or gzip compressed.Note that
Iterator.next()can throwIllegalArgumentExceptionif it encounters a corrupted chunk.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.MappedByteBufferbufferprivate java.nio.channels.FileChannelchannelprivate java.io.RandomAccessFilefile(package private) intlastChunkOffset
-
Constructor Summary
Constructors Modifier Constructor Description privateChunkIterator(java.io.File jfrFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private booleanbufferHasMagic(int[] magicBytes)private booleancheckHasMore()booleanhasNext()byte[]next()voidremove()
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNextin interfacejava.util.Iterator<byte[]>
-
checkHasMore
private boolean checkHasMore()
-
next
public byte[] next()
- Specified by:
nextin interfacejava.util.Iterator<byte[]>
-
bufferHasMagic
private boolean bufferHasMagic(int[] magicBytes)
-
remove
public void remove()
- Specified by:
removein interfacejava.util.Iterator<byte[]>
-
-