An iterator that allows iteration over elements contained in a capture file. Simple {@link IOIterator#next} and {@link IOIterator#hasNext} methods areused to iterate over a long sequence of element which reside physically on a some storage device. Elements which are typically records, are efficiently accessed and returned as shared ByteBuffers who's position and limit properties are set to enclose the contents of the record within some shared buffer.
The data returned by next
, is a shared buffer, not a view of the buffer but shared instance as returned by the next
call. It is important to note that any consecutive call to next
overrides the position and limit properties of the shared buffer that is returned in both instances. Therefore it is upto the user to either save that information or create a view of the buffer using ByteBuffer.slice()
method. RawIterator purposely does not return such views and leaves that upto the user to do. This way views are created only when truely required where persistance is needed. This optimization affords increadible performance when using a RawIterator. The author has measured 6,000,000 packet per second iteration speeds over very large capture files. Pefromance goes considerably down even when a single buffer view or any other object instance is created within critical sections of the iterator's code. The implementation goes to great lengths not to initiate even a single object when working with the IOSkippableIterator methods next
and skip
. These methods are optimized for maximum speed possible. Lastly note that skip
is even more efficient then next
at skipping over records. Skip's implementation is able to omit certain amount of logic in order to skip accross records even faster then next
can.
|
|
|
|
|
|
|
|