diff --git a/HISTORY.md b/HISTORY.md index f243cb380..c03c5e1b2 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,5 +1,9 @@ # Rocksdb Change Log ## Unreleased + +### Public API Change +* Add NewFileChecksumGenCrc32cFactory to the file checksum public API, such that the builtin Crc32c based file checksum generator factory can be used by applications. + ### New Features * Log CompactOnDeletionCollectorFactory window_size and deletion_trigger parameters in the info log file for troubleshooting purposes. diff --git a/include/rocksdb/file_checksum.h b/include/rocksdb/file_checksum.h index 61975f0f3..e7b27fb78 100644 --- a/include/rocksdb/file_checksum.h +++ b/include/rocksdb/file_checksum.h @@ -97,4 +97,10 @@ class FileChecksumList { // Create a new file checksum list. extern FileChecksumList* NewFileChecksumList(); +// Return a shared_ptr of the builtin Crc32 based file checksum generatory +// factory object, which can be shared to create the Crc32c based checksum +// generator object. +extern std::shared_ptr +GetFileChecksumGenCrc32cFactory(); + } // namespace ROCKSDB_NAMESPACE diff --git a/tools/ldb_cmd_test.cc b/tools/ldb_cmd_test.cc index db3f7e50a..8bc9c438a 100644 --- a/tools/ldb_cmd_test.cc +++ b/tools/ldb_cmd_test.cc @@ -344,9 +344,7 @@ TEST_F(LdbCmdTest, DumpFileChecksumCRC32) { Options opts; opts.env = env.get(); opts.create_if_missing = true; - FileChecksumGenCrc32cFactory* file_checksum_gen_factory = - new FileChecksumGenCrc32cFactory(); - opts.file_checksum_gen_factory.reset(file_checksum_gen_factory); + opts.file_checksum_gen_factory = GetFileChecksumGenCrc32cFactory(); DB* db = nullptr; std::string dbname = test::TmpDir(); diff --git a/util/file_checksum_helper.cc b/util/file_checksum_helper.cc index 5a8b6ded9..e8f32fb84 100644 --- a/util/file_checksum_helper.cc +++ b/util/file_checksum_helper.cc @@ -77,4 +77,10 @@ FileChecksumList* NewFileChecksumList() { return checksum_list; } +std::shared_ptr GetFileChecksumGenCrc32cFactory() { + static std::shared_ptr default_crc32c_gen_factory( + new FileChecksumGenCrc32cFactory()); + return default_crc32c_gen_factory; +} + } // namespace ROCKSDB_NAMESPACE