Repository navigation
Replies: 1 comment 5 replies
|
There are several options available through the API: A) Use Flush once you've reached the desired checkpoint. The current block will end and all output will have been written to output. You simply attach a counter to the output. Once Flush has returned you have your compressed offset. And you already control the input. B) Use an approach similar to pgzip that splits input and uses ResetDict to reset with a provided window. You can use concurrent compression of these blocks. It does 1MiB blocks with 16KiB history provided to each. Both will have blocks ending at full byte offsets. You can track the window easily yourself. Though if you are going to store it, you might as well start a clean block. |
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I am developing a pure-Go advanced TAR library ($O(1)$ random access to compressed
github.com/unxed/tar) that provides.tar.gzarchives. To achieve this, we aim for binary compatibility with industry-standard indexes used by Python'sratarmountandgztool, which are based on Mark Adler'szran.c(GZIDXformat).Currently, we can successfully read and seek using existing GZIP indexes in pure Go. We achieve this by loading the 32KB dictionary checkpoint from the index into
flate.NewReaderDictand handling bit-alignment via a custom bit-shifting reader wrapper.However, we are unable to generate these indexes on-the-fly during sequential decompression. This limitation exists because the internal state of the
flatedecompressor is encapsulated, making it impossible to capture the necessary checkpoint metadata.What is needed to generate a
zran-compatible index:During sequential decompression, we need to periodically (e.g., every 1MB or 4MB of uncompressed data) capture a checkpoint containing:
Proposed API Changes / Ideas
It would be extremely helpful to have an API or hook in
github.com/klauspost/compress/gzip(or the underlyingflatepackage) to retrieve this state.For example, a callback hook or an interface on the Reader:
I would be glad to discuss how such an API could be designed or to contribute to a prototype if this feature aligns with the roadmap of the repository.
References:
https://github.com/madler/zlib/blob/master/examples/zran.c
https://github.com/mxmlnkn/ratarmount
https://github.com/circulosmeos/gztool
https://github.com/unxed/tar
All reactions