jzebedee / deltaq

Fast and portable delta encoding for .NET in 100% safe, managed code.
Other
40 stars 13 forks source link

Bzip2 compression useless #4

Closed Skyppid closed 8 years ago

Skyppid commented 8 years ago

What is the matter with the Bzip2 implementation since the stream isn't seekable but the BsDiff-class requires a seekable stream? Is this for the planned upcoming VCDIFF implementation?

jzebedee commented 8 years ago

Bz2 will compress in a run-on fashion, so seeking wouldn't accomplish anything in the output stream. Bsdiff/bspatch never use seeking in the Bz2 streams themselves, only the I/O streams given for diff or patch inputs.

Bsdiff requires a seekable output stream while creating a diff because it has to complete the control, diff, and extra sections before seeking back to the beginning in order to write the header of the file.

Bspatch only requires a seekable input stream, which Bz2 handles fine. Bspatch seeks the input to read the ctrl, diff, and extra segments all at once, since each control triplet can require data from any of the three while patching a file.