Add new checksum type kXXH3 to Java API (#9749)

Summary:
Fix https://github.com/facebook/rocksdb/issues/9720

And make a couple of incidental tests test the thing they were meant to test.

Pull Request resolved: https://github.com/facebook/rocksdb/pull/9749

Reviewed By: ajkr

Differential Revision: D35115298

Pulled By: jay-zhuang

fbshipit-source-id: d687d1f070d29216be9693601c71131bbea87c79
This commit is contained in:
Alan Paxton 2022-03-24 12:33:12 -07:00 committed by Facebook GitHub Bot
parent f219e3d5d8
commit 8ae0c33a7a
3 changed files with 19 additions and 13 deletions

View file

@ -6539,6 +6539,8 @@ class ChecksumTypeJni {
return 0x2; return 0x2;
case ROCKSDB_NAMESPACE::ChecksumType::kxxHash64: case ROCKSDB_NAMESPACE::ChecksumType::kxxHash64:
return 0x3; return 0x3;
case ROCKSDB_NAMESPACE::ChecksumType::kXXH3:
return 0x4;
default: default:
return 0x7F; // undefined return 0x7F; // undefined
} }

View file

@ -24,7 +24,9 @@ public enum ChecksumType {
/** /**
* XX Hash 64 * XX Hash 64
*/ */
kxxHash64((byte) 3); kxxHash64((byte) 3),
kXXH3((byte) 4);
/** /**
* Returns the byte value of the enumerations value * Returns the byte value of the enumerations value
@ -35,7 +37,7 @@ public enum ChecksumType {
return value_; return value_;
} }
private ChecksumType(byte value) { private ChecksumType(final byte value) {
value_ = value; value_ = value;
} }

View file

@ -62,35 +62,37 @@ public class BlockBasedTableConfigTest {
final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig(); final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig();
assertThat(IndexType.values().length).isEqualTo(4); assertThat(IndexType.values().length).isEqualTo(4);
blockBasedTableConfig.setIndexType(IndexType.kHashSearch); blockBasedTableConfig.setIndexType(IndexType.kHashSearch);
assertThat(blockBasedTableConfig.indexType().equals( assertThat(blockBasedTableConfig.indexType()).isEqualTo(IndexType.kHashSearch);
IndexType.kHashSearch));
assertThat(IndexType.valueOf("kBinarySearch")).isNotNull(); assertThat(IndexType.valueOf("kBinarySearch")).isNotNull();
blockBasedTableConfig.setIndexType(IndexType.valueOf("kBinarySearch")); blockBasedTableConfig.setIndexType(IndexType.valueOf("kBinarySearch"));
assertThat(blockBasedTableConfig.indexType().equals( assertThat(blockBasedTableConfig.indexType()).isEqualTo(IndexType.kBinarySearch);
IndexType.kBinarySearch));
} }
@Test @Test
public void dataBlockIndexType() { public void dataBlockIndexType() {
final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig(); final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig();
blockBasedTableConfig.setDataBlockIndexType(DataBlockIndexType.kDataBlockBinaryAndHash); blockBasedTableConfig.setDataBlockIndexType(DataBlockIndexType.kDataBlockBinaryAndHash);
assertThat(blockBasedTableConfig.dataBlockIndexType().equals( assertThat(blockBasedTableConfig.dataBlockIndexType())
DataBlockIndexType.kDataBlockBinaryAndHash)); .isEqualTo(DataBlockIndexType.kDataBlockBinaryAndHash);
blockBasedTableConfig.setDataBlockIndexType(DataBlockIndexType.kDataBlockBinarySearch); blockBasedTableConfig.setDataBlockIndexType(DataBlockIndexType.kDataBlockBinarySearch);
assertThat(blockBasedTableConfig.dataBlockIndexType().equals( assertThat(blockBasedTableConfig.dataBlockIndexType())
DataBlockIndexType.kDataBlockBinarySearch)); .isEqualTo(DataBlockIndexType.kDataBlockBinarySearch);
} }
@Test @Test
public void checksumType() { public void checksumType() {
final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig(); final BlockBasedTableConfig blockBasedTableConfig = new BlockBasedTableConfig();
assertThat(ChecksumType.values().length).isEqualTo(4); assertThat(ChecksumType.values().length).isEqualTo(5);
assertThat(ChecksumType.valueOf("kxxHash")). assertThat(ChecksumType.valueOf("kxxHash")).
isEqualTo(ChecksumType.kxxHash); isEqualTo(ChecksumType.kxxHash);
blockBasedTableConfig.setChecksumType(ChecksumType.kNoChecksum); blockBasedTableConfig.setChecksumType(ChecksumType.kNoChecksum);
assertThat(blockBasedTableConfig.checksumType()).isEqualTo(ChecksumType.kNoChecksum);
blockBasedTableConfig.setChecksumType(ChecksumType.kxxHash); blockBasedTableConfig.setChecksumType(ChecksumType.kxxHash);
assertThat(blockBasedTableConfig.checksumType().equals( assertThat(blockBasedTableConfig.checksumType()).isEqualTo(ChecksumType.kxxHash);
ChecksumType.kxxHash)); blockBasedTableConfig.setChecksumType(ChecksumType.kxxHash64);
assertThat(blockBasedTableConfig.checksumType()).isEqualTo(ChecksumType.kxxHash64);
blockBasedTableConfig.setChecksumType(ChecksumType.kXXH3);
assertThat(blockBasedTableConfig.checksumType()).isEqualTo(ChecksumType.kXXH3);
} }
@Test @Test