Class ReftableOutputStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.reftable.ReftableOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Wrapper to assist formatting a reftable to an
OutputStream
.
Internally buffers at block size boundaries, flushing only complete blocks to
the OutputStream
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
private byte[]
private int
private int
private int
private DeflaterOutputStream
private int
private Deflater
private final CountingOutputStream
private long
private final byte[]
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription(package private) void
beginBlock
(byte type) (package private) int
(package private) int
(package private) static int
computeVarintSize
(long val) private void
ensureBytesAvailableInBlockBuf
(int cnt) (package private) int
estimatePadBetweenBlocks
(int currentBlockSize) (package private) void
(package private) void
(package private) void
(package private) void
(package private) long
(package private) void
setBlockSize
(int bs) (package private) long
size()
void
write
(byte[] b, int off, int cnt) void
write
(int b) (package private) void
(package private) void
writeInt16
(int val) (package private) void
writeInt24
(int val) (package private) void
writeVarint
(long val) (package private) void
writeVarintString
(byte[] msg) (package private) void
Methods inherited from class java.io.OutputStream
close, flush, write
-
Field Details
-
tmp
private final byte[] tmp -
out
-
alignBlocks
private final boolean alignBlocks -
deflater
-
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 classOutputStream
-
write
public void write(byte[] b, int off, int cnt) - Overrides:
write
in classOutputStream
-
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
-
writeVarintString
-
writeVarintString
void writeVarintString(byte[] msg) -
ensureBytesAvailableInBlockBuf
private void ensureBytesAvailableInBlockBuf(int cnt) -
flushFileHeader
- Throws:
IOException
-
beginBlock
void beginBlock(byte type) -
flushBlock
- Throws:
IOException
-
padBetweenBlocksToNextBlock
- Throws:
IOException
-
estimatePadBetweenBlocks
int estimatePadBetweenBlocks(int currentBlockSize) -
finishFile
- Throws:
IOException
-