Expose file_checksum and file_checksum_func_name in C API for live files#14532
Open
othmanekn wants to merge 2 commits intofacebook:mainfrom
Open
Expose file_checksum and file_checksum_func_name in C API for live files#14532othmanekn wants to merge 2 commits intofacebook:mainfrom
othmanekn wants to merge 2 commits intofacebook:mainfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The C++
SstFileMetaDatastruct (viaFileStorageInfoinmetadata.h) already exposesfile_checksumandfile_checksum_func_namefields, which are populated whenfile_checksum_gen_factoryis configured inDBOptions. However, these fields have no corresponding accessors in the C API (c.h), making them inaccessible to language bindings that wrap the C API (e.g., rust-rocksdb, gorocksdb, rocksdb-py).This PR simply exposes the existing C++ functionality through the C API, following the exact same patterns used by the other
rocksdb_livefiles_*accessors.Changes
Getters (read checksum data from
rocksdb_livefiles_t):rocksdb_livefiles_file_checksum(livefiles, index)— returns the file checksum stringrocksdb_livefiles_file_checksum_func_name(livefiles, index)— returns the checksum function name (e.g.,"FileChecksumCrc32c")Setters (builder pattern on
rocksdb_livefile_t, for symmetry with existingrocksdb_livefile_set_*functions):rocksdb_livefile_set_file_checksum(livefile, checksum)rocksdb_livefile_set_file_checksum_func_name(livefile, func_name)Test in
c_test.c:FileChecksumGenCrc32cFactoryenabledrocksdb_livefiles_file_checksum()returns a non-empty valuerocksdb_livefiles_file_checksum_func_name()returns"FileChecksumCrc32c"Motivation
We maintain a distributed key-value store built on RocksDB (via rust-rocksdb, which wraps the C API). During snapshot operations, we need SST file checksums for deduplication. Currently we compute CRC32 checksums ourselves by reading entire SST files from disk, even though RocksDB already computes and stores these checksums internally when
file_checksum_gen_factoryis configured. Exposing these fields through the C API would eliminate redundant I/O for all C API consumers.