Class PlainTableConfig
PlainTable is a RocksDB's SST file format optimized for low query latency on pure-memory or really low-latency media.
It also support prefix hash feature.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final EncodingTypestatic final booleanstatic final doublestatic final intstatic final intstatic final booleanstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintReturns the active EncodingTypebooleanReturn if full scan mode is activedoubleintReturns the value for huge page tlb sizelongintkeySize()protected longThis function should only be called by Options.setTableFormatConfig(), which will create a c++ shared-pointer to the c++ TableFactory that associated with the Java TableFormatConfig.setBloomBitsPerKey(int bitsPerKey) Set the number of bits per key used by the internal bloom filter in the plain table sst format.setEncodingType(EncodingType encodingType) Sets the encoding type.setFullScanMode(boolean fullScanMode) Set full scan mode, if true the whole file will be read one record by one without using the index.setHashTableRatio(double ratio) hashTableRatio is the desired utilization of the hash table used for prefix hashing.setHugePageTlbSize(int hugePageTlbSize) huge_page_tlb_size: if ≤0, allocate hash indexes and blooms from malloc otherwise from huge page TLB.setIndexSparseness(int sparseness) Index sparseness determines the index interval for keys inside the same prefix.setKeySize(int keySize) Set the length of the user key.setStoreIndexInFile(boolean storeIndexInFile) If set to true: compute plain table index and bloom filter during file building and store it in file.booleanReturn a boolean value indicating if index shall be stored in a file.
-
Field Details
-
VARIABLE_LENGTH
public static final int VARIABLE_LENGTH- See Also:
-
DEFAULT_BLOOM_BITS_PER_KEY
public static final int DEFAULT_BLOOM_BITS_PER_KEY- See Also:
-
DEFAULT_HASH_TABLE_RATIO
public static final double DEFAULT_HASH_TABLE_RATIO- See Also:
-
DEFAULT_INDEX_SPARSENESS
public static final int DEFAULT_INDEX_SPARSENESS- See Also:
-
DEFAULT_HUGE_TLB_SIZE
public static final int DEFAULT_HUGE_TLB_SIZE- See Also:
-
DEFAULT_ENCODING_TYPE
-
DEFAULT_FULL_SCAN_MODE
public static final boolean DEFAULT_FULL_SCAN_MODE- See Also:
-
DEFAULT_STORE_INDEX_IN_FILE
public static final boolean DEFAULT_STORE_INDEX_IN_FILE- See Also:
-
-
Constructor Details
-
PlainTableConfig
public PlainTableConfig()
-
-
Method Details
-
setKeySize
Set the length of the user key. If it is set to be VARIABLE_LENGTH, then it indicates the user keys are of variable length.
Otherwise,all the keys need to have the same length in byte.
DEFAULT: VARIABLE_LENGTH
- Parameters:
keySize- the length of the user key.- Returns:
- the reference to the current config.
-
keySize
public int keySize()- Returns:
- the specified size of the user key. If VARIABLE_LENGTH, then it indicates variable-length key.
-
setBloomBitsPerKey
Set the number of bits per key used by the internal bloom filter in the plain table sst format.- Parameters:
bitsPerKey- the number of bits per key for bloom filer.- Returns:
- the reference to the current config.
-
bloomBitsPerKey
public int bloomBitsPerKey()- Returns:
- the number of bits per key used for the bloom filter.
-
setHashTableRatio
hashTableRatio is the desired utilization of the hash table used for prefix hashing. The ideal ratio would be the number of prefixes / the number of hash buckets. If this value is set to zero, then hash table will not be used.- Parameters:
ratio- the hash table ratio.- Returns:
- the reference to the current config.
-
hashTableRatio
public double hashTableRatio()- Returns:
- the hash table ratio.
-
setIndexSparseness
Index sparseness determines the index interval for keys inside the same prefix. This number is equal to the maximum number of linear search required after hash and binary search. If it's set to 0, then each key will be indexed.- Parameters:
sparseness- the index sparseness.- Returns:
- the reference to the current config.
-
indexSparseness
public long indexSparseness()- Returns:
- the index sparseness.
-
setHugePageTlbSize
huge_page_tlb_size: if ≤0, allocate hash indexes and blooms from malloc otherwise from huge page TLB.
The user needs to reserve huge pages for it to be allocated, like:
sysctl -w vm.nr_hugepages=20See linux doc Documentation/vm/hugetlbpage.txt
- Parameters:
hugePageTlbSize- huge page tlb size- Returns:
- the reference to the current config.
-
hugePageTlbSize
public int hugePageTlbSize()Returns the value for huge page tlb size- Returns:
- hugePageTlbSize
-
setEncodingType
Sets the encoding type.This setting determines how to encode the keys. See enum
EncodingTypefor the choices.The value will determine how to encode keys when writing to a new SST file. This value will be stored inside the SST file which will be used when reading from the file, which makes it possible for users to choose different encoding type when reopening a DB. Files with different encoding types can co-exist in the same DB and can be read.
- Parameters:
encodingType-EncodingTypevalue.- Returns:
- the reference to the current config.
-
encodingType
Returns the active EncodingType- Returns:
- currently set encoding type
-
setFullScanMode
Set full scan mode, if true the whole file will be read one record by one without using the index.- Parameters:
fullScanMode- boolean value indicating if full scan mode shall be enabled.- Returns:
- the reference to the current config.
-
fullScanMode
public boolean fullScanMode()Return if full scan mode is active- Returns:
- boolean value indicating if the full scan mode is enabled.
-
setStoreIndexInFile
If set to true: compute plain table index and bloom filter during file building and store it in file. When reading file, index will be mmaped instead of doing recomputation.
- Parameters:
storeIndexInFile- value indicating if index shall be stored in a file- Returns:
- the reference to the current config.
-
storeIndexInFile
public boolean storeIndexInFile()Return a boolean value indicating if index shall be stored in a file.- Returns:
- currently set value for store index in file.
-
newTableFactoryHandle
protected long newTableFactoryHandle()Description copied from class:TableFormatConfigThis function should only be called by Options.setTableFormatConfig(), which will create a c++ shared-pointer to the c++ TableFactory that associated with the Java TableFormatConfig.
- Specified by:
newTableFactoryHandlein classTableFormatConfig- Returns:
- native handle address to native table instance.
-