1 // Copyright (c) 2011-present, Facebook, Inc.  All rights reserved.
2 //  This source code is licensed under both the GPLv2 (found in the
3 //  COPYING file in the root directory) and Apache 2.0 License
4 //  (found in the LICENSE.Apache file in the root directory).
5 
6 package org.rocksdb;
7 
8 import org.junit.ClassRule;
9 import org.junit.Test;
10 
11 import static org.assertj.core.api.Assertions.assertThat;
12 
13 public class PlainTableConfigTest {
14 
15   @ClassRule
16   public static final RocksNativeLibraryResource ROCKS_NATIVE_LIBRARY_RESOURCE =
17       new RocksNativeLibraryResource();
18 
19   @Test
keySize()20   public void keySize() {
21     PlainTableConfig plainTableConfig = new PlainTableConfig();
22     plainTableConfig.setKeySize(5);
23     assertThat(plainTableConfig.keySize()).
24         isEqualTo(5);
25   }
26 
27   @Test
bloomBitsPerKey()28   public void bloomBitsPerKey() {
29     PlainTableConfig plainTableConfig = new PlainTableConfig();
30     plainTableConfig.setBloomBitsPerKey(11);
31     assertThat(plainTableConfig.bloomBitsPerKey()).
32         isEqualTo(11);
33   }
34 
35   @Test
hashTableRatio()36   public void hashTableRatio() {
37     PlainTableConfig plainTableConfig = new PlainTableConfig();
38     plainTableConfig.setHashTableRatio(0.95);
39     assertThat(plainTableConfig.hashTableRatio()).
40         isEqualTo(0.95);
41   }
42 
43   @Test
indexSparseness()44   public void indexSparseness() {
45     PlainTableConfig plainTableConfig = new PlainTableConfig();
46     plainTableConfig.setIndexSparseness(18);
47     assertThat(plainTableConfig.indexSparseness()).
48         isEqualTo(18);
49   }
50 
51   @Test
hugePageTlbSize()52   public void hugePageTlbSize() {
53     PlainTableConfig plainTableConfig = new PlainTableConfig();
54     plainTableConfig.setHugePageTlbSize(1);
55     assertThat(plainTableConfig.hugePageTlbSize()).
56         isEqualTo(1);
57   }
58 
59   @Test
encodingType()60   public void encodingType() {
61     PlainTableConfig plainTableConfig = new PlainTableConfig();
62     plainTableConfig.setEncodingType(EncodingType.kPrefix);
63     assertThat(plainTableConfig.encodingType()).isEqualTo(
64         EncodingType.kPrefix);
65   }
66 
67   @Test
fullScanMode()68   public void fullScanMode() {
69     PlainTableConfig plainTableConfig = new PlainTableConfig();
70     plainTableConfig.setFullScanMode(true);
71     assertThat(plainTableConfig.fullScanMode()).isTrue();  }
72 
73   @Test
storeIndexInFile()74   public void storeIndexInFile() {
75     PlainTableConfig plainTableConfig = new PlainTableConfig();
76     plainTableConfig.setStoreIndexInFile(true);
77     assertThat(plainTableConfig.storeIndexInFile()).
78         isTrue();
79   }
80 
81   @Test
plainTableConfig()82   public void plainTableConfig() {
83     try(final Options opt = new Options()) {
84       final PlainTableConfig plainTableConfig = new PlainTableConfig();
85       opt.setTableFormatConfig(plainTableConfig);
86       assertThat(opt.tableFactoryName()).isEqualTo("PlainTable");
87     }
88   }
89 }
90