Interface AsyncReader<T>

All Superinterfaces:
DataReader<T>, DataRecordsReader<T>

public non-sealed interface AsyncReader<T> extends DataRecordsReader<T>
Interface for Asynchronous Readers.

This interface extends DataRecordsReader and models readers that return data asynchronously using CompletableFuture. Implementations should provide a non-blocking readAsync(int) primitive and may rely on default helpers to report PerL metrics when the benchmark harness requires timing or throughput observations.

Notes for implementors:

  • When the reader cannot perform an asynchronous read, returning a completed future that contains null is an acceptable signal that no data was read.
  • Default metric-recording helpers convert completed futures into PerL events and propagate exceptions (including timeouts) to the configured logger or PerL channel.
  • Method Details

    • readAsync

      CompletableFuture<T> readAsync(int size) throws EOFException, IOException
      Read the dat asynchronously.
      Parameters:
      size - size of the data in bytes to read.
      Returns:
      Completable Future.
      Throws:
      EOFException - If the End of the file occurred.
      IOException - If an exception occurred.
    • close

      default void close() throws IOException
      Close the Reader.
      Specified by:
      close in interface DataReader<T>
      Throws:
      IOException - If an exception occurred.
    • recordRead

      default void recordRead(DataType<T> dType, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel) throws EOFException, IOException
      Default implementation for Reading data using readAsync(int) ()} and recording the benchmark statistics. The end time of the status parameter Status.endTime of this method determines the terminating condition for time based reader performance benchmarking. If you are intend to not use readAsync(int) ()} then you can override this method. If you are intend to read multiple records then you can override this method. otherwise, use the default implementation and don't override this method.
      Specified by:
      recordRead in interface DataRecordsReader<T>
      Parameters:
      dType - dataType
      size - size of the data in bytes
      time - time interface
      status - Timestamp
      perlChannel - to call for benchmarking
      Throws:
      EOFException - If the End of the file occurred.
      IOException - If an exception occurred.
    • recordRead

      default void recordRead(DataType<T> dType, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel, int id, ReadRequestsLogger logger) throws EOFException, IOException
      Default implementation for Reading data using readAsync(int) ()} and recording the benchmark statistics. The end time of the status parameter Status.endTime of this method determines the terminating condition for time based reader performance benchmarking. If you are intend to not use readAsync(int) ()} then you can override this method. If you are intend to read multiple records then you can override this method. otherwise, use the default implementation and don't override this method.
      Specified by:
      recordRead in interface DataRecordsReader<T>
      Parameters:
      dType - dataType
      size - size of the data in bytes
      time - time interface
      status - Timestamp
      perlChannel - to call for benchmarking
      id - reader id
      logger - Read Request logger
      Throws:
      EOFException - If the End of the file occurred.
      IOException - If an exception occurred.
    • recordReadTime

      default void recordReadTime(DataType<T> dType, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel) throws EOFException, IOException
      Default implementation for Reading data using Reader.read(), extracting start time from data and recording the benchmark statistics. The end time of the status parameter Status.endTime of this method determines the terminating condition for time based reader performance benchmarking. If you are intend to not use Reader.read() then you can override this method. If you are intend to read multiple records then you can override this method. otherwise, use the default implementation and don't override this method.
      Specified by:
      recordReadTime in interface DataRecordsReader<T>
      Parameters:
      dType - dataType
      size - size of the data in bytes
      time - time interface
      status - Timestamp
      perlChannel - to call for benchmarking
      Throws:
      EOFException - If the End of the file occurred.
      IOException - If an exception occurred.
    • recordReadTime

      default void recordReadTime(DataType<T> dType, int size, io.time.Time time, Status status, io.perl.api.PerlChannel perlChannel, int id, ReadRequestsLogger logger) throws EOFException, IOException
      Default implementation for Reading data using Reader.read(), extracting start time from data and recording the benchmark statistics. The end time of the status parameter Status.endTime of this method determines the terminating condition for time based reader performance benchmarking. If you are intend to not use Reader.read() then you can override this method. If you are intend to read multiple records then you can override this method. otherwise, use the default implementation and don't override this method.
      Specified by:
      recordReadTime in interface DataRecordsReader<T>
      Parameters:
      dType - dataType
      size - size of the data in bytes
      time - time interface
      status - Timestamp
      perlChannel - to call for benchmarking
      id - reader id
      logger - Read Request logger
      Throws:
      EOFException - If the End of the file occurred.
      IOException - If an exception occurred.