Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for the seekable format #310

Merged
merged 1 commit into from
Jan 17, 2025

Conversation

rorosen
Copy link
Contributor

@rorosen rorosen commented Nov 25, 2024

This adds bindings for the seekable format to zstd-safe. Everything is behind the seekable feature flag, which disabled by default, and the basic functionality is covered by unit tests. In general, this is close to a 1-for-1 mapping to the seekable format C functions using rust types.

However, everything around the seek table API is commented out for now. I noticed that the creation of a seek table in ZSTD_seekTable_create_fromSeekable() (which is the only way to create a seek table) can cause a segmentation fault, if called with an uninitialized seekable. There is already a PR open upstream to fix the issue (facebook/zstd#4201). The complete seekable format can be used without access to the seek table functions without limitations, afaict they only provide advantages when working with multiple seekable archives in memory constrained environments.

This feature is also requested in #272

Copy link
Owner

@gyscos gyscos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for the work here!

Left a couple of comments, but overall it looks very nice, and I'm looking forward to merging it.

EDIT: It seems facebook/zstd#4201 was merged back in November, but we're still waiting for a release (1.5.7?) to include it.

zstd-safe/zstd-sys/update_bindings.sh Outdated Show resolved Hide resolved
zstd-safe/zstd-sys/zstd_seekable.h Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
zstd-safe/src/seekable.rs Show resolved Hide resolved
zstd-safe/src/seekable.rs Show resolved Hide resolved
zstd-safe/src/seekable.rs Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
@rorosen rorosen force-pushed the init-seekable-format branch from 9015062 to 40111e3 Compare January 11, 2025 10:19
@rorosen
Copy link
Contributor Author

rorosen commented Jan 11, 2025

Thanks for your review!

I updated the PR according to your suggestions, let me know if there is anything else.

I also think the SeekTable creation can be made safe with the next release of zstd.

zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
zstd-safe/src/seekable.rs Outdated Show resolved Hide resolved
Support the seekable format through bindings to the upstream
functionality in zstd-safe. The seekable format can be activated with
the `seekable` feature flag.
@rorosen rorosen force-pushed the init-seekable-format branch from 40111e3 to ab2ae11 Compare January 15, 2025 07:13
@gyscos gyscos merged commit 21d79e8 into gyscos:main Jan 17, 2025
5 checks passed
@rorosen rorosen deleted the init-seekable-format branch January 17, 2025 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants