Package opennlp.tools.ml.model
Class ChecksumEventStream
- All Implemented Interfaces:
AutoCloseable
,ObjectStream<Event>
A
Checksum
-based event stream
implementation.
Computes the checksum while consuming the event stream.
By default, this implementation will use CRC32C
for checksum calculations
as it can use of CPU-specific acceleration instructions at runtime.- See Also:
-
Constructor Summary
ConstructorDescriptionChecksumEventStream
(ObjectStream<Event> eventStream) Initializes anChecksumEventStream
. -
Method Summary
Modifier and TypeMethodDescriptionlong
Calculates and returns the (current) checksum.read()
Returns the nextObjectStream
object.Methods inherited from class opennlp.tools.util.AbstractObjectStream
close, reset
-
Constructor Details
-
ChecksumEventStream
Initializes anChecksumEventStream
.- Parameters:
eventStream
- TheObjectStream
that provides theEvent
samples.
-
-
Method Details
-
read
Description copied from interface:ObjectStream
Returns the nextObjectStream
object. Calling this method repeatedly until it returnsnull
will return each object from the underlying source exactly once.- Specified by:
read
in interfaceObjectStream<Event>
- Overrides:
read
in classAbstractObjectStream<Event>
- Returns:
- The next object or
null
to signal that the stream is exhausted. - Throws:
IOException
- Thrown if there is an error during reading.
-
calculateChecksum
public long calculateChecksum()Calculates and returns the (current) checksum.Note: This should be called once the underlying stream has been (fully) consumed.
- Returns:
- The calculated checksum as
long
.
-