Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Question on large object streams

> A delta is stored as a sequence of instructions to either copy data
> from the base object, or to insert a section of data which doesn't
> appear in the base (but needs to appear in the result).  A copy
> instruction has two arguments, the offset within the base to copy
> from, and the number of total bytes to copy.  The offset is absolute
> from the start of the base.
>
> It is not uncommon for a delta instruction stream to skip around
> within the base.  That is, it might be something like:
>
>  COPY from=45, len=12
>  INSERT "foo"
>  COPY from=12, len=4
>  INSERT "bar"
>  COPY from=63, len=8
>  INSERT "q"
>  COPY from=0, len=8
>
> Stepping from a COPY from=45 to COPY from=12 requires seeking
> backwards in the base to reposition from offset 57 (where the copy
> ended) to offset 12 (where the next copy starts).  When the base
> object is stored in as a byte[] in memory this seek backwards is free,
> we set a variable to the new position (12) and use that as the array
> index to copy with.  When the base object is an inflater stream we
> can't just seek backwards.  We have to close the stream, open it
> again, and skip forwards to the position.  Skipping forwards in an
> inflate stream requires inflating to a discard buffer.
>

One more question on this: why can't we inflate base object and use
RandomAccessFile to read from it?


Back to the top