mirror of
https://github.com/facebook/rocksdb
synced 2026-05-24 09:29:21 +00:00
Summary: **Description** This PR passes along the native `LiveFileMetaData#file_checksum` field from the C++ class to the Java API as a copied byte array. If there is no file checksum generator factory set beforehand, then the array will empty. Please advise if you'd rather it be null - an empty array means one extra allocation, but it avoids possible null pointer exceptions. > **Note** > This functionality complements but does not supersede https://github.com/facebook/rocksdb/issues/11736 It's outside the scope here to add support for Java based `FileChecksumGenFactory` implementations. As a workaround, users can already use the built-in one by creating their initial `DBOptions` via properties: ```java final Properties props = new Properties(); props.put("file_checksum_gen_factory", "FileChecksumGenCrc32cFactory"); try (final DBOptions dbOptions = DBOptions.getDBOptionsFromProps(props); final ColumnFamilyOptions cfOptions = new ColumnFamilyOptions(); final Options options = new Options(dbOptions, cfOptions).setCreateIfMissing(true)) { // do stuff } ``` I wanted to add a better test, but unfortunately there's no available CRC32C implementation available in Java 8 without adding a dependency or adding a JNI helper for RocksDB's own implementation (or bumping the minimum version for tests to Java 9). That said, I understand the test is rather poor, so happy to change it to whatever you'd like. **Context** To give some context, we replicate RocksDB checkpoints to other nodes. Part of this is verifying the integrity of each file during replication. With a large enough RocksDB, computing the checksum ourselves is prohibitively expensive. Since SST files comprise the bulk of the data, we'd much rather delegate this to RocksDB on file write, and read it back after to compare. It's likely we will provide a follow up to read the file checksum list directly from the manifest without having to open the DB, but this was the easiest first step to get it working for us. Pull Request resolved: https://github.com/facebook/rocksdb/pull/11770 Reviewed By: hx235 Differential Revision: D52420729 Pulled By: ajkr fbshipit-source-id: a873de35a48aaf315e125733091cd221a97b9073 |
||
|---|---|---|
| .. | ||
| benchmark/src/main/java/org/rocksdb/benchmark | ||
| crossbuild | ||
| jmh | ||
| rocksjni | ||
| samples/src/main/java | ||
| src | ||
| CMakeLists.txt | ||
| GetPutBenchmarks.md | ||
| HISTORY-JAVA.md | ||
| jdb_bench.sh | ||
| Makefile | ||
| pmd-rules.xml | ||
| pom.xml.template | ||
| RELEASE.md | ||
| spotbugs-exclude.xml | ||
| understanding_options.md | ||