mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Summary: Addressed all the issues in https://reviews.facebook.net/D15447. Now most table-related modules are hidden from user land. Test Plan: make check Reviewers: sdong, haobo, dhruba CC: leveldb Differential Revision: https://reviews.facebook.net/D15525
73 lines
2.9 KiB
C++
73 lines
2.9 KiB
C++
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
//
|
|
// Currently we support two types of tables: plain table and block-based table.
|
|
// 1. Block-based table: this is the default table type that we inherited from
|
|
// LevelDB, which was designed for storing data in hard disk or flash
|
|
// device.
|
|
// 2. Plain table: it is one of RocksDB's SST file format optimized
|
|
// for low query latency on pure-memory or really low-latency media.
|
|
//
|
|
// A tutorial of rocksdb table formats is available here:
|
|
// https://github.com/facebook/rocksdb/wiki/A-Tutorial-of-RocksDB-SST-formats
|
|
//
|
|
// Example code is also available
|
|
// https://github.com/facebook/rocksdb/wiki/A-Tutorial-of-RocksDB-SST-formats#wiki-examples
|
|
|
|
#pragma once
|
|
#include <memory>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
#include "rocksdb/env.h"
|
|
#include "rocksdb/iterator.h"
|
|
#include "rocksdb/options.h"
|
|
#include "rocksdb/status.h"
|
|
|
|
namespace rocksdb {
|
|
|
|
class TableFactory;
|
|
|
|
// -- Block-based Table
|
|
class FlushBlockPolicyFactory;
|
|
|
|
// For advanced user only
|
|
struct BlockBasedTableOptions {
|
|
// @flush_block_policy_factory creates the instances of flush block policy.
|
|
// which provides a configurable way to determine when to flush a block in
|
|
// the block based tables. If not set, table builder will use the default
|
|
// block flush policy, which cut blocks by block size (please refer to
|
|
// `FlushBlockBySizePolicy`).
|
|
std::shared_ptr<FlushBlockPolicyFactory> flush_block_policy_factory;
|
|
|
|
// TODO(kailiu) Temporarily disable this feature by making the default value
|
|
// to be false.
|
|
//
|
|
// Indicating if we'd put index/filter blocks to the block cache.
|
|
// If not specified, each "table reader" object will pre-load index/filter
|
|
// block during table initialization.
|
|
bool cache_index_and_filter_blocks = false;
|
|
};
|
|
|
|
// Create default block based table factory.
|
|
extern TableFactory* NewBlockBasedTableFactory(
|
|
const BlockBasedTableOptions& table_options = BlockBasedTableOptions());
|
|
|
|
// -- Plain Table
|
|
// @user_key_len: plain table has optimization for fix-sized keys, which can be
|
|
// specified via user_key_len. Alternatively, you can pass
|
|
// `kPlainTableVariableLength` if your keys have variable
|
|
// lengths.
|
|
// @bloom_bits_per_key: the number of bits used for bloom filer per key. You may
|
|
// disable it by passing a zero.
|
|
// @hash_table_ratio: the desired utilization of the hash table used for prefix
|
|
// hashing. hash_table_ratio = number of prefixes / #buckets
|
|
// in the hash table
|
|
const uint32_t kPlainTableVariableLength = 0;
|
|
extern TableFactory* NewPlainTableFactory(
|
|
uint32_t user_key_len = kPlainTableVariableLength,
|
|
int bloom_bits_per_key = 10, double hash_table_ratio = 0.75);
|
|
|
|
} // namespace rocksdb
|