Class Sort.ByteSequencesReader

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Enclosing class:
    Sort

    public static class Sort.ByteSequencesReader
    extends java.lang.Object
    implements java.io.Closeable
    Utility class to read length-prefixed byte[] entries from an input. Complementary to Sort.ByteSequencesWriter.
    • Constructor Summary

      Constructors 
      Constructor Description
      ByteSequencesReader​(java.io.DataInput is)
      Constructs a ByteSequencesReader from the provided DataInput
      ByteSequencesReader​(java.io.File file)
      Constructs a ByteSequencesReader from the provided File
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes the provided DataInput if it is Closeable.
      byte[] read()
      Reads the next entry and returns it if successful.
      boolean read​(BytesRef ref)
      Reads the next entry into the provided BytesRef.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ByteSequencesReader

        public ByteSequencesReader​(java.io.File file)
                            throws java.io.IOException
        Constructs a ByteSequencesReader from the provided File
        Throws:
        java.io.IOException
      • ByteSequencesReader

        public ByteSequencesReader​(java.io.DataInput is)
        Constructs a ByteSequencesReader from the provided DataInput
    • Method Detail

      • read

        public boolean read​(BytesRef ref)
                     throws java.io.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:
        java.io.EOFException - if the file ends before the full sequence is read.
        java.io.IOException
      • read

        public byte[] read()
                    throws java.io.IOException
        Reads the next entry and returns it if successful.
        Returns:
        Returns null if EOF occurred before the next entry could be read.
        Throws:
        java.io.EOFException - if the file ends before the full sequence is read.
        java.io.IOException
        See Also:
        read(BytesRef)
      • close

        public void close()
                   throws java.io.IOException
        Closes the provided DataInput if it is Closeable.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException