Class LimitReader


public class LimitReader extends ProxyReader
A proxy that can skip a number of upstream records, limit the number of records sent downstream, or both. This reader acts like the MySQL SELECT ... LIMIT offset, row_count statement.
  • Constructor Details

    • LimitReader

      public LimitReader(DataReader targetDataReader)
      Creates a reader with no offset or limit; set at least one before open().
    • LimitReader

      public LimitReader(DataReader targetDataReader, Long offset, Long limit)
      Creates a reader that skips offset records and then returns at most limit; either may be null, but not both.
    • LimitReader

      public LimitReader(DataReader targetDataReader, Integer offset, Integer limit)
      Creates a reader that skips offset records and then returns at most limit; either may be null, but not both.
    • LimitReader

      public LimitReader(DataReader targetDataReader, long limit)
      Creates a reader that returns at most limit records without skipping any.
  • Method Details

    • getOffset

      public Long getOffset()
      Returns the number of leading records to skip or null to skip none.
    • setOffset

      public LimitReader setOffset(Long offset)
      Sets the number of leading records to skip; null skips none.
    • setOffset

      public LimitReader setOffset(long offset)
      Sets the number of leading records to skip.
    • getLimit

      public Long getLimit()
      Returns the maximum number of records to return after the offset or null for no limit.
    • setLimit

      public LimitReader setLimit(Long limit)
      Sets the maximum number of records to return after the offset; null for no limit.
    • setLimit

      public LimitReader setLimit(long limit)
      Sets the maximum number of records to return after the offset.
    • getOffsetConsumed

      public long getOffsetConsumed()
      Returns the number of records skipped so far to satisfy the offset.
    • open

      public void open() throws DataException
      Description copied from class: DataEndpoint
      Makes this endpoint ready for reading or writing.
      Overrides:
      open 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