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
main
Alan Paxton 3 years ago committed by Facebook GitHub Bot
parent f219e3d5d8
commit 8ae0c33a7a
  1. 2
      java/rocksjni/portal.h
  2. 6
      java/src/main/java/org/rocksdb/ChecksumType.java
  3. 24
      java/src/test/java/org/rocksdb/BlockBasedTableConfigTest.java

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

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

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

Loading…
Cancel
Save