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
ConstructorsConstructorDescriptionChecksumEventStream(ObjectStream<Event> eventStream) Initializes anChecksumEventStream. -
Method Summary
Methods inherited from class AbstractObjectStream
close, reset
-
Constructor Details
-
ChecksumEventStream
Initializes anChecksumEventStream.- Parameters:
eventStream- TheObjectStreamthat provides theEventsamples.
-
-
Method Details
-
read
Description copied from interface:ObjectStreamReturns the nextTobject. Calling this method repeatedly until it returnsnullwill return each object from the underlying source exactly once.- Specified by:
readin interfaceObjectStream<Event>- Overrides:
readin classAbstractObjectStream<Event>- Returns:
- The next object or
nullto 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.
-