|
|
@ -5,49 +5,85 @@ |
|
|
|
|
|
|
|
|
|
|
|
package org.rocksdb.test; |
|
|
|
package org.rocksdb.test; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.junit.AfterClass; |
|
|
|
import org.junit.ClassRule; |
|
|
|
import org.junit.ClassRule; |
|
|
|
import org.junit.Test; |
|
|
|
import org.junit.Test; |
|
|
|
import org.rocksdb.BlockBasedTableConfig; |
|
|
|
import org.rocksdb.*; |
|
|
|
import org.rocksdb.ChecksumType; |
|
|
|
|
|
|
|
import org.rocksdb.IndexType; |
|
|
|
import static org.assertj.core.api.Assertions.assertThat; |
|
|
|
|
|
|
|
|
|
|
|
public class BlockBasedTableConfigTest { |
|
|
|
public class BlockBasedTableConfigTest { |
|
|
|
|
|
|
|
|
|
|
|
@ClassRule |
|
|
|
@ClassRule |
|
|
|
public static final RocksMemoryResource rocksMemoryResource = |
|
|
|
public static final RocksMemoryResource rocksMemoryResource = |
|
|
|
new RocksMemoryResource(); |
|
|
|
new RocksMemoryResource(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@AfterClass |
|
|
|
|
|
|
|
public static void printMessage(){ |
|
|
|
|
|
|
|
System.out.println("Passed BlockBasedTableConfigTst."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
public void shouldTestBlockBasedTableConfig() { |
|
|
|
public void shouldTestBlockBasedTableConfig() { |
|
|
|
BlockBasedTableConfig blockBasedTableConfig = |
|
|
|
BlockBasedTableConfig blockBasedTableConfig = |
|
|
|
new BlockBasedTableConfig(); |
|
|
|
new BlockBasedTableConfig(); |
|
|
|
blockBasedTableConfig.setNoBlockCache(true); |
|
|
|
blockBasedTableConfig.setNoBlockCache(true); |
|
|
|
assert(blockBasedTableConfig.noBlockCache()); |
|
|
|
assertThat(blockBasedTableConfig.noBlockCache()).isTrue(); |
|
|
|
blockBasedTableConfig.setBlockCacheSize(8*1024); |
|
|
|
blockBasedTableConfig.setBlockCacheSize(8 * 1024); |
|
|
|
assert(blockBasedTableConfig.blockCacheSize() == (8*1024)); |
|
|
|
assertThat(blockBasedTableConfig.blockCacheSize()). |
|
|
|
|
|
|
|
isEqualTo(8 * 1024); |
|
|
|
blockBasedTableConfig.setBlockSizeDeviation(12); |
|
|
|
blockBasedTableConfig.setBlockSizeDeviation(12); |
|
|
|
assert(blockBasedTableConfig.blockSizeDeviation() == 12); |
|
|
|
assertThat(blockBasedTableConfig.blockSizeDeviation()). |
|
|
|
|
|
|
|
isEqualTo(12); |
|
|
|
blockBasedTableConfig.setBlockRestartInterval(15); |
|
|
|
blockBasedTableConfig.setBlockRestartInterval(15); |
|
|
|
assert(blockBasedTableConfig.blockRestartInterval() == 15); |
|
|
|
assertThat(blockBasedTableConfig.blockRestartInterval()). |
|
|
|
|
|
|
|
isEqualTo(15); |
|
|
|
blockBasedTableConfig.setWholeKeyFiltering(false); |
|
|
|
blockBasedTableConfig.setWholeKeyFiltering(false); |
|
|
|
assert(!blockBasedTableConfig.wholeKeyFiltering()); |
|
|
|
assertThat(blockBasedTableConfig.wholeKeyFiltering()). |
|
|
|
|
|
|
|
isFalse(); |
|
|
|
blockBasedTableConfig.setCacheIndexAndFilterBlocks(true); |
|
|
|
blockBasedTableConfig.setCacheIndexAndFilterBlocks(true); |
|
|
|
assert(blockBasedTableConfig.cacheIndexAndFilterBlocks()); |
|
|
|
assertThat(blockBasedTableConfig.cacheIndexAndFilterBlocks()). |
|
|
|
|
|
|
|
isTrue(); |
|
|
|
blockBasedTableConfig.setHashIndexAllowCollision(false); |
|
|
|
blockBasedTableConfig.setHashIndexAllowCollision(false); |
|
|
|
assert(!blockBasedTableConfig.hashIndexAllowCollision()); |
|
|
|
assertThat(blockBasedTableConfig.hashIndexAllowCollision()). |
|
|
|
|
|
|
|
isFalse(); |
|
|
|
blockBasedTableConfig.setBlockCacheCompressedSize(40); |
|
|
|
blockBasedTableConfig.setBlockCacheCompressedSize(40); |
|
|
|
assert(blockBasedTableConfig.blockCacheCompressedSize() == 40); |
|
|
|
assertThat(blockBasedTableConfig.blockCacheCompressedSize()). |
|
|
|
|
|
|
|
isEqualTo(40); |
|
|
|
blockBasedTableConfig.setChecksumType(ChecksumType.kNoChecksum); |
|
|
|
blockBasedTableConfig.setChecksumType(ChecksumType.kNoChecksum); |
|
|
|
blockBasedTableConfig.setChecksumType(ChecksumType.kxxHash); |
|
|
|
blockBasedTableConfig.setChecksumType(ChecksumType.kxxHash); |
|
|
|
assert(blockBasedTableConfig.checksumType().equals( |
|
|
|
assertThat(blockBasedTableConfig.checksumType().equals( |
|
|
|
ChecksumType.kxxHash)); |
|
|
|
ChecksumType.kxxHash)); |
|
|
|
blockBasedTableConfig.setIndexType(IndexType.kHashSearch); |
|
|
|
blockBasedTableConfig.setIndexType(IndexType.kHashSearch); |
|
|
|
assert(blockBasedTableConfig.indexType().equals( |
|
|
|
assertThat(blockBasedTableConfig.indexType().equals( |
|
|
|
IndexType.kHashSearch)); |
|
|
|
IndexType.kHashSearch)); |
|
|
|
blockBasedTableConfig.setBlockCacheCompressedNumShardBits(4); |
|
|
|
blockBasedTableConfig.setBlockCacheCompressedNumShardBits(4); |
|
|
|
assert(blockBasedTableConfig.blockCacheCompressedNumShardBits() |
|
|
|
assertThat(blockBasedTableConfig.blockCacheCompressedNumShardBits()). |
|
|
|
== 4); |
|
|
|
isEqualTo(4); |
|
|
|
blockBasedTableConfig.setCacheNumShardBits(5); |
|
|
|
blockBasedTableConfig.setCacheNumShardBits(5); |
|
|
|
assert(blockBasedTableConfig.cacheNumShardBits() == 5); |
|
|
|
assertThat(blockBasedTableConfig.cacheNumShardBits()). |
|
|
|
|
|
|
|
isEqualTo(5); |
|
|
|
|
|
|
|
blockBasedTableConfig.setBlockSize(10); |
|
|
|
|
|
|
|
assertThat(blockBasedTableConfig.blockSize()).isEqualTo(10); |
|
|
|
System.out.println("Passed BlockBasedTableConfigTest."); |
|
|
|
System.out.println("Passed BlockBasedTableConfigTest."); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void shouldTestBlockBasedTableWithFilter() { |
|
|
|
|
|
|
|
Options options = new Options(); |
|
|
|
|
|
|
|
options.setTableFormatConfig( |
|
|
|
|
|
|
|
new BlockBasedTableConfig().setFilter( |
|
|
|
|
|
|
|
new BloomFilter(10))); |
|
|
|
|
|
|
|
assertThat(options.tableFactoryName()). |
|
|
|
|
|
|
|
isEqualTo("BlockBasedTable"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
public void shouldTestBlockBasedTableWithoutFilter() { |
|
|
|
|
|
|
|
Options options = new Options(); |
|
|
|
|
|
|
|
options.setTableFormatConfig( |
|
|
|
|
|
|
|
new BlockBasedTableConfig().setFilter(null)); |
|
|
|
|
|
|
|
assertThat(options.tableFactoryName()). |
|
|
|
|
|
|
|
isEqualTo("BlockBasedTable"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|