org.apache.lucene.util

## Class OfflineSorter.ByteSequencesReader

- java.lang.Object
- - org.apache.lucene.util.OfflineSorter.ByteSequencesReader

- All Implemented Interfaces:
    Closeable, AutoCloseable
  Enclosing class:
    OfflineSorter

      public static class OfflineSorter.ByteSequencesReader
      extends Object
      implements Closeable

  Utility class to read length-prefixed byte[] entries from an input. Complementary to `OfflineSorter.ByteSequencesWriter`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `OfflineSorter.ByteSequencesReader(DataInput is)` Constructs a ByteSequencesReader from the provided DataInput
    `OfflineSorter.ByteSequencesReader(Path path)` Constructs a ByteSequencesReader from the provided Path

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes the provided `DataInput` if it is `Closeable`.
    `byte[]` | `read()` Reads the next entry and returns it if successful.
    `boolean` | `read(BytesRefBuilder ref)` Reads the next entry into the provided `BytesRef`.

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

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

- - ### Constructor Detail

    - #### OfflineSorter.ByteSequencesReader

          public OfflineSorter.ByteSequencesReader(Path path)
                                            throws IOException

      Constructs a ByteSequencesReader from the provided Path
      Throws:
        `IOException`

    - #### OfflineSorter.ByteSequencesReader

          public OfflineSorter.ByteSequencesReader(DataInput is)

      Constructs a ByteSequencesReader from the provided DataInput

  - ### Method Detail

    - #### read

          public boolean read(BytesRefBuilder ref)
                       throws IOException

      Reads the next entry into the provided `BytesRef`. The internal storage is resized if needed.
      Returns:
        Returns `false` if EOF occurred when trying to read the header of the next sequence. Returns `true` otherwise.
      Throws:
        `EOFException` - if the file ends before the full sequence is read.
        `IOException`

    - #### read

          public byte[] read()
                      throws IOException

      Reads the next entry and returns it if successful.
      Returns:
        Returns `null` if EOF occurred before the next entry could be read.
      Throws:
        `EOFException` - if the file ends before the full sequence is read.
        `IOException`
      See Also:
        `read(BytesRefBuilder)`

    - #### close

          public void close()
                     throws IOException

      Closes the provided `DataInput` if it is `Closeable`.
      Specified by:
        `close` in interface `Closeable`
      Specified by:
        `close` in interface `AutoCloseable`
      Throws:
        `IOException`

Copyright © 2000-2017 Apache Software Foundation. All Rights Reserved.