Class SequentialWriter

    • Field Detail

      • bufferOffset

        protected long bufferOffset
      • fchannel

        protected final java.nio.channels.FileChannel fchannel
      • lastFlushOffset

        protected long lastFlushOffset
      • runPostFlush

        protected java.util.function.LongConsumer runPostFlush
    • Constructor Detail

      • SequentialWriter

        public SequentialWriter​(File file)
        Create heap-based, non-compressed SequenialWriter with default buffer size(64k).
        Parameters:
        file - File to write
      • SequentialWriter

        public SequentialWriter​(File file,
                                SequentialWriterOption option)
        Create SequentialWriter for given file with specific writer option.
        Parameters:
        file - File to write
        option - Writer option
      • SequentialWriter

        public SequentialWriter​(File file,
                                SequentialWriterOption option,
                                boolean strictFlushing)
        Create SequentialWriter for given file with specific writer option.
        Parameters:
        file -
        option -
        strictFlushing -
    • Method Detail

      • skipBytes

        public void skipBytes​(long numBytes)
                       throws java.io.IOException
        Throws:
        java.io.IOException
      • sync

        public void sync()
        Synchronize file contents with disk.
      • syncDataOnlyInternal

        protected void syncDataOnlyInternal()
      • syncInternal

        protected void syncInternal()
      • setPostFlushListener

        public void setPostFlushListener​(java.util.function.LongConsumer runPostFlush)
      • flushData

        protected void flushData()
        Override this method instead of overriding flush()
        Throws:
        FSWriteError - on any I/O error.
      • hasPosition

        public boolean hasPosition()
        Description copied from interface: DataOutputPlus
        If the implementation supports providing a position, this method returns true, otherwise false.
        Specified by:
        hasPosition in interface DataOutputPlus
      • position

        public long position()
        Description copied from interface: DataOutputPlus
        Returns the current position of the underlying target like a file-pointer or the position withing a buffer. Not every implementation may support this functionality. Whether or not this functionality is supported can be checked via the DataOutputPlus.hasPosition().
        Specified by:
        position in interface DataOutputPlus
      • maxBytesInPage

        public int maxBytesInPage()
        Description copied from interface: DataOutputPlus
        Returns the number of bytes that a page can take at maximum.
        Specified by:
        maxBytesInPage in interface DataOutputPlus
      • padToPageBoundary

        public void padToPageBoundary()
                               throws java.io.IOException
        Description copied from interface: DataOutputPlus
        Pad this with zeroes until the next page boundary. If the destination position is already at a page boundary, do not do anything.
        Specified by:
        padToPageBoundary in interface DataOutputPlus
        Throws:
        java.io.IOException
      • paddedPosition

        public long paddedPosition()
        Description copied from interface: DataOutputPlus
        Returns the next padded position. This is either the current position (if already padded), or the start of next page.
        Specified by:
        paddedPosition in interface DataOutputPlus
      • getOnDiskFilePointer

        public long getOnDiskFilePointer()
        Returns the current file pointer of the underlying on-disk file. Note that since write works by buffering data, the value of this will increase by buffer size and not every write to the writer will modify this value. Furthermore, for compressed files, this value refers to compressed data, while the writer getFilePointer() refers to uncompressedFile
        Returns:
        the current file pointer
      • getEstimatedOnDiskBytesWritten

        public long getEstimatedOnDiskBytesWritten()
      • length

        public long length()
      • getPath

        public java.lang.String getPath()
      • getFile

        public File getFile()
      • resetBuffer

        protected void resetBuffer()
      • current

        protected long current()
      • resetAndTruncate

        public void resetAndTruncate​(DataPosition mark)
        Drops all buffered data that's past the limits of our new file mark + buffer capacity, or syncs and truncates the underlying file to the marked position
      • getLastFlushOffset

        public long getLastFlushOffset()
      • truncate

        public void truncate​(long toSize)
      • isOpen

        public boolean isOpen()
      • commit

        public final java.lang.Throwable commit​(java.lang.Throwable accumulate)
        Specified by:
        commit in interface Transactional
      • abort

        public final java.lang.Throwable abort​(java.lang.Throwable accumulate)
        Specified by:
        abort in interface Transactional
      • writeDirectlyToChannel

        public int writeDirectlyToChannel​(java.nio.ByteBuffer buf)
                                   throws java.io.IOException
        Throws:
        java.io.IOException
      • finish

        public final void finish()