Package opennlp.tools.ml.model

# Class ChecksumEventStream

java.lang.Object
opennlp.tools.util.AbstractObjectStream<Event>
opennlp.tools.ml.model.ChecksumEventStream

All Implemented Interfaces:
  `AutoCloseable`, `ObjectStream<Event>`

public class ChecksumEventStream extends AbstractObjectStream<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:
  - `Event`
  - `Checksum`
  - `AbstractObjectStream`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ChecksumEventStream(ObjectStream<Event> eventStream)`
  Initializes an `ChecksumEventStream`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `long`
  `calculateChecksum()`
  Calculates and returns the (current) checksum.
  `Event`
  `read()`
  Returns the next `ObjectStream` object.

  ### Methods inherited from class opennlp.tools.util.AbstractObjectStream

  `close, reset`

  ### Methods inherited from class java.lang.Object

  `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ChecksumEventStream

    public ChecksumEventStream(ObjectStream<Event> eventStream)
    Initializes an `ChecksumEventStream`.
    Parameters:
      `eventStream` - The `ObjectStream` that provides the `Event` samples.

- ## Method Details

  - ### read

    public Event read() throws IOException
    Description copied from interface: `ObjectStream`
    Returns the next `ObjectStream` object. Calling this method repeatedly until it returns `null` will return each object from the underlying source exactly once.
    Specified by:
      `read` in interface `ObjectStream<Event>`
    Overrides:
      `read` in class `AbstractObjectStream<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`.