Class IndexOutput

    • Field Detail

      • resourceDescription

        private final java.lang.String resourceDescription
        Full description of this output, e.g. which class such as FSIndexOutput, and the full path to the file
      • name

        private final java.lang.String name
        Just the name part from resourceDescription
    • Constructor Detail

      • IndexOutput

        protected IndexOutput​(java.lang.String resourceDescription,
                              java.lang.String name)
        Sole constructor. resourceDescription should be non-null, opaque string describing this resource; it's returned from toString().
    • Method Detail

      • 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.
      • getChecksum

        public abstract long getChecksum()
                                  throws java.io.IOException
        Returns the current checksum of bytes written so far
        Throws:
        java.io.IOException
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • alignFilePointer

        public final long alignFilePointer​(int alignmentBytes)
                                    throws java.io.IOException
        Aligns the current file pointer to multiples of alignmentBytes bytes to improve reads with mmap. This will write between 0 and (alignmentBytes-1) zero bytes using DataOutput.writeByte(byte).
        Parameters:
        alignmentBytes - the alignment to which it should forward file pointer (must be a power of 2)
        Returns:
        the new file pointer after alignment
        Throws:
        java.io.IOException
        See Also:
        alignOffset(long, int)
      • alignOffset

        public static final long alignOffset​(long offset,
                                             int alignmentBytes)
        Aligns the given offset to multiples of alignmentBytes bytes by rounding up. The alignment must be a power of 2.