Skip to content

Commit

Permalink
Adapt rocksdb 6.23.3 (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Oct 14, 2021
1 parent 01b66fd commit 42b053f
Show file tree
Hide file tree
Showing 25 changed files with 468 additions and 47 deletions.
2 changes: 1 addition & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DZSTD_ZLIB_SUPPORT=ON -DZSTD_LZMA_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc) install && \
cd $BUILD_PATH && rm -rf * && ldconfig

rocksdb_version="6.22.1"
rocksdb_version="6.23.3"
cd $BUILD_PATH && wget https://github.com/facebook/rocksdb/archive/v${rocksdb_version}.tar.gz && tar xzf v${rocksdb_version}.tar.gz && cd rocksdb-${rocksdb_version}/ && \
mkdir -p build_place && cd build_place && cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_REQUIRED_PARAMS -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX -DWITH_TESTS=OFF -DWITH_GFLAGS=OFF \
-DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=OFF -DROCKSDB_BUILD_SHARED=OFF -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON \
Expand Down
7 changes: 4 additions & 3 deletions dist/linux_amd64/include/rocksdb/advanced_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,10 @@ struct CompressionOptions {
parallel_threads(1),
enabled(false),
max_dict_buffer_bytes(0) {}
CompressionOptions(int wbits, int _lev, int _strategy, int _max_dict_bytes,
int _zstd_max_train_bytes, int _parallel_threads,
bool _enabled, uint64_t _max_dict_buffer_bytes)
CompressionOptions(int wbits, int _lev, int _strategy,
uint32_t _max_dict_bytes, uint32_t _zstd_max_train_bytes,
uint32_t _parallel_threads, bool _enabled,
uint64_t _max_dict_buffer_bytes)
: window_bits(wbits),
level(_lev),
strategy(_strategy),
Expand Down
2 changes: 2 additions & 0 deletions dist/linux_amd64/include/rocksdb/c.h
Original file line number Diff line number Diff line change
Expand Up @@ -1602,6 +1602,8 @@ extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t*
rocksdb_filterpolicy_create_bloom(int bits_per_key);
extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t*
rocksdb_filterpolicy_create_bloom_full(int bits_per_key);
extern ROCKSDB_LIBRARY_API rocksdb_filterpolicy_t*
rocksdb_filterpolicy_create_ribbon(int bloom_equivalent_bits_per_key);

/* Merge Operator */

Expand Down
7 changes: 6 additions & 1 deletion dist/linux_amd64/include/rocksdb/comparator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#include <string>

#include "rocksdb/customizable.h"
#include "rocksdb/rocksdb_namespace.h"

namespace ROCKSDB_NAMESPACE {
Expand All @@ -20,7 +21,7 @@ class Slice;
// used as keys in an sstable or a database. A Comparator implementation
// must be thread-safe since rocksdb may invoke its methods concurrently
// from multiple threads.
class Comparator {
class Comparator : public Customizable {
public:
Comparator() : timestamp_size_(0) {}

Expand All @@ -37,7 +38,11 @@ class Comparator {

virtual ~Comparator() {}

static Status CreateFromString(const ConfigOptions& opts,
const std::string& id,
const Comparator** comp);
static const char* Type() { return "Comparator"; }

// Three-way comparison. Returns value:
// < 0 iff "a" < "b",
// == 0 iff "a" == "b",
Expand Down
7 changes: 4 additions & 3 deletions dist/linux_amd64/include/rocksdb/configurable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

#pragma once

#include <atomic>
#include <string>
#include <unordered_map>
#include <unordered_set>
Expand Down Expand Up @@ -55,7 +56,7 @@ class Configurable {
};

public:
Configurable() : prepared_(false) {}
Configurable();
virtual ~Configurable() {}

// Returns the raw pointer of the named options that is used by this
Expand Down Expand Up @@ -264,12 +265,12 @@ class Configurable {
// Returns true if this object has been initialized via PrepareOptions, false
// otherwise. Once an object has been prepared, only mutable options may be
// changed.
virtual bool IsPrepared() const { return prepared_; }
virtual bool IsPrepared() const { return is_prepared_; }

protected:
// True once the object is prepared. Once the object is prepared, only
// mutable options can be configured.
bool prepared_;
std::atomic<bool> is_prepared_;

// Returns the raw pointer for the associated named option.
// The name is typically the name of an option registered via the
Expand Down
34 changes: 34 additions & 0 deletions dist/linux_amd64/include/rocksdb/customizable.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,40 @@ class Customizable : public Configurable {
Status GetOption(const ConfigOptions& config_options, const std::string& name,
std::string* value) const override;
#endif // ROCKSDB_LITE
// Helper method for getting for parsing the opt_value into the corresponding
// options for use in potentially creating a new Customizable object (this
// method is primarily a support method for LoadSharedObject et al for new
// Customizable objects). The opt_value may be either name-value pairs
// separated by ";" (a=b; c=d), or a simple name (a). In order to create a new
// Customizable, the ID is determined by:
// - If the value is a simple name (e.g. "BlockBasedTable"), the id is this
// name;
// - Otherwise, if there is a "id=value", the id is set to "value"
// - Otherwise, if the input customizable is not null, custom->GetId is used
// - Otherwise, an error is returned.
//
// If the opt_value is name-value pairs, these pairs will be returned in
// options (without the id pair). If the ID being returned matches the ID of
// the input custom object, then the options from the input object will also
// be added to the returned options.
//
// This method returns non-OK if the ID could not be found, or if the
// opt_value could not be parsed into name-value pairs.
static Status GetOptionsMap(
const ConfigOptions& config_options, const Customizable* custom,
const std::string& opt_value, std::string* id,
std::unordered_map<std::string, std::string>* options);

// Helper method to configure a new object with the supplied options.
// If the object is not null and invoke_prepare_options=true, the object
// will be configured and prepared.
// Returns success if the object is properly configured and (optionally)
// prepared Returns InvalidArgument if the object is nullptr and there are
// options in the map Returns the result of the ConfigureFromMap or
// PrepareOptions
static Status ConfigureNewObject(
const ConfigOptions& config_options, Customizable* object,
const std::unordered_map<std::string, std::string>& options);

// Returns the inner class when a Customizable implements a has-a (wrapped)
// relationship. Derived classes that implement a has-a must override this
Expand Down
6 changes: 6 additions & 0 deletions dist/linux_amd64/include/rocksdb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -1423,6 +1423,12 @@ class DB {
GetColumnFamilyMetaData(DefaultColumnFamily(), metadata);
}

// Obtains the meta data of all column families for the DB.
// The returned map contains one entry for each column family indexed by the
// name of the column family.
virtual void GetAllColumnFamilyMetaData(
std::vector<ColumnFamilyMetaData>* /*metadata*/) {}

// IngestExternalFile() will load a list of external SST files (1) into the DB
// Two primary modes are supported:
// - Duplicate keys in the new files will overwrite exiting keys (default)
Expand Down
23 changes: 9 additions & 14 deletions dist/linux_amd64/include/rocksdb/env_encryption.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

#include <string>

#include "rocksdb/customizable.h"
#include "rocksdb/env.h"
#include "rocksdb/file_system.h"
#include "rocksdb/rocksdb_namespace.h"
Expand Down Expand Up @@ -58,7 +59,7 @@ class BlockAccessCipherStream {
};

// BlockCipher
class BlockCipher {
class BlockCipher : public Customizable {
public:
virtual ~BlockCipher(){};

Expand All @@ -80,12 +81,12 @@ class BlockCipher {
const std::string& value,
std::shared_ptr<BlockCipher>* result);

static const char* Type() { return "BlockCipher"; }
// Short-cut method to create a ROT13 BlockCipher.
// This cipher is only suitable for test purposes and should not be used in
// production!!!
static std::shared_ptr<BlockCipher> NewROT13Cipher(size_t block_size);

virtual const char* Name() const = 0;
// BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() = 0;

Expand All @@ -101,22 +102,22 @@ class BlockCipher {
// The encryption provider is used to create a cipher stream for a specific
// file. The returned cipher stream will be used for actual
// encryption/decryption actions.
class EncryptionProvider {
class EncryptionProvider : public Customizable {
public:
virtual ~EncryptionProvider(){};

// Creates a new EncryptionProvider from the input config_options and value
// The value describes the type of provider (and potentially optional
// configuration parameters) used to create this provider.
// For example, if the value is "CTR", a CTREncryptionProvider will be
// created. If the value is preceded by "test://" (e.g test://CTR"), the
// TEST_Initialize method will be invoked prior to returning the provider.
// created. If the value is ends with "://test" (e.g CTR://test"), the
// provider will be initialized in "TEST" mode prior to being returned.
//
// @param config_options Options to control how this provider is created
// and initialized.
// @param value The value might be:
// - CTR Create a CTR provider
// - test://CTR Create a CTR provider and initialize it for tests.
// - CTR://test Create a CTR provider and initialize it for tests.
// @param result The new provider object
// @return OK if the provider was successfully created
// @return NotFound if an invalid name was specified in the value
Expand All @@ -125,13 +126,12 @@ class EncryptionProvider {
const std::string& value,
std::shared_ptr<EncryptionProvider>* result);

static const char* Type() { return "EncryptionProvider"; }

// Short-cut method to create a CTR-provider
static std::shared_ptr<EncryptionProvider> NewCTRProvider(
const std::shared_ptr<BlockCipher>& cipher);

// Returns the name of this EncryptionProvider
virtual const char* Name() const = 0;

// GetPrefixLength returns the length of the prefix that is added to every
// file and used for storing encryption options. For optimal performance, the
// prefix length should be a multiple of the page size.
Expand Down Expand Up @@ -165,11 +165,6 @@ class EncryptionProvider {
// or not a file is encrypted by this provider. The maker will also be part
// of any encryption prefix for this provider.
virtual std::string GetMarker() const { return ""; }

protected:
// Optional method to initialize an EncryptionProvider in the TEST
// environment.
virtual Status TEST_Initialize() { return Status::OK(); }
};

class EncryptedSequentialFile : public FSSequentialFile {
Expand Down
20 changes: 15 additions & 5 deletions dist/linux_amd64/include/rocksdb/flush_block_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,15 @@
#pragma once

#include <string>

#include "rocksdb/customizable.h"
#include "rocksdb/table.h"

namespace ROCKSDB_NAMESPACE {

class Slice;
class BlockBuilder;
struct ConfigOptions;
struct Options;

// FlushBlockPolicy provides a configurable way to determine when to flush a
Expand All @@ -25,10 +28,16 @@ class FlushBlockPolicy {
virtual ~FlushBlockPolicy() {}
};

class FlushBlockPolicyFactory {
class FlushBlockPolicyFactory : public Customizable {
public:
// Return the name of the flush block policy.
virtual const char* Name() const = 0;
static const char* Type() { return "FlushBlockPolicyFactory"; }

// Creates a FlushBlockPolicyFactory based on the input value.
// By default, this method can create EveryKey or BySize PolicyFactory,
// which take now config_options.
static Status CreateFromString(
const ConfigOptions& config_options, const std::string& value,
std::shared_ptr<FlushBlockPolicyFactory>* result);

// Return a new block flush policy that flushes data blocks by data size.
// FlushBlockPolicy may need to access the metadata of the data block
Expand All @@ -45,9 +54,10 @@ class FlushBlockPolicyFactory {

class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory {
public:
FlushBlockBySizePolicyFactory() {}
FlushBlockBySizePolicyFactory();

const char* Name() const override { return "FlushBlockBySizePolicyFactory"; }
static const char* kClassName() { return "FlushBlockBySizePolicyFactory"; }
const char* Name() const override { return kClassName(); }

FlushBlockPolicy* NewFlushBlockPolicy(
const BlockBasedTableOptions& table_options,
Expand Down
46 changes: 46 additions & 0 deletions dist/linux_amd64/include/rocksdb/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "rocksdb/types.h"

namespace ROCKSDB_NAMESPACE {
struct BlobMetaData;
struct ColumnFamilyMetaData;
struct LevelMetaData;
struct SstFileMetaData;
Expand All @@ -35,6 +36,13 @@ struct ColumnFamilyMetaData {
std::string name;
// The metadata of all levels in this column family.
std::vector<LevelMetaData> levels;

// The total size of all blob files
uint64_t blob_file_size = 0;
// The number of blob files in this column family.
size_t blob_file_count = 0;
// The metadata of the blobs in this column family
std::vector<BlobMetaData> blob_files;
};

// The metadata that describes a level.
Expand Down Expand Up @@ -153,6 +161,44 @@ struct LiveFileMetaData : SstFileMetaData {
LiveFileMetaData() : column_family_name(), level(0) {}
};

// The MetaData that describes a Blob file
struct BlobMetaData {
BlobMetaData()
: blob_file_number(0),
blob_file_size(0),
total_blob_count(0),
total_blob_bytes(0),
garbage_blob_count(0),
garbage_blob_bytes(0) {}

BlobMetaData(uint64_t _file_number, const std::string& _file_name,
const std::string& _file_path, uint64_t _file_size,
uint64_t _total_blob_count, uint64_t _total_blob_bytes,
uint64_t _garbage_blob_count, uint64_t _garbage_blob_bytes,
const std::string& _file_checksum,
const std::string& _file_checksum_func_name)
: blob_file_number(_file_number),
blob_file_name(_file_name),
blob_file_path(_file_path),
blob_file_size(_file_size),
total_blob_count(_total_blob_count),
total_blob_bytes(_total_blob_bytes),
garbage_blob_count(_garbage_blob_count),
garbage_blob_bytes(_garbage_blob_bytes),
checksum_method(_file_checksum),
checksum_value(_file_checksum_func_name) {}
uint64_t blob_file_number;
std::string blob_file_name;
std::string blob_file_path;
uint64_t blob_file_size;
uint64_t total_blob_count;
uint64_t total_blob_bytes;
uint64_t garbage_blob_count;
uint64_t garbage_blob_bytes;
std::string checksum_method;
std::string checksum_value;
};

// Metadata returned as output from ExportColumnFamily() and used as input to
// CreateColumnFamiliesWithImport().
struct ExportImportFilesMetaData {
Expand Down
Loading

0 comments on commit 42b053f

Please sign in to comment.