Class BufferedReader


public class BufferedReader extends ProxyReader
A proxy that organizes incoming data by collecting records of the same type (using values in a subset of fields) to release them downstream together.
  • Constructor Details

    • BufferedReader

      public BufferedReader(DataReader reader, int queueSize, String... bufferByFields)
      Creates a reader that groups records by the values of the given fields; a background thread reads up to queueSize records ahead from the nested reader. Records whose grouping values are all null are dropped.
    • BufferedReader

      public BufferedReader(DataReader reader, int queueSize, FieldList bufferByFields)
      Creates a reader that groups records by the values of the given fields; a background thread reads up to queueSize records ahead from the nested reader. Records whose grouping values are all null are dropped.
  • Method Details

    • getBufferByFields

      public FieldList getBufferByFields()
    • isDebug

      public boolean isDebug()
      Indicates if buffer activity (buffers opened and closed, records added) is logged at debug level (default is false).
    • setDebug

      public BufferedReader setDebug(boolean debug)
      Indicates if buffer activity (buffers opened and closed, records added) is logged at debug level (default is false).
    • getBufferStrategy

      public BufferStrategy getBufferStrategy()
      Returns the strategy that decides when an open buffer is closed and its records released (defaults to closing 200 milliseconds after the last record was added or once it holds 100 records).
    • setBufferStrategy

      public BufferedReader setBufferStrategy(BufferStrategy bufferStrategy)
      Sets the strategy that decides when an open buffer is closed and its records released; null restores the default (200 milliseconds after the last record was added or 100 records). Must be called before open().
    • getBuffersCreated

      public long getBuffersCreated()
    • getBuffersClosed

      public long getBuffersClosed()
    • open

      public void open()
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open in class ProxyReader
    • close

      public void close() throws DataException
      Description copied from class: DataEndpoint
      Indicates that this endpoint has finished reading or writing.
      Overrides:
      close in class ProxyReader
      Throws:
      DataException
    • readImpl

      protected Record readImpl() throws Throwable
      Description copied from class: DataReader
      Overridden by subclasses to read the next record from this DataReader. The default implementation of DataReader.read() now insures that this method will not be called again after it returns a null.

      If no record is available, null will be returned.

      Contract for subclasses (see also docs/authoring/DataReader.md):

      Overrides:
      readImpl in class ProxyReader
      Throws:
      Throwable
    • addExceptionProperties

      public DataException addExceptionProperties(DataException exception)
      Description copied from class: Endpoint
      Adds this endpoint's current state to a DataException. Since this method is called whenever an exception is thrown, subclasses should override it to add their specific information.
      Overrides:
      addExceptionProperties in class ProxyReader
    • toString

      public String toString()
      Overrides:
      toString in class DataEndpoint