Class RAFDirectory.RAFIndexInput

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, java.lang.Cloneable, RandomAccessInput
    Enclosing class:
    RAFDirectory

    static final class RAFDirectory.RAFIndexInput
    extends BufferedIndexInput
    Reads bytes with RandomAccessFile.seek(long) followed by RandomAccessFile.read(byte[], int, int).
    • Field Detail

      • CHUNK_SIZE

        private static final int CHUNK_SIZE
        The maximum chunk size is 8192 bytes, because RandomAccessFile mallocs a native buffer outside of stack if the read buffer size is larger.
        See Also:
        Constant Field Values
      • file

        protected final java.io.RandomAccessFile file
        the file channel we will read from
      • isClone

        boolean isClone
        is this instance a clone and hence does not own the file to close it
      • off

        protected final long off
        start offset: non-zero in the slice case
      • end

        protected final long end
        end offset (start+length)
    • Constructor Detail

      • RAFIndexInput

        public RAFIndexInput​(java.lang.String resourceDesc,
                             java.io.RandomAccessFile file,
                             IOContext context)
                      throws java.io.IOException
        Throws:
        java.io.IOException
      • RAFIndexInput

        public RAFIndexInput​(java.lang.String resourceDesc,
                             java.io.RandomAccessFile file,
                             long off,
                             long length,
                             int bufferSize)
    • Method Detail

      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: IndexInput
        Closes the stream to further operations.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class IndexInput
        Throws:
        java.io.IOException
      • clone

        public RAFDirectory.RAFIndexInput clone()
        Description copied from class: IndexInput
        Returns a clone of this stream.

        Clones of a stream access the same data, and are positioned at the same point as the stream they were cloned from.

        Expert: Subclasses must ensure that clones may be positioned at different points in the input from each other and from the stream they were cloned from.

        Warning: Lucene never closes cloned IndexInputs, it will only call IndexInput.close() on the original object.

        If you access the cloned IndexInput after closing the original object, any readXXX methods will throw AlreadyClosedException.

        This method is NOT thread safe, so if the current IndexInput is being used by one thread while clone is called by another, disaster could strike.

        Overrides:
        clone in class BufferedIndexInput
      • slice

        public IndexInput slice​(java.lang.String sliceDescription,
                                long offset,
                                long length)
                         throws java.io.IOException
        Description copied from class: IndexInput
        Creates a slice of this index input, with the given description, offset, and length. The slice is sought to the beginning.
        Overrides:
        slice in class BufferedIndexInput
        Throws:
        java.io.IOException
      • length

        public final long length()
        Description copied from class: IndexInput
        The number of bytes in the file.
        Specified by:
        length in class IndexInput
      • readInternal

        protected void readInternal​(byte[] b,
                                    int offset,
                                    int len)
                             throws java.io.IOException
        IndexInput methods
        Specified by:
        readInternal in class BufferedIndexInput
        Parameters:
        b - the array to read bytes into
        offset - the offset in the array to start storing bytes
        len - the number of bytes to read
        Throws:
        java.io.IOException
      • isFDValid

        boolean isFDValid()
                   throws java.io.IOException
        Throws:
        java.io.IOException