Class IndexOutput

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable
    Direct Known Subclasses:
    BufferedIndexOutput, ChecksumIndexOutput, RAMOutputStream

    public abstract class IndexOutput
    extends DataOutput
    implements java.io.Closeable
    Abstract base class for output to a file in a Directory. A random-access output stream. Used for all Lucene index output operations.

    IndexOutput may only be used from one thread, because it is not thread safe (it keeps internal state like file position).

    See Also:
    Directory, IndexInput
    • Constructor Detail

      • IndexOutput

        public IndexOutput()
    • Method Detail

      • flush

        public abstract void flush()
                            throws java.io.IOException
        Forces any buffered output to be written.
        Throws:
        java.io.IOException
      • close

        public abstract void close()
                            throws java.io.IOException
        Closes this stream to further operations.
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Throws:
        java.io.IOException
      • getFilePointer

        public abstract long getFilePointer()
        Returns the current position in this file, where the next write will occur.
        See Also:
        seek(long)
      • seek

        @Deprecated
        public abstract void seek​(long pos)
                           throws java.io.IOException
        Deprecated.
        (4.1) This method will be removed in Lucene 5.0
        Sets current position in this file, where the next write will occur.
        Throws:
        java.io.IOException
        See Also:
        getFilePointer()
      • length

        public abstract long length()
                             throws java.io.IOException
        The number of bytes in the file.
        Throws:
        java.io.IOException
      • setLength

        public void setLength​(long length)
                       throws java.io.IOException
        Set the file length. By default, this method does nothing (it's optional for a Directory to implement it). But, certain Directory implementations (for example @see FSDirectory) can use this to inform the underlying IO system to pre-allocate the file to the specified size. If the length is longer than the current file length, the bytes added to the file are undefined. Otherwise the file is truncated.
        Parameters:
        length - file length
        Throws:
        java.io.IOException