Run automatic formatter against public header files (#5115)

Summary:
Automatically format public headers so it looks more consistent.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/5115

Differential Revision: D14632854

Pulled By: siying

fbshipit-source-id: ce9929ea62f9dcd65c69660b23eed1931cb0ae84
main
Siying Dong 6 years ago committed by Facebook Github Bot
parent 5f6adf3f6a
commit 1f7f5a5a79
  1. 2
      include/rocksdb/compaction_filter.h
  2. 5
      include/rocksdb/comparator.h
  3. 5
      include/rocksdb/concurrent_task_limiter.h
  4. 24
      include/rocksdb/convenience.h
  5. 55
      include/rocksdb/db.h
  6. 111
      include/rocksdb/env.h
  7. 284
      include/rocksdb/env_encryption.h
  8. 14
      include/rocksdb/filter_policy.h
  9. 9
      include/rocksdb/flush_block_policy.h
  10. 2
      include/rocksdb/ldb_tool.h
  11. 14
      include/rocksdb/listener.h
  12. 23
      include/rocksdb/memtablerep.h
  13. 7
      include/rocksdb/merge_operator.h
  14. 17
      include/rocksdb/metadata.h
  15. 24
      include/rocksdb/options.h
  16. 39
      include/rocksdb/perf_context.h
  17. 36
      include/rocksdb/slice.h
  18. 4
      include/rocksdb/slice_transform.h
  19. 5
      include/rocksdb/sst_file_writer.h
  20. 4
      include/rocksdb/statistics.h
  21. 5
      include/rocksdb/status.h
  22. 20
      include/rocksdb/table.h
  23. 46
      include/rocksdb/thread_status.h
  24. 1
      include/rocksdb/threadpool.h
  25. 11
      include/rocksdb/transaction_log.h
  26. 6
      include/rocksdb/types.h
  27. 5
      include/rocksdb/universal_compaction.h
  28. 7
      include/rocksdb/utilities/backupable_db.h
  29. 6
      include/rocksdb/utilities/db_ttl.h
  30. 2
      include/rocksdb/utilities/env_librados.h
  31. 22
      include/rocksdb/utilities/env_mirror.h
  32. 40
      include/rocksdb/utilities/ldb_cmd_execute_result.h
  33. 3
      include/rocksdb/utilities/sim_cache.h
  34. 58
      include/rocksdb/utilities/stackable_db.h
  35. 19
      include/rocksdb/utilities/table_properties_collectors.h
  36. 1
      include/rocksdb/utilities/transaction_db.h
  37. 18
      include/rocksdb/utilities/utility_db.h
  38. 8
      include/rocksdb/wal_filter.h
  39. 2
      include/rocksdb/write_batch.h

@ -189,7 +189,7 @@ class CompactionFilter {
// application to know about different compactions // application to know about different compactions
class CompactionFilterFactory { class CompactionFilterFactory {
public: public:
virtual ~CompactionFilterFactory() { } virtual ~CompactionFilterFactory() {}
virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter( virtual std::unique_ptr<CompactionFilter> CreateCompactionFilter(
const CompactionFilter::Context& context) = 0; const CompactionFilter::Context& context) = 0;

@ -55,9 +55,8 @@ class Comparator {
// If *start < limit, changes *start to a short string in [start,limit). // If *start < limit, changes *start to a short string in [start,limit).
// Simple comparator implementations may return with *start unchanged, // Simple comparator implementations may return with *start unchanged,
// i.e., an implementation of this method that does nothing is correct. // i.e., an implementation of this method that does nothing is correct.
virtual void FindShortestSeparator( virtual void FindShortestSeparator(std::string* start,
std::string* start, const Slice& limit) const = 0;
const Slice& limit) const = 0;
// Changes *key to a short string >= *key. // Changes *key to a short string >= *key.
// Simple comparator implementations may return with *key unchanged, // Simple comparator implementations may return with *key unchanged,

@ -16,7 +16,6 @@ namespace rocksdb {
class ConcurrentTaskLimiter { class ConcurrentTaskLimiter {
public: public:
virtual ~ConcurrentTaskLimiter() {} virtual ~ConcurrentTaskLimiter() {}
// Returns a name that identifies this concurrent task limiter. // Returns a name that identifies this concurrent task limiter.
@ -41,7 +40,7 @@ class ConcurrentTaskLimiter {
// @param limit: max concurrent tasks. // @param limit: max concurrent tasks.
// limit = 0 means no new task allowed. // limit = 0 means no new task allowed.
// limit < 0 means no limitation. // limit < 0 means no limitation.
extern ConcurrentTaskLimiter* NewConcurrentTaskLimiter( extern ConcurrentTaskLimiter* NewConcurrentTaskLimiter(const std::string& name,
const std::string& name, int32_t limit); int32_t limit);
} // namespace rocksdb } // namespace rocksdb

@ -277,15 +277,13 @@ Status GetPlainTableOptionsFromMap(
// BlockBasedTableOptions as part of the string for block-based table factory: // BlockBasedTableOptions as part of the string for block-based table factory:
// "write_buffer_size=1024;block_based_table_factory={block_size=4k};" // "write_buffer_size=1024;block_based_table_factory={block_size=4k};"
// "max_write_buffer_num=2" // "max_write_buffer_num=2"
Status GetColumnFamilyOptionsFromString( Status GetColumnFamilyOptionsFromString(const ColumnFamilyOptions& base_options,
const ColumnFamilyOptions& base_options, const std::string& opts_str,
const std::string& opts_str, ColumnFamilyOptions* new_options);
ColumnFamilyOptions* new_options);
Status GetDBOptionsFromString( Status GetDBOptionsFromString(const DBOptions& base_options,
const DBOptions& base_options, const std::string& opts_str,
const std::string& opts_str, DBOptions* new_options);
DBOptions* new_options);
Status GetStringFromDBOptions(std::string* opts_str, Status GetStringFromDBOptions(std::string* opts_str,
const DBOptions& db_options, const DBOptions& db_options,
@ -301,14 +299,12 @@ Status GetStringFromCompressionType(std::string* compression_str,
std::vector<CompressionType> GetSupportedCompressions(); std::vector<CompressionType> GetSupportedCompressions();
Status GetBlockBasedTableOptionsFromString( Status GetBlockBasedTableOptionsFromString(
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options, const std::string& opts_str,
const std::string& opts_str,
BlockBasedTableOptions* new_table_options); BlockBasedTableOptions* new_table_options);
Status GetPlainTableOptionsFromString( Status GetPlainTableOptionsFromString(const PlainTableOptions& table_options,
const PlainTableOptions& table_options, const std::string& opts_str,
const std::string& opts_str, PlainTableOptions* new_table_options);
PlainTableOptions* new_table_options);
Status GetMemTableRepFactoryFromString( Status GetMemTableRepFactoryFromString(
const std::string& opts_str, const std::string& opts_str,

@ -97,16 +97,16 @@ struct Range {
Slice start; Slice start;
Slice limit; Slice limit;
Range() { } Range() {}
Range(const Slice& s, const Slice& l) : start(s), limit(l) { } Range(const Slice& s, const Slice& l) : start(s), limit(l) {}
}; };
struct RangePtr { struct RangePtr {
const Slice* start; const Slice* start;
const Slice* limit; const Slice* limit;
RangePtr() : start(nullptr), limit(nullptr) { } RangePtr() : start(nullptr), limit(nullptr) {}
RangePtr(const Slice* s, const Slice* l) : start(s), limit(l) { } RangePtr(const Slice* s, const Slice* l) : start(s), limit(l) {}
}; };
struct IngestExternalFileArg { struct IngestExternalFileArg {
@ -131,8 +131,7 @@ class DB {
// OK on success. // OK on success.
// Stores nullptr in *dbptr and returns a non-OK status on error. // Stores nullptr in *dbptr and returns a non-OK status on error.
// Caller should delete *dbptr when it is no longer needed. // Caller should delete *dbptr when it is no longer needed.
static Status Open(const Options& options, static Status Open(const Options& options, const std::string& name,
const std::string& name,
DB** dbptr); DB** dbptr);
// Open the database for read only. All DB interfaces // Open the database for read only. All DB interfaces
@ -142,9 +141,9 @@ class DB {
// //
// Not supported in ROCKSDB_LITE, in which case the function will // Not supported in ROCKSDB_LITE, in which case the function will
// return Status::NotSupported. // return Status::NotSupported.
static Status OpenForReadOnly(const Options& options, static Status OpenForReadOnly(const Options& options, const std::string& name,
const std::string& name, DB** dbptr, DB** dbptr,
bool error_if_log_file_exist = false); bool error_if_log_file_exist = false);
// Open the database for read only with column families. When opening DB with // Open the database for read only with column families. When opening DB with
// read only, you can specify only a subset of column families in the // read only, you can specify only a subset of column families in the
@ -246,7 +245,7 @@ class DB {
const std::string& name, const std::string& name,
std::vector<std::string>* column_families); std::vector<std::string>* column_families);
DB() { } DB() {}
virtual ~DB(); virtual ~DB();
// Create a column_family and return the handle of column family // Create a column_family and return the handle of column family
@ -394,7 +393,8 @@ class DB {
virtual Status Get(const ReadOptions& options, virtual Status Get(const ReadOptions& options,
ColumnFamilyHandle* column_family, const Slice& key, ColumnFamilyHandle* column_family, const Slice& key,
PinnableSlice* value) = 0; PinnableSlice* value) = 0;
virtual Status Get(const ReadOptions& options, const Slice& key, std::string* value) { virtual Status Get(const ReadOptions& options, const Slice& key,
std::string* value) {
return Get(options, DefaultColumnFamily(), key, value); return Get(options, DefaultColumnFamily(), key, value);
} }
@ -415,9 +415,10 @@ class DB {
virtual std::vector<Status> MultiGet(const ReadOptions& options, virtual std::vector<Status> MultiGet(const ReadOptions& options,
const std::vector<Slice>& keys, const std::vector<Slice>& keys,
std::vector<std::string>* values) { std::vector<std::string>* values) {
return MultiGet(options, std::vector<ColumnFamilyHandle*>( return MultiGet(
keys.size(), DefaultColumnFamily()), options,
keys, values); std::vector<ColumnFamilyHandle*>(keys.size(), DefaultColumnFamily()),
keys, values);
} }
// If the key definitely does not exist in the database, then this method // If the key definitely does not exist in the database, then this method
@ -779,13 +780,10 @@ class DB {
// include_flags should be of type DB::SizeApproximationFlags // include_flags should be of type DB::SizeApproximationFlags
virtual void GetApproximateSizes(ColumnFamilyHandle* column_family, virtual void GetApproximateSizes(ColumnFamilyHandle* column_family,
const Range* range, int n, uint64_t* sizes, const Range* range, int n, uint64_t* sizes,
uint8_t include_flags uint8_t include_flags = INCLUDE_FILES) = 0;
= INCLUDE_FILES) = 0;
virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes, virtual void GetApproximateSizes(const Range* range, int n, uint64_t* sizes,
uint8_t include_flags uint8_t include_flags = INCLUDE_FILES) {
= INCLUDE_FILES) { GetApproximateSizes(DefaultColumnFamily(), range, n, sizes, include_flags);
GetApproximateSizes(DefaultColumnFamily(), range, n, sizes,
include_flags);
} }
// The method is similar to GetApproximateSizes, except it // The method is similar to GetApproximateSizes, except it
@ -802,8 +800,7 @@ class DB {
// Deprecated versions of GetApproximateSizes // Deprecated versions of GetApproximateSizes
ROCKSDB_DEPRECATED_FUNC virtual void GetApproximateSizes( ROCKSDB_DEPRECATED_FUNC virtual void GetApproximateSizes(
const Range* range, int n, uint64_t* sizes, const Range* range, int n, uint64_t* sizes, bool include_memtable) {
bool include_memtable) {
uint8_t include_flags = SizeApproximationFlags::INCLUDE_FILES; uint8_t include_flags = SizeApproximationFlags::INCLUDE_FILES;
if (include_memtable) { if (include_memtable) {
include_flags |= SizeApproximationFlags::INCLUDE_MEMTABLES; include_flags |= SizeApproximationFlags::INCLUDE_MEMTABLES;
@ -811,9 +808,8 @@ class DB {
GetApproximateSizes(DefaultColumnFamily(), range, n, sizes, include_flags); GetApproximateSizes(DefaultColumnFamily(), range, n, sizes, include_flags);
} }
ROCKSDB_DEPRECATED_FUNC virtual void GetApproximateSizes( ROCKSDB_DEPRECATED_FUNC virtual void GetApproximateSizes(
ColumnFamilyHandle* column_family, ColumnFamilyHandle* column_family, const Range* range, int n,
const Range* range, int n, uint64_t* sizes, uint64_t* sizes, bool include_memtable) {
bool include_memtable) {
uint8_t include_flags = SizeApproximationFlags::INCLUDE_FILES; uint8_t include_flags = SizeApproximationFlags::INCLUDE_FILES;
if (include_memtable) { if (include_memtable) {
include_flags |= SizeApproximationFlags::INCLUDE_MEMTABLES; include_flags |= SizeApproximationFlags::INCLUDE_MEMTABLES;
@ -1073,8 +1069,7 @@ class DB {
ColumnFamilyMetaData* /*metadata*/) {} ColumnFamilyMetaData* /*metadata*/) {}
// Get the metadata of the default column family. // Get the metadata of the default column family.
void GetColumnFamilyMetaData( void GetColumnFamilyMetaData(ColumnFamilyMetaData* metadata) {
ColumnFamilyMetaData* metadata) {
GetColumnFamilyMetaData(DefaultColumnFamily(), metadata); GetColumnFamilyMetaData(DefaultColumnFamily(), metadata);
} }
@ -1275,8 +1270,8 @@ class DB {
// Given a time window, return an iterator for accessing stats history // Given a time window, return an iterator for accessing stats history
// User is responsible for deleting StatsHistoryIterator after use // User is responsible for deleting StatsHistoryIterator after use
virtual Status GetStatsHistory(uint64_t /*start_time*/, virtual Status GetStatsHistory(
uint64_t /*end_time*/, uint64_t /*start_time*/, uint64_t /*end_time*/,
std::unique_ptr<StatsHistoryIterator>* /*stats_iterator*/) { std::unique_ptr<StatsHistoryIterator>* /*stats_iterator*/) {
return Status::NotSupported("GetStatsHistory() is not implemented."); return Status::NotSupported("GetStatsHistory() is not implemented.");
} }
@ -1308,7 +1303,7 @@ class DB {
// Be very careful using this method. // Be very careful using this method.
Status DestroyDB(const std::string& name, const Options& options, Status DestroyDB(const std::string& name, const Options& options,
const std::vector<ColumnFamilyDescriptor>& column_families = const std::vector<ColumnFamilyDescriptor>& column_families =
std::vector<ColumnFamilyDescriptor>()); std::vector<ColumnFamilyDescriptor>());
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
// If a DB cannot be opened, you may attempt to call this method to // If a DB cannot be opened, you may attempt to call this method to

@ -54,17 +54,16 @@ const size_t kDefaultPageSize = 4 * 1024;
// Options while opening a file to read/write // Options while opening a file to read/write
struct EnvOptions { struct EnvOptions {
// Construct with default Options // Construct with default Options
EnvOptions(); EnvOptions();
// Construct from Options // Construct from Options
explicit EnvOptions(const DBOptions& options); explicit EnvOptions(const DBOptions& options);
// If true, then use mmap to read data // If true, then use mmap to read data
bool use_mmap_reads = false; bool use_mmap_reads = false;
// If true, then use mmap to write data // If true, then use mmap to write data
bool use_mmap_writes = true; bool use_mmap_writes = true;
// If true, then use O_DIRECT for reading data // If true, then use O_DIRECT for reading data
@ -150,12 +149,12 @@ class Env {
// These values match Linux definition // These values match Linux definition
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fcntl.h#n56 // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/fcntl.h#n56
enum WriteLifeTimeHint { enum WriteLifeTimeHint {
WLTH_NOT_SET = 0, // No hint information set WLTH_NOT_SET = 0, // No hint information set
WLTH_NONE, // No hints about write life time WLTH_NONE, // No hints about write life time
WLTH_SHORT, // Data written has a short life time WLTH_SHORT, // Data written has a short life time
WLTH_MEDIUM, // Data written has a medium life time WLTH_MEDIUM, // Data written has a medium life time
WLTH_LONG, // Data written has a long life time WLTH_LONG, // Data written has a long life time
WLTH_EXTREME, // Data written has an extremely long life time WLTH_EXTREME, // Data written has an extremely long life time
}; };
// Create an object that writes to a new file with the specified // Create an object that writes to a new file with the specified
@ -321,11 +320,7 @@ class Env {
static std::string PriorityToString(Priority priority); static std::string PriorityToString(Priority priority);
// Priority for requesting bytes in rate limiter scheduler // Priority for requesting bytes in rate limiter scheduler
enum IOPriority { enum IOPriority { IO_LOW = 0, IO_HIGH = 1, IO_TOTAL = 2 };
IO_LOW = 0,
IO_HIGH = 1,
IO_TOTAL = 2
};
// Arrange to run "(*function)(arg)" once in a background thread, in // Arrange to run "(*function)(arg)" once in a background thread, in
// the thread pool specified by pri. By default, jobs go to the 'LOW' // the thread pool specified by pri. By default, jobs go to the 'LOW'
@ -377,9 +372,7 @@ class Env {
// Default implementation simply relies on NowMicros. // Default implementation simply relies on NowMicros.
// In platform-specific implementations, NowNanos() should return time points // In platform-specific implementations, NowNanos() should return time points
// that are MONOTONIC. // that are MONOTONIC.
virtual uint64_t NowNanos() { virtual uint64_t NowNanos() { return NowMicros() * 1000; }
return NowMicros() * 1000;
}
// 0 indicates not supported. // 0 indicates not supported.
virtual uint64_t NowCPUNanos() { return 0; } virtual uint64_t NowCPUNanos() { return 0; }
@ -396,7 +389,7 @@ class Env {
// Get full directory name for this db. // Get full directory name for this db.
virtual Status GetAbsolutePath(const std::string& db_path, virtual Status GetAbsolutePath(const std::string& db_path,
std::string* output_path) = 0; std::string* output_path) = 0;
// The number of background worker threads of a specific thread pool // The number of background worker threads of a specific thread pool
// for this environment. 'LOW' is the default pool. // for this environment. 'LOW' is the default pool.
@ -503,7 +496,7 @@ ThreadStatusUpdater* CreateThreadStatusUpdater();
// A file abstraction for reading sequentially through a file // A file abstraction for reading sequentially through a file
class SequentialFile { class SequentialFile {
public: public:
SequentialFile() { } SequentialFile() {}
virtual ~SequentialFile(); virtual ~SequentialFile();
// Read up to "n" bytes from the file. "scratch[0..n-1]" may be // Read up to "n" bytes from the file. "scratch[0..n-1]" may be
@ -551,8 +544,7 @@ class SequentialFile {
// A file abstraction for randomly reading the contents of a file. // A file abstraction for randomly reading the contents of a file.
class RandomAccessFile { class RandomAccessFile {
public: public:
RandomAccessFile() {}
RandomAccessFile() { }
virtual ~RandomAccessFile(); virtual ~RandomAccessFile();
// Read up to "n" bytes from the file starting at "offset". // Read up to "n" bytes from the file starting at "offset".
@ -589,8 +581,8 @@ class RandomAccessFile {
// //
// Note: these IDs are only valid for the duration of the process. // Note: these IDs are only valid for the duration of the process.
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0; // Default implementation to prevent issues with backwards return 0; // Default implementation to prevent issues with backwards
// compatibility. // compatibility.
}; };
enum AccessPattern { NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED }; enum AccessPattern { NORMAL, RANDOM, SEQUENTIAL, WILLNEED, DONTNEED };
@ -619,11 +611,10 @@ class RandomAccessFile {
class WritableFile { class WritableFile {
public: public:
WritableFile() WritableFile()
: last_preallocated_block_(0), : last_preallocated_block_(0),
preallocation_block_size_(0), preallocation_block_size_(0),
io_priority_(Env::IO_TOTAL), io_priority_(Env::IO_TOTAL),
write_hint_(Env::WLTH_NOT_SET) { write_hint_(Env::WLTH_NOT_SET) {}
}
virtual ~WritableFile(); virtual ~WritableFile();
// Append data to the end of the file // Append data to the end of the file
@ -651,7 +642,8 @@ class WritableFile {
// //
// PositionedAppend() requires aligned buffer to be passed in. The alignment // PositionedAppend() requires aligned buffer to be passed in. The alignment
// required is queried via GetRequiredBufferAlignment() // required is queried via GetRequiredBufferAlignment()
virtual Status PositionedAppend(const Slice& /* data */, uint64_t /* offset */) { virtual Status PositionedAppend(const Slice& /* data */,
uint64_t /* offset */) {
return Status::NotSupported(); return Status::NotSupported();
} }
@ -662,7 +654,7 @@ class WritableFile {
virtual Status Truncate(uint64_t /*size*/) { return Status::OK(); } virtual Status Truncate(uint64_t /*size*/) { return Status::OK(); }
virtual Status Close() = 0; virtual Status Close() = 0;
virtual Status Flush() = 0; virtual Status Flush() = 0;
virtual Status Sync() = 0; // sync data virtual Status Sync() = 0; // sync data
/* /*
* Sync data and/or metadata as well. * Sync data and/or metadata as well.
@ -670,15 +662,11 @@ class WritableFile {
* Override this method for environments where we need to sync * Override this method for environments where we need to sync
* metadata as well. * metadata as well.
*/ */
virtual Status Fsync() { virtual Status Fsync() { return Sync(); }
return Sync();
}
// true if Sync() and Fsync() are safe to call concurrently with Append() // true if Sync() and Fsync() are safe to call concurrently with Append()
// and Flush(). // and Flush().
virtual bool IsSyncThreadSafe() const { virtual bool IsSyncThreadSafe() const { return false; }
return false;
}
// Indicates the upper layers if the current WritableFile implementation // Indicates the upper layers if the current WritableFile implementation
// uses direct IO. // uses direct IO.
@ -691,9 +679,7 @@ class WritableFile {
* Change the priority in rate limiter if rate limiting is enabled. * Change the priority in rate limiter if rate limiting is enabled.
* If rate limiting is not enabled, this call has no effect. * If rate limiting is not enabled, this call has no effect.
*/ */
virtual void SetIOPriority(Env::IOPriority pri) { virtual void SetIOPriority(Env::IOPriority pri) { io_priority_ = pri; }
io_priority_ = pri;
}
virtual Env::IOPriority GetIOPriority() { return io_priority_; } virtual Env::IOPriority GetIOPriority() { return io_priority_; }
@ -705,9 +691,7 @@ class WritableFile {
/* /*
* Get the size of valid data in the file. * Get the size of valid data in the file.
*/ */
virtual uint64_t GetFileSize() { virtual uint64_t GetFileSize() { return 0; }
return 0;
}
/* /*
* Get and set the default pre-allocation block size for writes to * Get and set the default pre-allocation block size for writes to
@ -727,7 +711,7 @@ class WritableFile {
// For documentation, refer to RandomAccessFile::GetUniqueId() // For documentation, refer to RandomAccessFile::GetUniqueId()
virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const { virtual size_t GetUniqueId(char* /*id*/, size_t /*max_size*/) const {
return 0; // Default implementation to prevent issues with backwards return 0; // Default implementation to prevent issues with backwards
} }
// Remove any kind of caching of data from the offset to offset+length // Remove any kind of caching of data from the offset to offset+length
@ -762,10 +746,10 @@ class WritableFile {
// cover this write would be and Allocate to that point. // cover this write would be and Allocate to that point.
const auto block_size = preallocation_block_size_; const auto block_size = preallocation_block_size_;
size_t new_last_preallocated_block = size_t new_last_preallocated_block =
(offset + len + block_size - 1) / block_size; (offset + len + block_size - 1) / block_size;
if (new_last_preallocated_block > last_preallocated_block_) { if (new_last_preallocated_block > last_preallocated_block_) {
size_t num_spanned_blocks = size_t num_spanned_blocks =
new_last_preallocated_block - last_preallocated_block_; new_last_preallocated_block - last_preallocated_block_;
Allocate(block_size * last_preallocated_block_, Allocate(block_size * last_preallocated_block_,
block_size * num_spanned_blocks); block_size * num_spanned_blocks);
last_preallocated_block_ = new_last_preallocated_block; last_preallocated_block_ = new_last_preallocated_block;
@ -835,7 +819,7 @@ class RandomRWFile {
// MemoryMappedFileBuffer object represents a memory-mapped file's raw buffer. // MemoryMappedFileBuffer object represents a memory-mapped file's raw buffer.
// Subclasses should release the mapping upon destruction. // Subclasses should release the mapping upon destruction.
class MemoryMappedFileBuffer { class MemoryMappedFileBuffer {
public: public:
MemoryMappedFileBuffer(void* _base, size_t _length) MemoryMappedFileBuffer(void* _base, size_t _length)
: base_(_base), length_(_length) {} : base_(_base), length_(_length) {}
@ -846,11 +830,11 @@ public:
MemoryMappedFileBuffer(const MemoryMappedFileBuffer&) = delete; MemoryMappedFileBuffer(const MemoryMappedFileBuffer&) = delete;
MemoryMappedFileBuffer& operator=(const MemoryMappedFileBuffer&) = delete; MemoryMappedFileBuffer& operator=(const MemoryMappedFileBuffer&) = delete;
void* GetBase() const { return base_; } void* GetBase() const { return base_; }
size_t GetLen() const { return length_; } size_t GetLen() const { return length_; }
protected: protected:
void* base_; void* base_;
const size_t length_; const size_t length_;
}; };
@ -907,7 +891,8 @@ class Logger {
// and format. Any log with level under the internal log level // and format. Any log with level under the internal log level
// of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be // of *this (see @SetInfoLogLevel and @GetInfoLogLevel) will not be
// printed. // printed.
virtual void Logv(const InfoLogLevel log_level, const char* format, va_list ap); virtual void Logv(const InfoLogLevel log_level, const char* format,
va_list ap);
virtual size_t GetLogFileSize() const { return kDoNotSupportGetLogFileSize; } virtual size_t GetLogFileSize() const { return kDoNotSupportGetLogFileSize; }
// Flush to the OS buffers // Flush to the OS buffers
@ -928,12 +913,12 @@ class Logger {
InfoLogLevel log_level_; InfoLogLevel log_level_;
}; };
// Identifies a locked file. // Identifies a locked file.
class FileLock { class FileLock {
public: public:
FileLock() { } FileLock() {}
virtual ~FileLock(); virtual ~FileLock();
private: private:
// No copying allowed // No copying allowed
FileLock(const FileLock&); FileLock(const FileLock&);
@ -964,21 +949,21 @@ extern void Fatal(const std::shared_ptr<Logger>& info_log, const char* format,
// The default info log level is InfoLogLevel::INFO_LEVEL. // The default info log level is InfoLogLevel::INFO_LEVEL.
extern void Log(const std::shared_ptr<Logger>& info_log, const char* format, extern void Log(const std::shared_ptr<Logger>& info_log, const char* format,
...) ...)
# if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
__attribute__((__format__(__printf__, 2, 3))) __attribute__((__format__(__printf__, 2, 3)))
# endif #endif
; ;
extern void LogFlush(Logger *info_log); extern void LogFlush(Logger* info_log);
extern void Log(const InfoLogLevel log_level, Logger* info_log, extern void Log(const InfoLogLevel log_level, Logger* info_log,
const char* format, ...); const char* format, ...);
// The default info log level is InfoLogLevel::INFO_LEVEL. // The default info log level is InfoLogLevel::INFO_LEVEL.
extern void Log(Logger* info_log, const char* format, ...) extern void Log(Logger* info_log, const char* format, ...)
# if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
__attribute__((__format__ (__printf__, 2, 3))) __attribute__((__format__(__printf__, 2, 3)))
# endif #endif
; ;
// a set of log functions with different log levels. // a set of log functions with different log levels.
@ -1004,7 +989,7 @@ extern Status ReadFileToString(Env* env, const std::string& fname,
class EnvWrapper : public Env { class EnvWrapper : public Env {
public: public:
// Initialize an EnvWrapper that delegates all calls to *t // Initialize an EnvWrapper that delegates all calls to *t
explicit EnvWrapper(Env* t) : target_(t) { } explicit EnvWrapper(Env* t) : target_(t) {}
~EnvWrapper() override; ~EnvWrapper() override;
// Return the target to which this Env forwards all calls // Return the target to which this Env forwards all calls
@ -1174,9 +1159,7 @@ class EnvWrapper : public Env {
return target_->GetThreadStatusUpdater(); return target_->GetThreadStatusUpdater();
} }
uint64_t GetThreadID() const override { uint64_t GetThreadID() const override { return target_->GetThreadID(); }
return target_->GetThreadID();
}
std::string GenerateUniqueId() override { std::string GenerateUniqueId() override {
return target_->GenerateUniqueId(); return target_->GenerateUniqueId();
@ -1219,7 +1202,7 @@ class EnvWrapper : public Env {
// protected virtual methods. // protected virtual methods.
class WritableFileWrapper : public WritableFile { class WritableFileWrapper : public WritableFile {
public: public:
explicit WritableFileWrapper(WritableFile* t) : target_(t) { } explicit WritableFileWrapper(WritableFile* t) : target_(t) {}
Status Append(const Slice& data) override { return target_->Append(data); } Status Append(const Slice& data) override { return target_->Append(data); }
Status PositionedAppend(const Slice& data, uint64_t offset) override { Status PositionedAppend(const Slice& data, uint64_t offset) override {

@ -5,7 +5,7 @@
#pragma once #pragma once
#if !defined(ROCKSDB_LITE) #if !defined(ROCKSDB_LITE)
#include <string> #include <string>
@ -15,184 +15,190 @@ namespace rocksdb {
class EncryptionProvider; class EncryptionProvider;
// Returns an Env that encrypts data when stored on disk and decrypts data when // Returns an Env that encrypts data when stored on disk and decrypts data when
// read from disk. // read from disk.
Env* NewEncryptedEnv(Env* base_env, EncryptionProvider* provider); Env* NewEncryptedEnv(Env* base_env, EncryptionProvider* provider);
// BlockAccessCipherStream is the base class for any cipher stream that // BlockAccessCipherStream is the base class for any cipher stream that
// supports random access at block level (without requiring data from other blocks). // supports random access at block level (without requiring data from other
// E.g. CTR (Counter operation mode) supports this requirement. // blocks). E.g. CTR (Counter operation mode) supports this requirement.
class BlockAccessCipherStream { class BlockAccessCipherStream {
public: public:
virtual ~BlockAccessCipherStream() {}; virtual ~BlockAccessCipherStream(){};
// BlockSize returns the size of each block supported by this cipher stream. // BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() = 0; virtual size_t BlockSize() = 0;
// Encrypt one or more (partial) blocks of data at the file offset. // Encrypt one or more (partial) blocks of data at the file offset.
// Length of data is given in dataSize. // Length of data is given in dataSize.
virtual Status Encrypt(uint64_t fileOffset, char *data, size_t dataSize); virtual Status Encrypt(uint64_t fileOffset, char* data, size_t dataSize);
// Decrypt one or more (partial) blocks of data at the file offset. // Decrypt one or more (partial) blocks of data at the file offset.
// Length of data is given in dataSize. // Length of data is given in dataSize.
virtual Status Decrypt(uint64_t fileOffset, char *data, size_t dataSize); virtual Status Decrypt(uint64_t fileOffset, char* data, size_t dataSize);
protected: protected:
// Allocate scratch space which is passed to EncryptBlock/DecryptBlock. // Allocate scratch space which is passed to EncryptBlock/DecryptBlock.
virtual void AllocateScratch(std::string&) = 0; virtual void AllocateScratch(std::string&) = 0;
// Encrypt a block of data at the given block index. // Encrypt a block of data at the given block index.
// Length of data is equal to BlockSize(); // Length of data is equal to BlockSize();
virtual Status EncryptBlock(uint64_t blockIndex, char *data, char* scratch) = 0; virtual Status EncryptBlock(uint64_t blockIndex, char* data,
char* scratch) = 0;
// Decrypt a block of data at the given block index. // Decrypt a block of data at the given block index.
// Length of data is equal to BlockSize(); // Length of data is equal to BlockSize();
virtual Status DecryptBlock(uint64_t blockIndex, char *data, char* scratch) = 0; virtual Status DecryptBlock(uint64_t blockIndex, char* data,
char* scratch) = 0;
}; };
// BlockCipher // BlockCipher
class BlockCipher { class BlockCipher {
public: public:
virtual ~BlockCipher() {}; virtual ~BlockCipher(){};
// BlockSize returns the size of each block supported by this cipher stream. // BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() = 0; virtual size_t BlockSize() = 0;
// Encrypt a block of data. // Encrypt a block of data.
// Length of data is equal to BlockSize(). // Length of data is equal to BlockSize().
virtual Status Encrypt(char *data) = 0; virtual Status Encrypt(char* data) = 0;
// Decrypt a block of data. // Decrypt a block of data.
// Length of data is equal to BlockSize(). // Length of data is equal to BlockSize().
virtual Status Decrypt(char *data) = 0; virtual Status Decrypt(char* data) = 0;
}; };
// Implements a BlockCipher using ROT13. // Implements a BlockCipher using ROT13.
// //
// Note: This is a sample implementation of BlockCipher, // Note: This is a sample implementation of BlockCipher,
// it is NOT considered safe and should NOT be used in production. // it is NOT considered safe and should NOT be used in production.
class ROT13BlockCipher : public BlockCipher { class ROT13BlockCipher : public BlockCipher {
private: private:
size_t blockSize_; size_t blockSize_;
public:
ROT13BlockCipher(size_t blockSize) public:
: blockSize_(blockSize) {} ROT13BlockCipher(size_t blockSize) : blockSize_(blockSize) {}
virtual ~ROT13BlockCipher() {}; virtual ~ROT13BlockCipher(){};
// BlockSize returns the size of each block supported by this cipher stream. // BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() override { return blockSize_; } virtual size_t BlockSize() override { return blockSize_; }
// Encrypt a block of data. // Encrypt a block of data.
// Length of data is equal to BlockSize(). // Length of data is equal to BlockSize().
virtual Status Encrypt(char *data) override; virtual Status Encrypt(char* data) override;
// Decrypt a block of data. // Decrypt a block of data.
// Length of data is equal to BlockSize(). // Length of data is equal to BlockSize().
virtual Status Decrypt(char *data) override; virtual Status Decrypt(char* data) override;
}; };
// CTRCipherStream implements BlockAccessCipherStream using an // CTRCipherStream implements BlockAccessCipherStream using an
// Counter operations mode. // Counter operations mode.
// See https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation // See https://en.wikipedia.org/wiki/Block_cipher_mode_of_operation
// //
// Note: This is a possible implementation of BlockAccessCipherStream, // Note: This is a possible implementation of BlockAccessCipherStream,
// it is considered suitable for use. // it is considered suitable for use.
class CTRCipherStream final : public BlockAccessCipherStream { class CTRCipherStream final : public BlockAccessCipherStream {
private: private:
BlockCipher& cipher_; BlockCipher& cipher_;
std::string iv_; std::string iv_;
uint64_t initialCounter_; uint64_t initialCounter_;
public:
CTRCipherStream(BlockCipher& c, const char *iv, uint64_t initialCounter) public:
: cipher_(c), iv_(iv, c.BlockSize()), initialCounter_(initialCounter) {}; CTRCipherStream(BlockCipher& c, const char* iv, uint64_t initialCounter)
virtual ~CTRCipherStream() {}; : cipher_(c), iv_(iv, c.BlockSize()), initialCounter_(initialCounter){};
virtual ~CTRCipherStream(){};
// BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() override { return cipher_.BlockSize(); } // BlockSize returns the size of each block supported by this cipher stream.
virtual size_t BlockSize() override { return cipher_.BlockSize(); }
protected:
// Allocate scratch space which is passed to EncryptBlock/DecryptBlock. protected:
virtual void AllocateScratch(std::string&) override; // Allocate scratch space which is passed to EncryptBlock/DecryptBlock.
virtual void AllocateScratch(std::string&) override;
// Encrypt a block of data at the given block index.
// Length of data is equal to BlockSize(); // Encrypt a block of data at the given block index.
virtual Status EncryptBlock(uint64_t blockIndex, char *data, char *scratch) override; // Length of data is equal to BlockSize();
virtual Status EncryptBlock(uint64_t blockIndex, char* data,
// Decrypt a block of data at the given block index. char* scratch) override;
// Length of data is equal to BlockSize();
virtual Status DecryptBlock(uint64_t blockIndex, char *data, char *scratch) override; // Decrypt a block of data at the given block index.
// Length of data is equal to BlockSize();
virtual Status DecryptBlock(uint64_t blockIndex, char* data,
char* scratch) override;
}; };
// The encryption provider is used to create a cipher stream for a specific file. // The encryption provider is used to create a cipher stream for a specific
// The returned cipher stream will be used for actual encryption/decryption // file. The returned cipher stream will be used for actual
// actions. // encryption/decryption actions.
class EncryptionProvider { class EncryptionProvider {
public: public:
virtual ~EncryptionProvider() {}; virtual ~EncryptionProvider(){};
// GetPrefixLength returns the length of the prefix that is added to every file // GetPrefixLength returns the length of the prefix that is added to every
// and used for storing encryption options. // file and used for storing encryption options. For optimal performance, the
// For optimal performance, the prefix length should be a multiple of // prefix length should be a multiple of the page size.
// the page size. virtual size_t GetPrefixLength() = 0;
virtual size_t GetPrefixLength() = 0;
// CreateNewPrefix initialized an allocated block of prefix memory
// CreateNewPrefix initialized an allocated block of prefix memory // for a new file.
// for a new file. virtual Status CreateNewPrefix(const std::string& fname, char* prefix,
virtual Status CreateNewPrefix(const std::string& fname, char *prefix, size_t prefixLength) = 0; size_t prefixLength) = 0;
// CreateCipherStream creates a block access cipher stream for a file given // CreateCipherStream creates a block access cipher stream for a file given
// given name and options. // given name and options.
virtual Status CreateCipherStream( virtual Status CreateCipherStream(
const std::string& fname, const EnvOptions& options, Slice& prefix, const std::string& fname, const EnvOptions& options, Slice& prefix,
std::unique_ptr<BlockAccessCipherStream>* result) = 0; std::unique_ptr<BlockAccessCipherStream>* result) = 0;
}; };
// This encryption provider uses a CTR cipher stream, with a given block cipher // This encryption provider uses a CTR cipher stream, with a given block cipher
// and IV. // and IV.
// //
// Note: This is a possible implementation of EncryptionProvider, // Note: This is a possible implementation of EncryptionProvider,
// it is considered suitable for use, provided a safe BlockCipher is used. // it is considered suitable for use, provided a safe BlockCipher is used.
class CTREncryptionProvider : public EncryptionProvider { class CTREncryptionProvider : public EncryptionProvider {
private: private:
BlockCipher& cipher_; BlockCipher& cipher_;
protected:
const static size_t defaultPrefixLength = 4096; protected:
const static size_t defaultPrefixLength = 4096;
public: public:
CTREncryptionProvider(BlockCipher& c) CTREncryptionProvider(BlockCipher& c) : cipher_(c){};
: cipher_(c) {}; virtual ~CTREncryptionProvider() {}
virtual ~CTREncryptionProvider() {}
// GetPrefixLength returns the length of the prefix that is added to every
// GetPrefixLength returns the length of the prefix that is added to every file // file and used for storing encryption options. For optimal performance, the
// and used for storing encryption options. // prefix length should be a multiple of the page size.
// For optimal performance, the prefix length should be a multiple of virtual size_t GetPrefixLength() override;
// the page size.
virtual size_t GetPrefixLength() override; // CreateNewPrefix initialized an allocated block of prefix memory
// for a new file.
// CreateNewPrefix initialized an allocated block of prefix memory virtual Status CreateNewPrefix(const std::string& fname, char* prefix,
// for a new file. size_t prefixLength) override;
virtual Status CreateNewPrefix(const std::string& fname, char *prefix, size_t prefixLength) override;
// CreateCipherStream creates a block access cipher stream for a file given
// CreateCipherStream creates a block access cipher stream for a file given // given name and options.
// given name and options. virtual Status CreateCipherStream(
virtual Status CreateCipherStream( const std::string& fname, const EnvOptions& options, Slice& prefix,
const std::string& fname, const EnvOptions& options, Slice& prefix, std::unique_ptr<BlockAccessCipherStream>* result) override;
std::unique_ptr<BlockAccessCipherStream>* result) override;
protected:
protected: // PopulateSecretPrefixPart initializes the data into a new prefix block
// PopulateSecretPrefixPart initializes the data into a new prefix block // that will be encrypted. This function will store the data in plain text.
// that will be encrypted. This function will store the data in plain text. // It will be encrypted later (before written to disk).
// It will be encrypted later (before written to disk). // Returns the amount of space (starting from the start of the prefix)
// Returns the amount of space (starting from the start of the prefix) // that has been initialized.
// that has been initialized. virtual size_t PopulateSecretPrefixPart(char* prefix, size_t prefixLength,
virtual size_t PopulateSecretPrefixPart(char *prefix, size_t prefixLength, size_t blockSize); size_t blockSize);
// CreateCipherStreamFromPrefix creates a block access cipher stream for a file given // CreateCipherStreamFromPrefix creates a block access cipher stream for a
// given name and options. The given prefix is already decrypted. // file given given name and options. The given prefix is already decrypted.
virtual Status CreateCipherStreamFromPrefix( virtual Status CreateCipherStreamFromPrefix(
const std::string& fname, const EnvOptions& options, const std::string& fname, const EnvOptions& options,
uint64_t initialCounter, const Slice& iv, const Slice& prefix, uint64_t initialCounter, const Slice& iv, const Slice& prefix,
std::unique_ptr<BlockAccessCipherStream>* result); std::unique_ptr<BlockAccessCipherStream>* result);
}; };
} // namespace rocksdb } // namespace rocksdb

@ -19,9 +19,9 @@
#pragma once #pragma once
#include <stdlib.h>
#include <memory> #include <memory>
#include <stdexcept> #include <stdexcept>
#include <stdlib.h>
#include <string> #include <string>
#include <vector> #include <vector>
@ -47,7 +47,7 @@ class FilterBitsBuilder {
// Calculate num of entries fit into a space. // Calculate num of entries fit into a space.
#if defined(_MSC_VER) #if defined(_MSC_VER)
#pragma warning(push) #pragma warning(push)
#pragma warning(disable : 4702) // unreachable code #pragma warning(disable : 4702) // unreachable code
#endif #endif
virtual int CalculateNumEntry(const uint32_t /*space*/) { virtual int CalculateNumEntry(const uint32_t /*space*/) {
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
@ -102,8 +102,8 @@ class FilterPolicy {
// //
// Warning: do not change the initial contents of *dst. Instead, // Warning: do not change the initial contents of *dst. Instead,
// append the newly constructed filter to *dst. // append the newly constructed filter to *dst.
virtual void CreateFilter(const Slice* keys, int n, std::string* dst) virtual void CreateFilter(const Slice* keys, int n,
const = 0; std::string* dst) const = 0;
// "filter" contains the data appended by a preceding call to // "filter" contains the data appended by a preceding call to
// CreateFilter() on this class. This method must return true if // CreateFilter() on this class. This method must return true if
@ -114,9 +114,7 @@ class FilterPolicy {
// Get the FilterBitsBuilder, which is ONLY used for full filter block // Get the FilterBitsBuilder, which is ONLY used for full filter block
// It contains interface to take individual key, then generate filter // It contains interface to take individual key, then generate filter
virtual FilterBitsBuilder* GetFilterBitsBuilder() const { virtual FilterBitsBuilder* GetFilterBitsBuilder() const { return nullptr; }
return nullptr;
}
// Get the FilterBitsReader, which is ONLY used for full filter block // Get the FilterBitsReader, which is ONLY used for full filter block
// It contains interface to tell if key can be in filter // It contains interface to tell if key can be in filter
@ -147,4 +145,4 @@ class FilterPolicy {
// trailing spaces in keys. // trailing spaces in keys.
extern const FilterPolicy* NewBloomFilterPolicy( extern const FilterPolicy* NewBloomFilterPolicy(
int bits_per_key, bool use_block_based_builder = false); int bits_per_key, bool use_block_based_builder = false);
} } // namespace rocksdb

@ -20,10 +20,9 @@ class FlushBlockPolicy {
public: public:
// Keep track of the key/value sequences and return the boolean value to // Keep track of the key/value sequences and return the boolean value to
// determine if table builder should flush current data block. // determine if table builder should flush current data block.
virtual bool Update(const Slice& key, virtual bool Update(const Slice& key, const Slice& value) = 0;
const Slice& value) = 0;
virtual ~FlushBlockPolicy() { } virtual ~FlushBlockPolicy() {}
}; };
class FlushBlockPolicyFactory { class FlushBlockPolicyFactory {
@ -41,7 +40,7 @@ class FlushBlockPolicyFactory {
const BlockBasedTableOptions& table_options, const BlockBasedTableOptions& table_options,
const BlockBuilder& data_block_builder) const = 0; const BlockBuilder& data_block_builder) const = 0;
virtual ~FlushBlockPolicyFactory() { } virtual ~FlushBlockPolicyFactory() {}
}; };
class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory { class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory {
@ -59,4 +58,4 @@ class FlushBlockBySizePolicyFactory : public FlushBlockPolicyFactory {
const BlockBuilder& data_block_builder); const BlockBuilder& data_block_builder);
}; };
} // rocksdb } // namespace rocksdb

@ -38,6 +38,6 @@ class LDBTool {
const std::vector<ColumnFamilyDescriptor>* column_families = nullptr); const std::vector<ColumnFamilyDescriptor>* column_families = nullptr);
}; };
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

@ -192,8 +192,8 @@ struct FlushJobInfo {
struct CompactionJobInfo { struct CompactionJobInfo {
CompactionJobInfo() = default; CompactionJobInfo() = default;
explicit CompactionJobInfo(const CompactionJobStats& _stats) : explicit CompactionJobInfo(const CompactionJobStats& _stats)
stats(_stats) {} : stats(_stats) {}
// the id of the column family where the compaction happened. // the id of the column family where the compaction happened.
uint32_t cf_id; uint32_t cf_id;
@ -244,7 +244,6 @@ struct MemTableInfo {
uint64_t num_entries; uint64_t num_entries;
// Total number of deletes in memtable // Total number of deletes in memtable
uint64_t num_deletes; uint64_t num_deletes;
}; };
struct ExternalFileIngestionInfo { struct ExternalFileIngestionInfo {
@ -324,8 +323,7 @@ class EventListener {
// Note that the this function must be implemented in a way such that // Note that the this function must be implemented in a way such that
// it should not run for an extended period of time before the function // it should not run for an extended period of time before the function
// returns. Otherwise, RocksDB may be blocked. // returns. Otherwise, RocksDB may be blocked.
virtual void OnCompactionBegin(DB* /*db*/, virtual void OnCompactionBegin(DB* /*db*/, const CompactionJobInfo& /*ci*/) {}
const CompactionJobInfo& /*ci*/) {}
// A callback function for RocksDB which will be called whenever // A callback function for RocksDB which will be called whenever
// a registered RocksDB compacts a file. The default implementation // a registered RocksDB compacts a file. The default implementation
@ -380,8 +378,7 @@ class EventListener {
// Note that if applications would like to use the passed reference // Note that if applications would like to use the passed reference
// outside this function call, they should make copies from these // outside this function call, they should make copies from these
// returned value. // returned value.
virtual void OnMemTableSealed( virtual void OnMemTableSealed(const MemTableInfo& /*info*/) {}
const MemTableInfo& /*info*/) {}
// A callback function for RocksDB which will be called before // A callback function for RocksDB which will be called before
// a column family handle is deleted. // a column family handle is deleted.
@ -457,8 +454,7 @@ class EventListener {
#else #else
class EventListener { class EventListener {};
};
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

@ -35,11 +35,11 @@
#pragma once #pragma once
#include <memory> #include <rocksdb/slice.h>
#include <stdexcept>
#include <stdint.h> #include <stdint.h>
#include <stdlib.h> #include <stdlib.h>
#include <rocksdb/slice.h> #include <memory>
#include <stdexcept>
namespace rocksdb { namespace rocksdb {
@ -75,7 +75,7 @@ class MemTableRep {
virtual int operator()(const char* prefix_len_key, virtual int operator()(const char* prefix_len_key,
const Slice& key) const = 0; const Slice& key) const = 0;
virtual ~KeyComparator() { } virtual ~KeyComparator() {}
}; };
explicit MemTableRep(Allocator* allocator) : allocator_(allocator) {} explicit MemTableRep(Allocator* allocator) : allocator_(allocator) {}
@ -142,7 +142,7 @@ class MemTableRep {
// does nothing. After MarkReadOnly() is called, this table rep will // does nothing. After MarkReadOnly() is called, this table rep will
// not be written to (ie No more calls to Allocate(), Insert(), // not be written to (ie No more calls to Allocate(), Insert(),
// or any writes done directly to entries accessed through the iterator.) // or any writes done directly to entries accessed through the iterator.)
virtual void MarkReadOnly() { } virtual void MarkReadOnly() {}
// Notify this table rep that it has been flushed to stable storage. // Notify this table rep that it has been flushed to stable storage.
// By default, does nothing. // By default, does nothing.
@ -150,7 +150,7 @@ class MemTableRep {
// Invariant: MarkReadOnly() is called, before MarkFlushed(). // Invariant: MarkReadOnly() is called, before MarkFlushed().
// Note that this method if overridden, should not run for an extended period // Note that this method if overridden, should not run for an extended period
// of time. Otherwise, RocksDB may be blocked. // of time. Otherwise, RocksDB may be blocked.
virtual void MarkFlushed() { } virtual void MarkFlushed() {}
// Look up key from the mem table, since the first key in the mem table whose // Look up key from the mem table, since the first key in the mem table whose
// user_key matches the one given k, call the function callback_func(), with // user_key matches the one given k, call the function callback_func(), with
@ -176,7 +176,7 @@ class MemTableRep {
// that was allocated through the allocator. Safe to call from any thread. // that was allocated through the allocator. Safe to call from any thread.
virtual size_t ApproximateMemoryUsage() = 0; virtual size_t ApproximateMemoryUsage() = 0;
virtual ~MemTableRep() { } virtual ~MemTableRep() {}
// Iteration over the contents of a skip collection // Iteration over the contents of a skip collection
class Iterator { class Iterator {
@ -317,16 +317,14 @@ class VectorRepFactory : public MemTableRepFactory {
const size_t count_; const size_t count_;
public: public:
explicit VectorRepFactory(size_t count = 0) : count_(count) { } explicit VectorRepFactory(size_t count = 0) : count_(count) {}
using MemTableRepFactory::CreateMemTableRep; using MemTableRepFactory::CreateMemTableRep;
virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator&, virtual MemTableRep* CreateMemTableRep(const MemTableRep::KeyComparator&,
Allocator*, const SliceTransform*, Allocator*, const SliceTransform*,
Logger* logger) override; Logger* logger) override;
virtual const char* Name() const override { virtual const char* Name() const override { return "VectorRepFactory"; }
return "VectorRepFactory";
}
}; };
// This class contains a fixed array of buckets, each // This class contains a fixed array of buckets, each
@ -337,8 +335,7 @@ class VectorRepFactory : public MemTableRepFactory {
// link lists in the skiplist // link lists in the skiplist
extern MemTableRepFactory* NewHashSkipListRepFactory( extern MemTableRepFactory* NewHashSkipListRepFactory(
size_t bucket_count = 1000000, int32_t skiplist_height = 4, size_t bucket_count = 1000000, int32_t skiplist_height = 4,
int32_t skiplist_branching_factor = 4 int32_t skiplist_branching_factor = 4);
);
// The factory is to create memtables based on a hash table: // The factory is to create memtables based on a hash table:
// it contains a fixed array of buckets, each pointing to either a linked list // it contains a fixed array of buckets, each pointing to either a linked list

@ -239,13 +239,10 @@ class AssociativeMergeOperator : public MergeOperator {
// returns false, it is because client specified bad data or there was // returns false, it is because client specified bad data or there was
// internal corruption. The client should assume that this will be treated // internal corruption. The client should assume that this will be treated
// as an error by the library. // as an error by the library.
virtual bool Merge(const Slice& key, virtual bool Merge(const Slice& key, const Slice* existing_value,
const Slice* existing_value, const Slice& value, std::string* new_value,
const Slice& value,
std::string* new_value,
Logger* logger) const = 0; Logger* logger) const = 0;
private: private:
// Default implementations of the MergeOperator functions // Default implementations of the MergeOperator functions
bool FullMergeV2(const MergeOperationInput& merge_in, bool FullMergeV2(const MergeOperationInput& merge_in,

@ -22,8 +22,8 @@ struct SstFileMetaData;
struct ColumnFamilyMetaData { struct ColumnFamilyMetaData {
ColumnFamilyMetaData() : size(0), file_count(0), name("") {} ColumnFamilyMetaData() : size(0), file_count(0), name("") {}
ColumnFamilyMetaData(const std::string& _name, uint64_t _size, ColumnFamilyMetaData(const std::string& _name, uint64_t _size,
const std::vector<LevelMetaData>&& _levels) : const std::vector<LevelMetaData>&& _levels)
size(_size), name(_name), levels(_levels) {} : size(_size), name(_name), levels(_levels) {}
// The size of this column family in bytes, which is equal to the sum of // The size of this column family in bytes, which is equal to the sum of
// the file size of its "levels". // the file size of its "levels".
@ -39,9 +39,8 @@ struct ColumnFamilyMetaData {
// The metadata that describes a level. // The metadata that describes a level.
struct LevelMetaData { struct LevelMetaData {
LevelMetaData(int _level, uint64_t _size, LevelMetaData(int _level, uint64_t _size,
const std::vector<SstFileMetaData>&& _files) : const std::vector<SstFileMetaData>&& _files)
level(_level), size(_size), : level(_level), size(_size), files(_files) {}
files(_files) {}
// The level which this meta data describes. // The level which this meta data describes.
const int level; const int level;
@ -94,9 +93,9 @@ struct SstFileMetaData {
SequenceNumber smallest_seqno; // Smallest sequence number in file. SequenceNumber smallest_seqno; // Smallest sequence number in file.
SequenceNumber largest_seqno; // Largest sequence number in file. SequenceNumber largest_seqno; // Largest sequence number in file.
std::string smallestkey; // Smallest user defined key in the file. std::string smallestkey; // Smallest user defined key in the file.
std::string largestkey; // Largest user defined key in the file. std::string largestkey; // Largest user defined key in the file.
uint64_t num_reads_sampled; // How many times the file is read. uint64_t num_reads_sampled; // How many times the file is read.
bool being_compacted; // true if the file is currently being compacted. bool being_compacted; // true if the file is currently being compacted.
uint64_t num_entries; uint64_t num_entries;
@ -106,7 +105,7 @@ struct SstFileMetaData {
// The full set of metadata associated with each SST file. // The full set of metadata associated with each SST file.
struct LiveFileMetaData : SstFileMetaData { struct LiveFileMetaData : SstFileMetaData {
std::string column_family_name; // Name of the column family std::string column_family_name; // Name of the column family
int level; // Level at which this file resides. int level; // Level at which this file resides.
LiveFileMetaData() : column_family_name(), level(0) {} LiveFileMetaData() : column_family_name(), level(0) {}
}; };
} // namespace rocksdb } // namespace rocksdb

@ -10,11 +10,11 @@
#include <stddef.h> #include <stddef.h>
#include <stdint.h> #include <stdint.h>
#include <string>
#include <memory>
#include <vector>
#include <limits> #include <limits>
#include <memory>
#include <string>
#include <unordered_map> #include <unordered_map>
#include <vector>
#include "rocksdb/advanced_options.h" #include "rocksdb/advanced_options.h"
#include "rocksdb/comparator.h" #include "rocksdb/comparator.h"
@ -94,8 +94,7 @@ struct ColumnFamilyOptions : public AdvancedColumnFamilyOptions {
// an iterator, only Put() and Get() API calls // an iterator, only Put() and Get() API calls
// //
// Not supported in ROCKSDB_LITE // Not supported in ROCKSDB_LITE
ColumnFamilyOptions* OptimizeForPointLookup( ColumnFamilyOptions* OptimizeForPointLookup(uint64_t block_cache_size_mb);
uint64_t block_cache_size_mb);
// Default values for some parameters in ColumnFamilyOptions are not // Default values for some parameters in ColumnFamilyOptions are not
// optimized for heavy workloads and big datasets, which means you might // optimized for heavy workloads and big datasets, which means you might
@ -341,7 +340,6 @@ struct DbPath {
DbPath(const std::string& p, uint64_t t) : path(p), target_size(t) {} DbPath(const std::string& p, uint64_t t) : path(p), target_size(t) {}
}; };
struct DBOptions { struct DBOptions {
// The function recovers options to the option as in version 4.6. // The function recovers options to the option as in version 4.6.
DBOptions* OldDefaults(int rocksdb_major_version = 4, DBOptions* OldDefaults(int rocksdb_major_version = 4,
@ -416,9 +414,9 @@ struct DBOptions {
std::shared_ptr<Logger> info_log = nullptr; std::shared_ptr<Logger> info_log = nullptr;
#ifdef NDEBUG #ifdef NDEBUG
InfoLogLevel info_log_level = INFO_LEVEL; InfoLogLevel info_log_level = INFO_LEVEL;
#else #else
InfoLogLevel info_log_level = DEBUG_LEVEL; InfoLogLevel info_log_level = DEBUG_LEVEL;
#endif // NDEBUG #endif // NDEBUG
// Number of open files that can be used by the DB. You may need to // Number of open files that can be used by the DB. You may need to
@ -722,12 +720,7 @@ struct DBOptions {
// Specify the file access pattern once a compaction is started. // Specify the file access pattern once a compaction is started.
// It will be applied to all input files of a compaction. // It will be applied to all input files of a compaction.
// Default: NORMAL // Default: NORMAL
enum AccessHint { enum AccessHint { NONE, NORMAL, SEQUENTIAL, WILLNEED };
NONE,
NORMAL,
SEQUENTIAL,
WILLNEED
};
AccessHint access_hint_on_compaction_start = NORMAL; AccessHint access_hint_on_compaction_start = NORMAL;
// If true, always create a new file descriptor and new table reader // If true, always create a new file descriptor and new table reader
@ -782,7 +775,6 @@ struct DBOptions {
// Dynamically changeable through SetDBOptions() API. // Dynamically changeable through SetDBOptions() API.
size_t writable_file_max_buffer_size = 1024 * 1024; size_t writable_file_max_buffer_size = 1024 * 1024;
// Use adaptive mutex, which spins in the user space before resorting // Use adaptive mutex, which spins in the user space before resorting
// to kernel. This could reduce context switch when the mutex is not // to kernel. This could reduce context switch when the mutex is not
// heavily contended. However, if the mutex is hot, we could end up // heavily contended. However, if the mutex is hot, we could end up
@ -1364,7 +1356,7 @@ struct IngestExternalFileOptions {
bool verify_checksums_before_ingest = false; bool verify_checksums_before_ingest = false;
}; };
enum TraceFilterType: uint64_t { enum TraceFilterType : uint64_t {
// Trace all the operations // Trace all the operations
kTraceFilterNone = 0x0, kTraceFilterNone = 0x0,
// Do not trace the get operations // Do not trace the get operations

@ -5,8 +5,8 @@
#pragma once #pragma once
#include <map>
#include <stdint.h> #include <stdint.h>
#include <map>
#include <string> #include <string>
#include "rocksdb/perf_level.h" #include "rocksdb/perf_level.h"
@ -35,14 +35,13 @@ struct PerfContextByLevel {
// total nanos spent on reading data from SST files // total nanos spent on reading data from SST files
uint64_t get_from_table_nanos; uint64_t get_from_table_nanos;
uint64_t block_cache_hit_count = 0; // total number of block cache hits uint64_t block_cache_hit_count = 0; // total number of block cache hits
uint64_t block_cache_miss_count = 0; // total number of block cache misses uint64_t block_cache_miss_count = 0; // total number of block cache misses
void Reset(); // reset all performance counters to zero void Reset(); // reset all performance counters to zero
}; };
struct PerfContext { struct PerfContext {
~PerfContext(); ~PerfContext();
PerfContext() {} PerfContext() {}
@ -51,7 +50,7 @@ struct PerfContext {
PerfContext& operator=(const PerfContext&); PerfContext& operator=(const PerfContext&);
PerfContext(PerfContext&&) noexcept; PerfContext(PerfContext&&) noexcept;
void Reset(); // reset all performance counters to zero void Reset(); // reset all performance counters to zero
std::string ToString(bool exclude_zero_counters = false) const; std::string ToString(bool exclude_zero_counters = false) const;
@ -64,18 +63,18 @@ struct PerfContext {
// free the space for PerfContextByLevel, also disable per level perf context // free the space for PerfContextByLevel, also disable per level perf context
void ClearPerLevelPerfContext(); void ClearPerLevelPerfContext();
uint64_t user_key_comparison_count; // total number of user key comparisons uint64_t user_key_comparison_count; // total number of user key comparisons
uint64_t block_cache_hit_count; // total number of block cache hits uint64_t block_cache_hit_count; // total number of block cache hits
uint64_t block_read_count; // total number of block reads (with IO) uint64_t block_read_count; // total number of block reads (with IO)
uint64_t block_read_byte; // total number of bytes from block reads uint64_t block_read_byte; // total number of bytes from block reads
uint64_t block_read_time; // total nanos spent on block reads uint64_t block_read_time; // total nanos spent on block reads
uint64_t block_cache_index_hit_count; // total number of index block hits uint64_t block_cache_index_hit_count; // total number of index block hits
uint64_t index_block_read_count; // total number of index block reads uint64_t index_block_read_count; // total number of index block reads
uint64_t block_cache_filter_hit_count; // total number of filter block hits uint64_t block_cache_filter_hit_count; // total number of filter block hits
uint64_t filter_block_read_count; // total number of filter block reads uint64_t filter_block_read_count; // total number of filter block reads
uint64_t compression_dict_block_read_count; // total number of compression uint64_t compression_dict_block_read_count; // total number of compression
// dictionary block reads // dictionary block reads
uint64_t block_checksum_time; // total nanos spent on block checksum uint64_t block_checksum_time; // total nanos spent on block checksum
uint64_t block_decompress_time; // total nanos spent on block decompression uint64_t block_decompress_time; // total nanos spent on block decompression
uint64_t get_read_bytes; // bytes for vals returned by Get uint64_t get_read_bytes; // bytes for vals returned by Get
@ -116,9 +115,9 @@ struct PerfContext {
// //
uint64_t internal_merge_count; uint64_t internal_merge_count;
uint64_t get_snapshot_time; // total nanos spent on getting snapshot uint64_t get_snapshot_time; // total nanos spent on getting snapshot
uint64_t get_from_memtable_time; // total nanos spent on querying memtables uint64_t get_from_memtable_time; // total nanos spent on querying memtables
uint64_t get_from_memtable_count; // number of mem tables queried uint64_t get_from_memtable_count; // number of mem tables queried
// total nanos spent after Get() finds a key // total nanos spent after Get() finds a key
uint64_t get_post_process_time; uint64_t get_post_process_time;
uint64_t get_from_output_files_time; // total nanos reading from output files uint64_t get_from_output_files_time; // total nanos reading from output files
@ -230,4 +229,4 @@ struct PerfContext {
// if defined(NPERF_CONTEXT), then the pointer is not thread-local // if defined(NPERF_CONTEXT), then the pointer is not thread-local
PerfContext* get_perf_context(); PerfContext* get_perf_context();
} } // namespace rocksdb

@ -19,9 +19,9 @@
#pragma once #pragma once
#include <assert.h> #include <assert.h>
#include <cstdio>
#include <stddef.h> #include <stddef.h>
#include <string.h> #include <string.h>
#include <cstdio>
#include <string> #include <string>
#ifdef __cpp_lib_string_view #ifdef __cpp_lib_string_view
@ -35,14 +35,14 @@ namespace rocksdb {
class Slice { class Slice {
public: public:
// Create an empty slice. // Create an empty slice.
Slice() : data_(""), size_(0) { } Slice() : data_(""), size_(0) {}
// Create a slice that refers to d[0,n-1]. // Create a slice that refers to d[0,n-1].
Slice(const char* d, size_t n) : data_(d), size_(n) { } Slice(const char* d, size_t n) : data_(d), size_(n) {}
// Create a slice that refers to the contents of "s" // Create a slice that refers to the contents of "s"
/* implicit */ /* implicit */
Slice(const std::string& s) : data_(s.data()), size_(s.size()) { } Slice(const std::string& s) : data_(s.data()), size_(s.size()) {}
#ifdef __cpp_lib_string_view #ifdef __cpp_lib_string_view
// Create a slice that refers to the same contents as "sv" // Create a slice that refers to the same contents as "sv"
@ -52,9 +52,7 @@ class Slice {
// Create a slice that refers to s[0,strlen(s)-1] // Create a slice that refers to s[0,strlen(s)-1]
/* implicit */ /* implicit */
Slice(const char* s) : data_(s) { Slice(const char* s) : data_(s) { size_ = (s == nullptr) ? 0 : strlen(s); }
size_ = (s == nullptr) ? 0 : strlen(s);
}
// Create a single slice from SliceParts using buf as storage. // Create a single slice from SliceParts using buf as storage.
// buf must exist as long as the returned Slice exists. // buf must exist as long as the returned Slice exists.
@ -77,7 +75,10 @@ class Slice {
} }
// Change this slice to refer to an empty array // Change this slice to refer to an empty array
void clear() { data_ = ""; size_ = 0; } void clear() {
data_ = "";
size_ = 0;
}
// Drop the first "n" bytes from this slice. // Drop the first "n" bytes from this slice.
void remove_prefix(size_t n) { void remove_prefix(size_t n) {
@ -117,8 +118,7 @@ class Slice {
// Return true iff "x" is a prefix of "*this" // Return true iff "x" is a prefix of "*this"
bool starts_with(const Slice& x) const { bool starts_with(const Slice& x) const {
return ((size_ >= x.size_) && return ((size_ >= x.size_) && (memcmp(data_, x.data_, x.size_) == 0));
(memcmp(data_, x.data_, x.size_) == 0));
} }
bool ends_with(const Slice& x) const { bool ends_with(const Slice& x) const {
@ -129,7 +129,7 @@ class Slice {
// Compare two slices and returns the first byte where they differ // Compare two slices and returns the first byte where they differ
size_t difference_offset(const Slice& b) const; size_t difference_offset(const Slice& b) const;
// private: make these public for rocksdbjni access // private: make these public for rocksdbjni access
const char* data_; const char* data_;
size_t size_; size_t size_;
@ -219,8 +219,8 @@ class PinnableSlice : public Slice, public Cleanable {
// A set of Slices that are virtually concatenated together. 'parts' points // A set of Slices that are virtually concatenated together. 'parts' points
// to an array of Slices. The number of elements in the array is 'num_parts'. // to an array of Slices. The number of elements in the array is 'num_parts'.
struct SliceParts { struct SliceParts {
SliceParts(const Slice* _parts, int _num_parts) : SliceParts(const Slice* _parts, int _num_parts)
parts(_parts), num_parts(_num_parts) { } : parts(_parts), num_parts(_num_parts) {}
SliceParts() : parts(nullptr), num_parts(0) {} SliceParts() : parts(nullptr), num_parts(0) {}
const Slice* parts; const Slice* parts;
@ -232,17 +232,17 @@ inline bool operator==(const Slice& x, const Slice& y) {
(memcmp(x.data(), y.data(), x.size()) == 0)); (memcmp(x.data(), y.data(), x.size()) == 0));
} }
inline bool operator!=(const Slice& x, const Slice& y) { inline bool operator!=(const Slice& x, const Slice& y) { return !(x == y); }
return !(x == y);
}
inline int Slice::compare(const Slice& b) const { inline int Slice::compare(const Slice& b) const {
assert(data_ != nullptr && b.data_ != nullptr); assert(data_ != nullptr && b.data_ != nullptr);
const size_t min_len = (size_ < b.size_) ? size_ : b.size_; const size_t min_len = (size_ < b.size_) ? size_ : b.size_;
int r = memcmp(data_, b.data_, min_len); int r = memcmp(data_, b.data_, min_len);
if (r == 0) { if (r == 0) {
if (size_ < b.size_) r = -1; if (size_ < b.size_)
else if (size_ > b.size_) r = +1; r = -1;
else if (size_ > b.size_)
r = +1;
} }
return r; return r;
} }

@ -28,7 +28,7 @@ class Slice;
*/ */
class SliceTransform { class SliceTransform {
public: public:
virtual ~SliceTransform() {}; virtual ~SliceTransform(){};
// Return the name of this transformation. // Return the name of this transformation.
virtual const char* Name() const = 0; virtual const char* Name() const = 0;
@ -98,4 +98,4 @@ extern const SliceTransform* NewCappedPrefixTransform(size_t cap_len);
extern const SliceTransform* NewNoopTransform(); extern const SliceTransform* NewNoopTransform();
} } // namespace rocksdb

@ -77,8 +77,9 @@ class SstFileWriter {
// be ingested into this column_family, note that passing nullptr means that // be ingested into this column_family, note that passing nullptr means that
// the column_family is unknown. // the column_family is unknown.
// If invalidate_page_cache is set to true, SstFileWriter will give the OS a // If invalidate_page_cache is set to true, SstFileWriter will give the OS a
// hint that this file pages is not needed every time we write 1MB to the file. // hint that this file pages is not needed every time we write 1MB to the
// To use the rate limiter an io_priority smaller than IO_TOTAL can be passed. // file. To use the rate limiter an io_priority smaller than IO_TOTAL can be
// passed.
SstFileWriter(const EnvOptions& env_options, const Options& options, SstFileWriter(const EnvOptions& env_options, const Options& options,
ColumnFamilyHandle* column_family = nullptr, ColumnFamilyHandle* column_family = nullptr,
bool invalidate_page_cache = true, bool invalidate_page_cache = true,

@ -495,9 +495,7 @@ class Statistics {
} }
// Resets all ticker and histogram stats // Resets all ticker and histogram stats
virtual Status Reset() { virtual Status Reset() { return Status::NotSupported("Not implemented"); }
return Status::NotSupported("Not implemented");
}
// String representation of the statistic object. // String representation of the statistic object.
virtual std::string ToString() const { virtual std::string ToString() const {

@ -305,11 +305,12 @@ class Status {
static const char* CopyState(const char* s); static const char* CopyState(const char* s);
}; };
inline Status::Status(const Status& s) : code_(s.code_), subcode_(s.subcode_), sev_(s.sev_) { inline Status::Status(const Status& s)
: code_(s.code_), subcode_(s.subcode_), sev_(s.sev_) {
state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_); state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_);
} }
inline Status::Status(const Status& s, Severity sev) inline Status::Status(const Status& s, Severity sev)
: code_(s.code_), subcode_(s.subcode_), sev_(sev) { : code_(s.code_), subcode_(s.subcode_), sev_(sev) {
state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_); state_ = (s.state_ == nullptr) ? nullptr : CopyState(s.state_);
} }
inline Status& Status::operator=(const Status& s) { inline Status& Status::operator=(const Status& s) {

@ -356,13 +356,13 @@ struct PlainTableOptions {
}; };
// -- Plain Table with prefix-only seek // -- Plain Table with prefix-only seek
// For this factory, you need to set Options.prefix_extractor properly to make it // For this factory, you need to set Options.prefix_extractor properly to make
// work. Look-up will starts with prefix hash lookup for key prefix. Inside the // it work. Look-up will starts with prefix hash lookup for key prefix. Inside
// hash bucket found, a binary search is executed for hash conflicts. Finally, // the hash bucket found, a binary search is executed for hash conflicts.
// a linear search is used. // Finally, a linear search is used.
extern TableFactory* NewPlainTableFactory(const PlainTableOptions& options = extern TableFactory* NewPlainTableFactory(
PlainTableOptions()); const PlainTableOptions& options = PlainTableOptions());
struct CuckooTablePropertyNames { struct CuckooTablePropertyNames {
// The key that is used to fill empty buckets. // The key that is used to fill empty buckets.
@ -496,9 +496,8 @@ class TableFactory {
// //
// If the function cannot find a way to sanitize the input DB Options, // If the function cannot find a way to sanitize the input DB Options,
// a non-ok Status will be returned. // a non-ok Status will be returned.
virtual Status SanitizeOptions( virtual Status SanitizeOptions(const DBOptions& db_opts,
const DBOptions& db_opts, const ColumnFamilyOptions& cf_opts) const = 0;
const ColumnFamilyOptions& cf_opts) const = 0;
// Return a string that contains printable format of table configurations. // Return a string that contains printable format of table configurations.
// RocksDB prints configurations at DB Open(). // RocksDB prints configurations at DB Open().
@ -538,7 +537,8 @@ class TableFactory {
// @block_based_table_factory: block based table factory to use. If NULL, use // @block_based_table_factory: block based table factory to use. If NULL, use
// a default one. // a default one.
// @plain_table_factory: plain table factory to use. If NULL, use a default one. // @plain_table_factory: plain table factory to use. If NULL, use a default one.
// @cuckoo_table_factory: cuckoo table factory to use. If NULL, use a default one. // @cuckoo_table_factory: cuckoo table factory to use. If NULL, use a default
// one.
extern TableFactory* NewAdaptiveTableFactory( extern TableFactory* NewAdaptiveTableFactory(
std::shared_ptr<TableFactory> table_factory_to_write = nullptr, std::shared_ptr<TableFactory> table_factory_to_write = nullptr,
std::shared_ptr<TableFactory> block_based_table_factory = nullptr, std::shared_ptr<TableFactory> block_based_table_factory = nullptr,

@ -20,8 +20,7 @@
#include <utility> #include <utility>
#include <vector> #include <vector>
#if !defined(ROCKSDB_LITE) && \ #if !defined(ROCKSDB_LITE) && !defined(NROCKSDB_THREAD_STATUS) && \
!defined(NROCKSDB_THREAD_STATUS) && \
defined(ROCKSDB_SUPPORT_THREAD_LOCAL) defined(ROCKSDB_SUPPORT_THREAD_LOCAL)
#define ROCKSDB_USING_THREAD_STATUS #define ROCKSDB_USING_THREAD_STATUS
#endif #endif
@ -43,9 +42,9 @@ struct ThreadStatus {
// The type of a thread. // The type of a thread.
enum ThreadType : int { enum ThreadType : int {
HIGH_PRIORITY = 0, // RocksDB BG thread in high-pri thread pool HIGH_PRIORITY = 0, // RocksDB BG thread in high-pri thread pool
LOW_PRIORITY, // RocksDB BG thread in low-pri thread pool LOW_PRIORITY, // RocksDB BG thread in low-pri thread pool
USER, // User thread (Non-RocksDB BG thread) USER, // User thread (Non-RocksDB BG thread)
BOTTOM_PRIORITY, // RocksDB BG thread in bottom-pri thread pool BOTTOM_PRIORITY, // RocksDB BG thread in bottom-pri thread pool
NUM_THREAD_TYPES NUM_THREAD_TYPES
}; };
@ -105,22 +104,20 @@ struct ThreadStatus {
NUM_STATE_TYPES NUM_STATE_TYPES
}; };
ThreadStatus(const uint64_t _id, ThreadStatus(const uint64_t _id, const ThreadType _thread_type,
const ThreadType _thread_type, const std::string& _db_name, const std::string& _cf_name,
const std::string& _db_name,
const std::string& _cf_name,
const OperationType _operation_type, const OperationType _operation_type,
const uint64_t _op_elapsed_micros, const uint64_t _op_elapsed_micros,
const OperationStage _operation_stage, const OperationStage _operation_stage,
const uint64_t _op_props[], const uint64_t _op_props[], const StateType _state_type)
const StateType _state_type) : : thread_id(_id),
thread_id(_id), thread_type(_thread_type), thread_type(_thread_type),
db_name(_db_name), db_name(_db_name),
cf_name(_cf_name), cf_name(_cf_name),
operation_type(_operation_type), operation_type(_operation_type),
op_elapsed_micros(_op_elapsed_micros), op_elapsed_micros(_op_elapsed_micros),
operation_stage(_operation_stage), operation_stage(_operation_stage),
state_type(_state_type) { state_type(_state_type) {
for (int i = 0; i < kNumOperationProperties; ++i) { for (int i = 0; i < kNumOperationProperties; ++i) {
op_properties[i] = _op_props[i]; op_properties[i] = _op_props[i];
} }
@ -172,23 +169,20 @@ struct ThreadStatus {
static const std::string MicrosToString(uint64_t op_elapsed_time); static const std::string MicrosToString(uint64_t op_elapsed_time);
// Obtain a human-readable string describing the specified operation stage. // Obtain a human-readable string describing the specified operation stage.
static const std::string& GetOperationStageName( static const std::string& GetOperationStageName(OperationStage stage);
OperationStage stage);
// Obtain the name of the "i"th operation property of the // Obtain the name of the "i"th operation property of the
// specified operation. // specified operation.
static const std::string& GetOperationPropertyName( static const std::string& GetOperationPropertyName(OperationType op_type,
OperationType op_type, int i); int i);
// Translate the "i"th property of the specified operation given // Translate the "i"th property of the specified operation given
// a property value. // a property value.
static std::map<std::string, uint64_t> static std::map<std::string, uint64_t> InterpretOperationProperties(
InterpretOperationProperties( OperationType op_type, const uint64_t* op_properties);
OperationType op_type, const uint64_t* op_properties);
// Obtain the name of a state given its type. // Obtain the name of a state given its type.
static const std::string& GetStateName(StateType state_type); static const std::string& GetStateName(StateType state_type);
}; };
} // namespace rocksdb } // namespace rocksdb

@ -47,7 +47,6 @@ class ThreadPool {
virtual void SubmitJob(const std::function<void()>&) = 0; virtual void SubmitJob(const std::function<void()>&) = 0;
// This moves the function in for efficiency // This moves the function in for efficiency
virtual void SubmitJob(std::function<void()>&&) = 0; virtual void SubmitJob(std::function<void()>&&) = 0;
}; };
// NewThreadPool() is a function that could be used to create a ThreadPool // NewThreadPool() is a function that could be used to create a ThreadPool

@ -5,18 +5,18 @@
#pragma once #pragma once
#include <memory>
#include <vector>
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/types.h" #include "rocksdb/types.h"
#include "rocksdb/write_batch.h" #include "rocksdb/write_batch.h"
#include <memory>
#include <vector>
namespace rocksdb { namespace rocksdb {
class LogFile; class LogFile;
typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr; typedef std::vector<std::unique_ptr<LogFile>> VectorLogPtr;
enum WalFileType { enum WalFileType {
/* Indicates that WAL file is in archive directory. WAL files are moved from /* Indicates that WAL file is in archive directory. WAL files are moved from
* the main db directory to archive directory once they are not live and stay * the main db directory to archive directory once they are not live and stay
* there until cleaned up. Files are cleaned depending on archive size * there until cleaned up. Files are cleaned depending on archive size
@ -27,7 +27,7 @@ enum WalFileType {
/* Indicates that WAL file is live and resides in the main db directory */ /* Indicates that WAL file is live and resides in the main db directory */
kAliveLogFile = 1 kAliveLogFile = 1
} ; };
class LogFile { class LogFile {
public: public:
@ -39,7 +39,6 @@ class LogFile {
// For an archived-log-file = /archive/000003.log // For an archived-log-file = /archive/000003.log
virtual std::string PathName() const = 0; virtual std::string PathName() const = 0;
// Primary identifier for log file. // Primary identifier for log file.
// This is directly proportional to creation time of the log file // This is directly proportional to creation time of the log file
virtual uint64_t LogNumber() const = 0; virtual uint64_t LogNumber() const = 0;
@ -119,4 +118,4 @@ class TransactionLogIterator {
: verify_checksums_(verify_checksums) {} : verify_checksums_(verify_checksums) {}
}; };
}; };
} // namespace rocksdb } // namespace rocksdb

@ -32,11 +32,9 @@ struct FullKey {
SequenceNumber sequence; SequenceNumber sequence;
EntryType type; EntryType type;
FullKey() FullKey() : sequence(0) {} // Intentionally left uninitialized (for speed)
: sequence(0)
{} // Intentionally left uninitialized (for speed)
FullKey(const Slice& u, const SequenceNumber& seq, EntryType t) FullKey(const Slice& u, const SequenceNumber& seq, EntryType t)
: user_key(u), sequence(seq), type(t) { } : user_key(u), sequence(seq), type(t) {}
std::string DebugString(bool hex = false) const; std::string DebugString(bool hex = false) const;
void clear() { void clear() {

@ -16,13 +16,12 @@ namespace rocksdb {
// into a single compaction run // into a single compaction run
// //
enum CompactionStopStyle { enum CompactionStopStyle {
kCompactionStopStyleSimilarSize, // pick files of similar size kCompactionStopStyleSimilarSize, // pick files of similar size
kCompactionStopStyleTotalSize // total size of picked files > next file kCompactionStopStyleTotalSize // total size of picked files > next file
}; };
class CompactionOptionsUniversal { class CompactionOptionsUniversal {
public: public:
// Percentage flexibility while comparing file size. If the candidate file(s) // Percentage flexibility while comparing file size. If the candidate file(s)
// size is 1% smaller than the next file's size, then include next file into // size is 1% smaller than the next file's size, then include next file into
// this candidate set. // Default: 1 // this candidate set. // Default: 1

@ -15,10 +15,10 @@
#endif #endif
#include <inttypes.h> #include <inttypes.h>
#include <string> #include <functional>
#include <map> #include <map>
#include <string>
#include <vector> #include <vector>
#include <functional>
#include "rocksdb/utilities/stackable_db.h" #include "rocksdb/utilities/stackable_db.h"
@ -257,8 +257,7 @@ class BackupEngine {
// BackupableDBOptions have to be the same as the ones used in previous // BackupableDBOptions have to be the same as the ones used in previous
// BackupEngines for the same backup directory. // BackupEngines for the same backup directory.
static Status Open(Env* db_env, static Status Open(Env* db_env, const BackupableDBOptions& options,
const BackupableDBOptions& options,
BackupEngine** backup_engine_ptr); BackupEngine** backup_engine_ptr);
// same as CreateNewBackup, but stores extra application metadata // same as CreateNewBackup, but stores extra application metadata

@ -9,8 +9,8 @@
#include <string> #include <string>
#include <vector> #include <vector>
#include "rocksdb/utilities/stackable_db.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/utilities/stackable_db.h"
namespace rocksdb { namespace rocksdb {
@ -60,9 +60,9 @@ class DBWithTTL : public StackableDB {
DBWithTTL** dbptr, std::vector<int32_t> ttls, DBWithTTL** dbptr, std::vector<int32_t> ttls,
bool read_only = false); bool read_only = false);
virtual void SetTtl(int32_t ttl) = 0; virtual void SetTtl(int32_t ttl) = 0;
virtual void SetTtl(ColumnFamilyHandle *h, int32_t ttl) = 0; virtual void SetTtl(ColumnFamilyHandle* h, int32_t ttl) = 0;
protected: protected:
explicit DBWithTTL(DB* db) : StackableDB(db) {} explicit DBWithTTL(DB* db) : StackableDB(db) {}

@ -172,4 +172,4 @@ class EnvLibrados : public EnvWrapper {
librados::IoCtx* _GetIoctx(const std::string& prefix); librados::IoCtx* _GetIoctx(const std::string& prefix);
friend class LibradosWritableFile; friend class LibradosWritableFile;
}; };
} } // namespace rocksdb

@ -19,8 +19,8 @@
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
#include <iostream>
#include <algorithm> #include <algorithm>
#include <iostream>
#include <vector> #include <vector>
#include "rocksdb/env.h" #include "rocksdb/env.h"
@ -31,21 +31,15 @@ class RandomAccessFileMirror;
class WritableFileMirror; class WritableFileMirror;
class EnvMirror : public EnvWrapper { class EnvMirror : public EnvWrapper {
Env* a_, *b_; Env *a_, *b_;
bool free_a_, free_b_; bool free_a_, free_b_;
public: public:
EnvMirror(Env* a, Env* b, bool free_a=false, bool free_b=false) EnvMirror(Env* a, Env* b, bool free_a = false, bool free_b = false)
: EnvWrapper(a), : EnvWrapper(a), a_(a), b_(b), free_a_(free_a), free_b_(free_b) {}
a_(a),
b_(b),
free_a_(free_a),
free_b_(free_b) {}
~EnvMirror() { ~EnvMirror() {
if (free_a_) if (free_a_) delete a_;
delete a_; if (free_b_) delete b_;
if (free_b_)
delete b_;
} }
Status NewSequentialFile(const std::string& f, Status NewSequentialFile(const std::string& f,
@ -157,12 +151,12 @@ class EnvMirror : public EnvWrapper {
class FileLockMirror : public FileLock { class FileLockMirror : public FileLock {
public: public:
FileLock* a_, *b_; FileLock *a_, *b_;
FileLockMirror(FileLock* a, FileLock* b) : a_(a), b_(b) {} FileLockMirror(FileLock* a, FileLock* b) : a_(a), b_(b) {}
}; };
Status LockFile(const std::string& f, FileLock** l) override { Status LockFile(const std::string& f, FileLock** l) override {
FileLock* al, *bl; FileLock *al, *bl;
Status as = a_->LockFile(f, &al); Status as = a_->LockFile(f, &al);
Status bs = b_->LockFile(f, &bl); Status bs = b_->LockFile(f, &bl);
assert(as == bs); assert(as == bs);

@ -12,26 +12,28 @@
namespace rocksdb { namespace rocksdb {
class LDBCommandExecuteResult { class LDBCommandExecuteResult {
public: public:
enum State { enum State {
EXEC_NOT_STARTED = 0, EXEC_SUCCEED = 1, EXEC_FAILED = 2, EXEC_NOT_STARTED = 0,
EXEC_SUCCEED = 1,
EXEC_FAILED = 2,
}; };
LDBCommandExecuteResult() : state_(EXEC_NOT_STARTED), message_("") {} LDBCommandExecuteResult() : state_(EXEC_NOT_STARTED), message_("") {}
LDBCommandExecuteResult(State state, std::string& msg) : LDBCommandExecuteResult(State state, std::string& msg)
state_(state), message_(msg) {} : state_(state), message_(msg) {}
std::string ToString() { std::string ToString() {
std::string ret; std::string ret;
switch (state_) { switch (state_) {
case EXEC_SUCCEED: case EXEC_SUCCEED:
break; break;
case EXEC_FAILED: case EXEC_FAILED:
ret.append("Failed: "); ret.append("Failed: ");
break; break;
case EXEC_NOT_STARTED: case EXEC_NOT_STARTED:
ret.append("Not started: "); ret.append("Not started: ");
} }
if (!message_.empty()) { if (!message_.empty()) {
ret.append(message_); ret.append(message_);
@ -44,17 +46,11 @@ public:
message_ = ""; message_ = "";
} }
bool IsSucceed() { bool IsSucceed() { return state_ == EXEC_SUCCEED; }
return state_ == EXEC_SUCCEED;
}
bool IsNotStarted() { bool IsNotStarted() { return state_ == EXEC_NOT_STARTED; }
return state_ == EXEC_NOT_STARTED;
}
bool IsFailed() { bool IsFailed() { return state_ == EXEC_FAILED; }
return state_ == EXEC_FAILED;
}
static LDBCommandExecuteResult Succeed(std::string msg) { static LDBCommandExecuteResult Succeed(std::string msg) {
return LDBCommandExecuteResult(EXEC_SUCCEED, msg); return LDBCommandExecuteResult(EXEC_SUCCEED, msg);
@ -64,7 +60,7 @@ public:
return LDBCommandExecuteResult(EXEC_FAILED, msg); return LDBCommandExecuteResult(EXEC_FAILED, msg);
} }
private: private:
State state_; State state_;
std::string message_; std::string message_;
@ -72,4 +68,4 @@ private:
bool operator!=(const LDBCommandExecuteResult&); bool operator!=(const LDBCommandExecuteResult&);
}; };
} } // namespace rocksdb

@ -73,7 +73,8 @@ class SimCache : public Cache {
// stop logging to the file automatically after reaching a specific size in // stop logging to the file automatically after reaching a specific size in
// bytes, a values of 0 disable this feature // bytes, a values of 0 disable this feature
virtual Status StartActivityLogging(const std::string& activity_log_file, virtual Status StartActivityLogging(const std::string& activity_log_file,
Env* env, uint64_t max_logging_size = 0) = 0; Env* env,
uint64_t max_logging_size = 0) = 0;
// Stop cache activity logging if any // Stop cache activity logging if any
virtual void StopActivityLogging() = 0; virtual void StopActivityLogging() = 0;

@ -13,7 +13,6 @@
#undef DeleteFile #undef DeleteFile
#endif #endif
namespace rocksdb { namespace rocksdb {
// This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d // This class contains APIs to stack rocksdb wrappers.Eg. Stack TTL over base d
@ -37,9 +36,7 @@ class StackableDB : public DB {
virtual Status Close() override { return db_->Close(); } virtual Status Close() override { return db_->Close(); }
virtual DB* GetBaseDB() { virtual DB* GetBaseDB() { return db_; }
return db_;
}
virtual DB* GetRootDB() override { return db_->GetRootDB(); } virtual DB* GetRootDB() override { return db_->GetRootDB(); }
@ -144,10 +141,8 @@ class StackableDB : public DB {
return db_->Merge(options, column_family, key, value); return db_->Merge(options, column_family, key, value);
} }
virtual Status Write(const WriteOptions& opts, WriteBatch* updates) override {
virtual Status Write(const WriteOptions& opts, WriteBatch* updates) return db_->Write(opts, updates);
override {
return db_->Write(opts, updates);
} }
using DB::NewIterator; using DB::NewIterator;
@ -163,10 +158,7 @@ class StackableDB : public DB {
return db_->NewIterators(options, column_families, iterators); return db_->NewIterators(options, column_families, iterators);
} }
virtual const Snapshot* GetSnapshot() override { return db_->GetSnapshot(); }
virtual const Snapshot* GetSnapshot() override {
return db_->GetSnapshot();
}
virtual void ReleaseSnapshot(const Snapshot* snapshot) override { virtual void ReleaseSnapshot(const Snapshot* snapshot) override {
return db_->ReleaseSnapshot(snapshot); return db_->ReleaseSnapshot(snapshot);
@ -197,12 +189,10 @@ class StackableDB : public DB {
} }
using DB::GetApproximateSizes; using DB::GetApproximateSizes;
virtual void GetApproximateSizes(ColumnFamilyHandle* column_family, virtual void GetApproximateSizes(
const Range* r, int n, uint64_t* sizes, ColumnFamilyHandle* column_family, const Range* r, int n, uint64_t* sizes,
uint8_t include_flags uint8_t include_flags = INCLUDE_FILES) override {
= INCLUDE_FILES) override { return db_->GetApproximateSizes(column_family, r, n, sizes, include_flags);
return db_->GetApproximateSizes(column_family, r, n, sizes,
include_flags);
} }
using DB::GetApproximateMemTableStats; using DB::GetApproximateMemTableStats;
@ -251,24 +241,20 @@ class StackableDB : public DB {
} }
using DB::MaxMemCompactionLevel; using DB::MaxMemCompactionLevel;
virtual int MaxMemCompactionLevel(ColumnFamilyHandle* column_family) virtual int MaxMemCompactionLevel(
override { ColumnFamilyHandle* column_family) override {
return db_->MaxMemCompactionLevel(column_family); return db_->MaxMemCompactionLevel(column_family);
} }
using DB::Level0StopWriteTrigger; using DB::Level0StopWriteTrigger;
virtual int Level0StopWriteTrigger(ColumnFamilyHandle* column_family) virtual int Level0StopWriteTrigger(
override { ColumnFamilyHandle* column_family) override {
return db_->Level0StopWriteTrigger(column_family); return db_->Level0StopWriteTrigger(column_family);
} }
virtual const std::string& GetName() const override { virtual const std::string& GetName() const override { return db_->GetName(); }
return db_->GetName();
}
virtual Env* GetEnv() const override { virtual Env* GetEnv() const override { return db_->GetEnv(); }
return db_->GetEnv();
}
using DB::GetOptions; using DB::GetOptions;
virtual Options GetOptions(ColumnFamilyHandle* column_family) const override { virtual Options GetOptions(ColumnFamilyHandle* column_family) const override {
@ -291,9 +277,7 @@ class StackableDB : public DB {
return db_->Flush(fopts, column_families); return db_->Flush(fopts, column_families);
} }
virtual Status SyncWAL() override { virtual Status SyncWAL() override { return db_->SyncWAL(); }
return db_->SyncWAL();
}
virtual Status FlushWAL(bool sync) override { return db_->FlushWAL(sync); } virtual Status FlushWAL(bool sync) override { return db_->FlushWAL(sync); }
@ -312,9 +296,8 @@ class StackableDB : public DB {
db_->GetLiveFilesMetaData(metadata); db_->GetLiveFilesMetaData(metadata);
} }
virtual void GetColumnFamilyMetaData( virtual void GetColumnFamilyMetaData(ColumnFamilyHandle* column_family,
ColumnFamilyHandle *column_family, ColumnFamilyMetaData* cf_meta) override {
ColumnFamilyMetaData* cf_meta) override {
db_->GetColumnFamilyMetaData(column_family, cf_meta); db_->GetColumnFamilyMetaData(column_family, cf_meta);
} }
@ -322,14 +305,15 @@ class StackableDB : public DB {
virtual Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs, virtual Status GetLiveFiles(std::vector<std::string>& vec, uint64_t* mfs,
bool flush_memtable = true) override { bool flush_memtable = true) override {
return db_->GetLiveFiles(vec, mfs, flush_memtable); return db_->GetLiveFiles(vec, mfs, flush_memtable);
} }
virtual SequenceNumber GetLatestSequenceNumber() const override { virtual SequenceNumber GetLatestSequenceNumber() const override {
return db_->GetLatestSequenceNumber(); return db_->GetLatestSequenceNumber();
} }
virtual bool SetPreserveDeletesSequenceNumber(SequenceNumber seqnum) override { virtual bool SetPreserveDeletesSequenceNumber(
SequenceNumber seqnum) override {
return db_->SetPreserveDeletesSequenceNumber(seqnum); return db_->SetPreserveDeletesSequenceNumber(seqnum);
} }
@ -401,4 +385,4 @@ class StackableDB : public DB {
std::shared_ptr<DB> shared_db_ptr_; std::shared_ptr<DB> shared_db_ptr_;
}; };
} // namespace rocksdb } // namespace rocksdb

@ -40,20 +40,18 @@ class CompactOnDeletionCollectorFactory
private: private:
friend std::shared_ptr<CompactOnDeletionCollectorFactory> friend std::shared_ptr<CompactOnDeletionCollectorFactory>
NewCompactOnDeletionCollectorFactory( NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
size_t sliding_window_size, size_t deletion_trigger);
size_t deletion_trigger);
// A factory of a table property collector that marks a SST // A factory of a table property collector that marks a SST
// file as need-compaction when it observe at least "D" deletion // file as need-compaction when it observe at least "D" deletion
// entries in any "N" consecutive entires. // entries in any "N" consecutive entires.
// //
// @param sliding_window_size "N" // @param sliding_window_size "N"
// @param deletion_trigger "D" // @param deletion_trigger "D"
CompactOnDeletionCollectorFactory( CompactOnDeletionCollectorFactory(size_t sliding_window_size,
size_t sliding_window_size, size_t deletion_trigger)
size_t deletion_trigger) : : sliding_window_size_(sliding_window_size),
sliding_window_size_(sliding_window_size), deletion_trigger_(deletion_trigger) {}
deletion_trigger_(deletion_trigger) {}
std::atomic<size_t> sliding_window_size_; std::atomic<size_t> sliding_window_size_;
std::atomic<size_t> deletion_trigger_; std::atomic<size_t> deletion_trigger_;
@ -69,9 +67,8 @@ class CompactOnDeletionCollectorFactory
// @param deletion_trigger "D". Note that even when "N" is changed, // @param deletion_trigger "D". Note that even when "N" is changed,
// the specified number for "D" will not be changed. // the specified number for "D" will not be changed.
extern std::shared_ptr<CompactOnDeletionCollectorFactory> extern std::shared_ptr<CompactOnDeletionCollectorFactory>
NewCompactOnDeletionCollectorFactory( NewCompactOnDeletionCollectorFactory(size_t sliding_window_size,
size_t sliding_window_size, size_t deletion_trigger);
size_t deletion_trigger);
} // namespace rocksdb } // namespace rocksdb
#endif // !ROCKSDB_LITE #endif // !ROCKSDB_LITE

@ -127,7 +127,6 @@ struct TransactionOptions {
// return 0 if // return 0 if
// a.compare(b) returns 0. // a.compare(b) returns 0.
// If positive, specifies the wait timeout in milliseconds when // If positive, specifies the wait timeout in milliseconds when
// a transaction attempts to lock a key. // a transaction attempts to lock a key.
// //

@ -4,12 +4,12 @@
#pragma once #pragma once
#ifndef ROCKSDB_LITE #ifndef ROCKSDB_LITE
#include <vector>
#include <string> #include <string>
#include <vector>
#include "rocksdb/utilities/stackable_db.h"
#include "rocksdb/utilities/db_ttl.h"
#include "rocksdb/db.h" #include "rocksdb/db.h"
#include "rocksdb/utilities/db_ttl.h"
#include "rocksdb/utilities/stackable_db.h"
namespace rocksdb { namespace rocksdb {
@ -22,14 +22,12 @@ class UtilityDB {
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
__attribute__((deprecated)) __attribute__((deprecated))
#elif _WIN32 #elif _WIN32
__declspec(deprecated) __declspec(deprecated)
#endif #endif
static Status OpenTtlDB(const Options& options, static Status
const std::string& name, OpenTtlDB(const Options& options, const std::string& name,
StackableDB** dbptr, StackableDB** dbptr, int32_t ttl = 0, bool read_only = false);
int32_t ttl = 0,
bool read_only = false);
}; };
} // namespace rocksdb } // namespace rocksdb
#endif // ROCKSDB_LITE #endif // ROCKSDB_LITE

@ -5,8 +5,8 @@
#pragma once #pragma once
#include <string>
#include <map> #include <map>
#include <string>
namespace rocksdb { namespace rocksdb {
@ -34,7 +34,7 @@ class WalFilter {
virtual ~WalFilter() {} virtual ~WalFilter() {}
// Provide ColumnFamily->LogNumber map to filter // Provide ColumnFamily->LogNumber map to filter
// so that filter can determine whether a log number applies to a given // so that filter can determine whether a log number applies to a given
// column family (i.e. that log hasn't been flushed to SST already for the // column family (i.e. that log hasn't been flushed to SST already for the
// column family). // column family).
// We also pass in name->id map as only name is known during // We also pass in name->id map as only name is known during
@ -83,8 +83,8 @@ class WalFilter {
return LogRecord(batch, new_batch, batch_changed); return LogRecord(batch, new_batch, batch_changed);
} }
// Please see the comments for LogRecord above. This function is for // Please see the comments for LogRecord above. This function is for
// compatibility only and contains a subset of parameters. // compatibility only and contains a subset of parameters.
// New code should use the function above. // New code should use the function above.
virtual WalProcessingOption LogRecord(const WriteBatch& /*batch*/, virtual WalProcessingOption LogRecord(const WriteBatch& /*batch*/,
WriteBatch* /*new_batch*/, WriteBatch* /*new_batch*/,

@ -24,10 +24,10 @@
#pragma once #pragma once
#include <stdint.h>
#include <atomic> #include <atomic>
#include <stack> #include <stack>
#include <string> #include <string>
#include <stdint.h>
#include "rocksdb/status.h" #include "rocksdb/status.h"
#include "rocksdb/write_batch_base.h" #include "rocksdb/write_batch_base.h"

Loading…
Cancel
Save