Class AbstractBufferedFileOutput

  • All Implemented Interfaces:
    java.io.Closeable, java.io.DataOutput, java.lang.AutoCloseable, org.apache.hugegraph.computer.core.io.BytesOutput, org.apache.hugegraph.computer.core.io.RandomAccessOutput
    Direct Known Subclasses:
    BufferedFileOutput, ValueFileOutput

    public abstract class AbstractBufferedFileOutput
    extends UnsafeBytesOutput
    • Field Detail

      • fileOffset

        protected long fileOffset
    • Constructor Detail

      • AbstractBufferedFileOutput

        public AbstractBufferedFileOutput​(int bufferCapacity)
    • Method Detail

      • writeFixedInt

        public void writeFixedInt​(long position,
                                  int v)
                           throws java.io.IOException
        Specified by:
        writeFixedInt in interface org.apache.hugegraph.computer.core.io.RandomAccessOutput
        Overrides:
        writeFixedInt in class UnsafeBytesOutput
        Throws:
        java.io.IOException
      • position

        public long position()
        Specified by:
        position in interface org.apache.hugegraph.computer.core.io.RandomAccessOutput
        Overrides:
        position in class UnsafeBytesOutput
      • skip

        public long skip​(long bytesToSkip)
                  throws java.io.IOException
        Description copied from class: UnsafeBytesOutput
        If you write some thing, and you need to write the serialized byte size first. If the byte size is unknown when write, you can skip 4 bytes (size of int)first, after write out the content, get the serialized byte size and calls writeInt(int position, int v) to write the int at skipped position. The serialized byte size can be get by the difference of UnsafeBytesOutput.position() before and after write the content.
        Specified by:
        skip in interface org.apache.hugegraph.computer.core.io.RandomAccessOutput
        Overrides:
        skip in class UnsafeBytesOutput
        Returns:
        the position before skip.
        Throws:
        java.io.IOException
      • require

        protected void require​(int size)
                        throws java.io.IOException
        Overrides:
        require in class UnsafeBytesOutput
        Throws:
        java.io.IOException
      • bufferSize

        protected int bufferSize()
      • bufferAvailable

        protected int bufferAvailable()
      • bufferCapacity

        protected int bufferCapacity()
      • flushBuffer

        protected abstract void flushBuffer()
                                     throws java.io.IOException
        Throws:
        java.io.IOException