diff --git a/HISTORY.md b/HISTORY.md index 145525668b33a8898cd17f4a37ffa1887c0c3e98..bc7b2784f510b26a735d0b6e06728d1acc56244b 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -3,6 +3,9 @@ ### Bug Fixes * Fix wrong result being read from ingested file. May happen when a key in the file happen to be prefix of another key also in the file. The issue can further cause more data corruption. The issue exists with rocksdb >= 5.0.0 since DB::IngestExternalFile() was introduced. +### 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 * Added support for pipelined & parallel compression optimization for `BlockBasedTableBuilder`. This optimization makes block building, block compression and block appending a pipeline, and uses multiple threads to accelerate block compression. Users can set `CompressionOptions::parallel_threads` greater than 1 to enable compression parallelism. * Provide an allocator for memkind to be used with block cache. This is to work with memory technologies (Intel DCPMM is one such technology currently available) that require different libraries for allocation and management (such as PMDK and memkind). The high capacities available make it possible to provision large caches (up to several TBs in size) beyond what is achievable with DRAM. diff --git a/include/rocksdb/file_checksum.h b/include/rocksdb/file_checksum.h index 61975f0f38cf08d142a0c57d6ff0bc32bd40e6c5..e7b27fb7851f89b9d8b1179915287679c69977a9 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 db3f7e50a1e94d7a9a8fabca4fd7e169b9a9857b..8bc9c438aba77ec35fc9ae0e383d09478be4c4db 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 5a8b6ded9f94bac6522ce78753294b89e30e6909..e8f32fb842f95ceb5ab1c496c99cc42c9d913817 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