Package org.rocksdb

Class PlainTableConfig

java.lang.Object
org.rocksdb.TableFormatConfig
org.rocksdb.PlainTableConfig

public class PlainTableConfig extends TableFormatConfig
The config for plain table sst format.

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 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

      public static final EncodingType 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

      public PlainTableConfig setKeySize(int keySize)

      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

      public PlainTableConfig setBloomBitsPerKey(int bitsPerKey)
      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

      public PlainTableConfig setHashTableRatio(double ratio)
      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

      public PlainTableConfig setIndexSparseness(int sparseness)
      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

      public PlainTableConfig setHugePageTlbSize(int hugePageTlbSize)

      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=20

      See 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

      public PlainTableConfig setEncodingType(EncodingType encodingType)
      Sets the encoding type.

      This setting determines how to encode the keys. See enum EncodingType for 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 - EncodingType value.
      Returns:
      the reference to the current config.
    • encodingType

      public EncodingType encodingType()
      Returns the active EncodingType
      Returns:
      currently set encoding type
    • setFullScanMode

      public PlainTableConfig setFullScanMode(boolean fullScanMode)
      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

      public PlainTableConfig setStoreIndexInFile(boolean storeIndexInFile)

      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: TableFormatConfig

      This 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:
      newTableFactoryHandle in class TableFormatConfig
      Returns:
      native handle address to native table instance.