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 throwIllegalArgumentException
if it encounters a corrupted chunk.
-
-
Field Summary
Fields Modifier and Type Field Description private java.nio.MappedByteBuffer
buffer
private java.nio.channels.FileChannel
channel
private java.io.RandomAccessFile
file
(package private) int
lastChunkOffset
-
Constructor Summary
Constructors Modifier Constructor Description private
ChunkIterator(java.io.File jfrFile)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private boolean
bufferHasMagic(int[] magicBytes)
private boolean
checkHasMore()
boolean
hasNext()
byte[]
next()
void
remove()
-
-
-
Method Detail
-
hasNext
public boolean hasNext()
- Specified by:
hasNext
in interfacejava.util.Iterator<byte[]>
-
checkHasMore
private boolean checkHasMore()
-
next
public byte[] next()
- Specified by:
next
in interfacejava.util.Iterator<byte[]>
-
bufferHasMagic
private boolean bufferHasMagic(int[] magicBytes)
-
remove
public void remove()
- Specified by:
remove
in interfacejava.util.Iterator<byte[]>
-
-