Class SortingReader


public class SortingReader extends ProxyReader
A proxy that sorts records.
  • Constructor Details

    • SortingReader

      public SortingReader(DataReader reader, long bufferSize)
      Parameters:
      reader -
      bufferSize - memory buffer in bytes
    • SortingReader

      public SortingReader(DataReader reader)
      Creates a reader that sorts all records in memory, without overflowing to disk.
  • Method Details

    • getNestedReader

      public DataReader getNestedReader()
      Description copied from class: DataReader
      Returns the DataReader held inside this one or null if there isn't one.
      Overrides:
      getNestedReader in class ProxyReader
    • getNestedReader0

      public DataReader getNestedReader0()
      Returns the reader actually being proxied: the original until the first read, then one over the sorted records (getNestedReader() always returns the original).
    • isCacheFieldIndexes

      public boolean isCacheFieldIndexes()
    • setCacheFieldIndexes

      public SortingReader setCacheFieldIndexes(boolean cacheFieldIndexes)
    • getOrder

      public RecordComparator getOrder()
      Returns the comparator that defines the sort order; with no fields added, records are compared on all their fields.
    • add

      public SortingReader add(String fieldName)
      Adds an ascending sort on the given field name or FieldPath expression, after any fields already added.
    • add

      public SortingReader add(String fieldName, boolean ascending)
      Adds an ascending or descending sort on the given field name or FieldPath expression, after any fields already added.
    • asc

      public SortingReader asc(String fieldName)
      Adds an ascending sort on the given field name or FieldPath expression, after any fields already added.
    • desc

      public SortingReader desc(String fieldName)
      Adds a descending sort on the given field name or FieldPath expression, after any fields already added.
    • add

      public SortingReader add(String fieldName, boolean ascending, Collator collator)
      Adds a sort on the given field name or FieldPath expression that uses the collator for string values, after any fields already added.
    • 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
    • copy

      public static void copy(DataReader source, DataWriter sink) throws Throwable
      Writes every remaining record from the source to the sink without opening or closing either.
      Throws:
      Throwable