Class ReftableOutputStream

java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.reftable.ReftableOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

class ReftableOutputStream extends OutputStream
Wrapper to assist formatting a reftable to an OutputStream.

Internally buffers at block size boundaries, flushing only complete blocks to the OutputStream.

  • Field Details

    • tmp

      private final byte[] tmp
    • out

      private final CountingOutputStream out
    • alignBlocks

      private final boolean alignBlocks
    • deflater

      private Deflater deflater
    • compressor

      private DeflaterOutputStream compressor
    • blockType

      private int blockType
    • blockSize

      private int blockSize
    • blockStart

      private int blockStart
    • blockBuf

      private byte[] blockBuf
    • cur

      private int cur
    • paddingUsed

      private long paddingUsed
  • Constructor Details

    • ReftableOutputStream

      ReftableOutputStream(OutputStream os, int bs, boolean align)
  • Method Details

    • setBlockSize

      void setBlockSize(int bs)
    • write

      public void write(int b)
      Specified by:
      write in class OutputStream
    • write

      public void write(byte[] b, int off, int cnt)
      Overrides:
      write in class OutputStream
    • bytesWrittenInBlock

      int bytesWrittenInBlock()
    • bytesAvailableInBlock

      int bytesAvailableInBlock()
    • paddingUsed

      long paddingUsed()
    • size

      long size()
      Returns:
      bytes flushed; excludes bytesWrittenInBlock().
    • computeVarintSize

      static int computeVarintSize(long val)
    • writeVarint

      void writeVarint(long val)
    • writeInt16

      void writeInt16(int val)
    • writeInt24

      void writeInt24(int val)
    • writeId

      void writeId(ObjectId id)
    • writeVarintString

      void writeVarintString(String s)
    • writeVarintString

      void writeVarintString(byte[] msg)
    • ensureBytesAvailableInBlockBuf

      private void ensureBytesAvailableInBlockBuf(int cnt)
    • flushFileHeader

      void flushFileHeader() throws IOException
      Throws:
      IOException
    • beginBlock

      void beginBlock(byte type)
    • flushBlock

      void flushBlock() throws IOException
      Throws:
      IOException
    • padBetweenBlocksToNextBlock

      void padBetweenBlocksToNextBlock() throws IOException
      Throws:
      IOException
    • estimatePadBetweenBlocks

      int estimatePadBetweenBlocks(int currentBlockSize)
    • finishFile

      void finishFile() throws IOException
      Throws:
      IOException