public class BinaryDeltaInputStream extends InputStream
InputStream
that applies a binary delta to a base on the fly.
Delta application to a base needs random access to the base data. The delta is expressed as a sequence of copy and insert instructions. A copy instruction has the form "COPY fromOffset length" and says "copy length bytes from the base, starting at offset fromOffset, to the result". An insert instruction has the form "INSERT length" followed by length bytes and says "copy the next length bytes from the delta to the result".
These instructions are generated using a content-defined chunking algorithm (currently C git uses the standard Rabin variant; but there are others that could be used) that identifies equal chunks. It is entirely possible that a later copy instruction has a fromOffset that is before the fromOffset of an earlier copy instruction.
This makes it impossible to stream the base.
JGit is limited to 2GB maximum size for the base since array indices are signed 32bit values.
Constructor and Description |
---|
BinaryDeltaInputStream(byte[] base,
InputStream delta)
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
long |
getExpectedResultSize()
Tells the expected size of the final result.
|
boolean |
isFullyConsumed()
Tells whether the delta has been fully consumed, and the expected number
of bytes for the combined result have been read from this
BinaryDeltaInputStream . |
int |
read() |
int |
read(byte[] b,
int off,
int len) |
available, mark, markSupported, read, reset, skip
public BinaryDeltaInputStream(byte[] base, InputStream delta)
base
- data to apply the delta todelta
- InputStream
delivering the delta to applypublic int read() throws IOException
read
in class InputStream
IOException
public int read(byte[] b, int off, int len) throws IOException
read
in class InputStream
IOException
public long getExpectedResultSize() throws IOException
IOException
- if the size cannot be determined from delta
public boolean isFullyConsumed()
BinaryDeltaInputStream
.public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in class InputStream
IOException
Copyright © 2021 Eclipse JGit Project. All rights reserved.