Class PackOutputStream
java.lang.Object
java.io.OutputStream
org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream
org.eclipse.jgit.internal.storage.pack.PackOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
Custom output stream to support
PackWriter
.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final byte[]
private final byte[]
private boolean
private final PackWriter
Fields inherited from class org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream
BYTES_TO_WRITE_BEFORE_CANCEL_CHECK
-
Constructor Summary
ConstructorsConstructorDescriptionPackOutputStream
(ProgressMonitor writeMonitor, OutputStream out, PackWriter pw) Initialize a pack output stream. -
Method Summary
Modifier and TypeMethodDescription(package private) void
final byte[]
Get a temporary buffer writers can use to copy data with.private static final int
objectHeader
(long len, int type, byte[] buf) private static final int
ofsDelta
(long diff, byte[] buf, int p) private static final int
ofsDeltaVarIntLength
(long v) (package private) final void
writeFileHeader
(int version, long objectCount) final void
writeHeader
(ObjectToPack otp, long rawLength) Commits the object header onto the stream.final void
writeObject
(ObjectToPack otp) Write one object.Methods inherited from class org.eclipse.jgit.internal.storage.io.CancellableDigestOutputStream
flush, getDigest, getWriteMonitor, length, write, write
Methods inherited from class java.io.OutputStream
close, nullOutputStream, write
-
Field Details
-
packWriter
-
headerBuffer
private final byte[] headerBuffer -
copyBuffer
private final byte[] copyBuffer -
ofsDelta
private boolean ofsDelta
-
-
Constructor Details
-
PackOutputStream
Initialize a pack output stream.This constructor is exposed to support debugging the JGit library only. Application or storage level code should not create a PackOutputStream, instead use
PackWriter
, and let the writer create the stream.- Parameters:
writeMonitor
- monitor to update on object output progress.out
- target stream to receive all object contents.pw
- packer that is going to perform the output.
-
-
Method Details
-
writeFileHeader
- Throws:
IOException
-
writeObject
Write one object. If the object was already written, this method does nothing and returns quickly. This case occurs whenever an object was written out of order in order to ensure the delta base occurred before the object that needs it.- Parameters:
otp
- the object to write.- Throws:
IOException
- the object cannot be read from the object reader, or the output stream is no longer accepting output. Caller must examine the type of exception and possibly its message to distinguish between these cases.
-
writeHeader
Commits the object header onto the stream.Once the header has been written, the object representation must be fully output, or packing must abort abnormally.
- Parameters:
otp
- the object to pack. Header information is obtained.rawLength
- number of bytes of the inflated content. For an object that is in whole object format, this is the same as the object size. For an object that is in a delta format, this is the size of the inflated delta instruction stream.- Throws:
IOException
- the underlying stream refused to accept the header.
-
objectHeader
private static final int objectHeader(long len, int type, byte[] buf) -
ofsDelta
private static final int ofsDelta(long diff, byte[] buf, int p) -
ofsDeltaVarIntLength
private static final int ofsDeltaVarIntLength(long v) -
getCopyBuffer
public final byte[] getCopyBuffer()Get a temporary buffer writers can use to copy data with.- Returns:
- a temporary buffer writers can use to copy data with.
-
endObject
void endObject()
-