|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface RawIterator
An iterator that allows iteration over elements contained in a capture file.
Simple IOIterator.next() and IOIterator.hasNext() methods are
used 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.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from interface com.slytechs.utils.collection.IOIterator |
|---|
com.slytechs.utils.collection.IOIterator.IteratorAdapter<E> |
| Method Summary | |
|---|---|
void |
add(java.nio.ByteBuffer buffer,
boolean copy)
Adds a new record at the current cursor position. |
void |
add(java.nio.ByteBuffer b1,
java.nio.ByteBuffer b2)
Adds a new record using two buffers. |
Filter |
getFilter()
|
void |
replace(java.nio.ByteBuffer buffer,
boolean copy)
Replaces the record at current cursor position with the new record found in the buffer. |
void |
replaceInPlace()
Replaces the current record with its own contents and causes the original region to become invalid and replaced by new in-memory cache buffer which contains the same content. |
void |
resize(long size)
Changes the length of the current record. |
com.slytechs.utils.collection.SeekResult |
seek(Filter<RecordFilterTarget> filter)
Seek the first record from the current position that will match the supplied filter. |
com.slytechs.utils.collection.SeekResult |
seekSecond()
|
com.slytechs.utils.collection.SeekResult |
seekToIndex(long recordIndex)
Seeks to a record by its zero-based index as counted from the first record. |
RecordError[] |
skipOverErrors()
Skips over a packet record and ignores errors if any. |
| Methods inherited from interface org.jnetstream.capture.file.FileIterator |
|---|
seek, setAutoflush |
| Methods inherited from interface com.slytechs.utils.collection.IOSeekableFirstLast |
|---|
seekEnd, seekFirst, seekLast |
| Methods inherited from interface com.slytechs.utils.collection.IOSkippable |
|---|
skip |
| Methods inherited from interface com.slytechs.utils.collection.IOIterator |
|---|
hasNext, next, remove |
| Methods inherited from interface org.jnetstream.capture.file.FileModifier |
|---|
abortChanges, add, addAll, addAll, remove, removeAll, removeAll, removeAll, removeAll, replace, retainAll, retainAll, swap |
| Methods inherited from interface com.slytechs.utils.collection.IOSeekable |
|---|
seek, seek |
| Methods inherited from interface com.slytechs.utils.collection.IOPositional |
|---|
getPosition, setPosition, setPosition |
| Methods inherited from interface java.io.Flushable |
|---|
flush |
| Methods inherited from interface java.io.Closeable |
|---|
close |
| Methods inherited from interface java.lang.Iterable |
|---|
iterator |
| Method Detail |
|---|
com.slytechs.utils.collection.SeekResult seekToIndex(long recordIndex)
throws java.io.IOException
recordIndex - zero-based index of the record to seek to
java.io.IOException - any IO errors
com.slytechs.utils.collection.SeekResult seek(Filter<RecordFilterTarget> filter)
throws java.io.IOException
filter - a record filter to used in record matching
java.io.IOException - any IO errors
com.slytechs.utils.collection.SeekResult seekSecond()
throws java.io.IOException
java.io.IOException
void resize(long size)
throws java.io.IOException
size - new size of the record
java.io.IOException - any IO errors
void add(java.nio.ByteBuffer b1,
java.nio.ByteBuffer b2)
throws java.io.IOException
#addAll(ByteBuffer[]) version as the two buffers are received
as normal parameters. This version of the add method is used when record's
header and content reside in two separate buffers. Addition is done by
copy.
b1 - first buffer containing the record's headerb2 - second buffer containing the record's content
java.io.IOException - any IO errors
void add(java.nio.ByteBuffer buffer,
boolean copy)
throws java.io.IOException
position and limit. The
additional boolean flag indicates if the buffer's content should be copied
into private buffer or if the record's in-memory representation should be
presented as the user supplied buffer. If copy is false, any changes made
to the record will be reflected in the user buffer and visa versa, unless
the supplied buffer is readonly. If the buffer is readonly, a copy of it
will be made upon first change to the buffer automatically into a
read-write buffer.
buffer - buffer containing the recordcopy - true means that record's content found in the buffer will be
copied into a private read-write buffer
java.io.IOException - any IO errors
void replace(java.nio.ByteBuffer buffer,
boolean copy)
throws java.io.IOException
position and
limit. The additional boolean flag indicates if the
buffer's content should be copied into private buffer or if the record's
in-memory representation should be presented as the user supplied buffer.
If copy is false, any changes made to the record will be reflected in the
user buffer and visa versa, unless the supplied buffer is readonly. If the
buffer is readonly, a copy of it will be made upon first change to the
buffer automatically into a read-write buffer.
buffer - the buffer containing the new recordcopy - true means that record's content found in the buffer will be
copied into a private read-write buffer
java.io.IOException - any IO errors
void replaceInPlace()
throws java.io.IOException
Replaces the current record with its own contents and causes the original region to become invalid and replaced by new in-memory cache buffer which contains the same content.
This method is primarily used by Packet and Record objects to setup the way their buffer modification are to take place. Either in-place or in the buffer they originally came from, or duplicated to in memory cache. The original content in physical storage stay unmodified while Packet and Record object make modifications to a duplicate copy of the buffer. Only a flush() forces the changes out to the physical storage. This is safer way to make changes as all the changes can be made in memory first, somewhat offline, and not be propaged to physical storage in case of crash or serious error. A flush() sends all the changes to physical storage in one step.
java.io.IOException - any IO errors
RecordError[] skipOverErrors()
throws java.io.IOException
IOSkippable.skip().
java.io.IOExceptionFilter getFilter()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||