2013-11-18 19:12:08 +01:00
|
|
|
// Copyright (c) 2013, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
2011-03-18 23:37:00 +01:00
|
|
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
|
|
|
|
2013-08-23 17:38:13 +02:00
|
|
|
#ifndef STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_
|
|
|
|
#define STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
#include <stddef.h>
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
#include <stdint.h>
|
2012-09-06 02:44:13 +02:00
|
|
|
#include <string>
|
2013-01-20 11:07:13 +01:00
|
|
|
#include <memory>
|
2013-01-24 19:54:26 +01:00
|
|
|
#include <vector>
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
#include <limits>
|
2012-10-23 22:30:14 +02:00
|
|
|
#include <stdint.h>
|
2014-09-17 21:46:32 +02:00
|
|
|
#include <unordered_map>
|
2013-10-16 20:50:50 +02:00
|
|
|
|
2014-05-02 01:28:23 +02:00
|
|
|
#include "rocksdb/version.h"
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
#include "rocksdb/listener.h"
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/universal_compaction.h"
|
2013-08-13 23:04:56 +02:00
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2011-03-18 23:37:00 +01:00
|
|
|
|
|
|
|
class Cache;
|
2013-11-08 06:27:21 +01:00
|
|
|
class CompactionFilter;
|
|
|
|
class CompactionFilterFactory;
|
2014-01-10 02:52:11 +01:00
|
|
|
class CompactionFilterFactoryV2;
|
2011-03-18 23:37:00 +01:00
|
|
|
class Comparator;
|
|
|
|
class Env;
|
2014-03-05 03:10:14 +01:00
|
|
|
enum InfoLogLevel : unsigned char;
|
2012-04-17 17:36:46 +02:00
|
|
|
class FilterPolicy;
|
2011-07-21 04:40:18 +02:00
|
|
|
class Logger;
|
2013-03-21 23:59:47 +01:00
|
|
|
class MergeOperator;
|
2011-03-18 23:37:00 +01:00
|
|
|
class Snapshot;
|
2013-10-29 01:54:09 +01:00
|
|
|
class TableFactory;
|
2014-01-25 01:15:05 +01:00
|
|
|
class MemTableRepFactory;
|
TablePropertiesCollectorFactory
Summary:
This diff addresses task #4296714 and rethinks how users provide us with TablePropertiesCollectors as part of Options.
Here's description of task #4296714:
I'm debugging #4295529 and noticed that our count of user properties kDeletedKeys is wrong. We're sharing one single InternalKeyPropertiesCollector with all Table Builders. In LOG Files, we're outputting number of kDeletedKeys as connected with a single table, while it's actually the total count of deleted keys since creation of the DB.
For example, this table has 3155 entries and 1391828 deleted keys.
The problem with current approach that we call methods on a single TablePropertiesCollector for all the tables we create. Even worse, we could do it from multiple threads at the same time and TablePropertiesCollector has no way of knowing which table we're calling it for.
Good part: Looks like nobody inside Facebook is using Options::table_properties_collectors. This means we should be able to painfully change the API.
In this change, I introduce TablePropertiesCollectorFactory. For every table we create, we call `CreateTablePropertiesCollector`, which creates a TablePropertiesCollector for a single table. We then use it sequentially from a single thread, which means it doesn't have to be thread-safe.
Test Plan:
Added a test in table_properties_collector_test that fails on master (build two tables, assert that kDeletedKeys count is correct for the second one).
Also, all other tests
Reviewers: sdong, dhruba, haobo, kailiu
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D18579
2014-05-13 21:30:55 +02:00
|
|
|
class TablePropertiesCollectorFactory;
|
generic rate limiter
Summary:
A generic rate limiter that can be shared by threads and rocksdb
instances. Will use this to smooth out write traffic generated by
compaction and flush. This will help us get better p99 behavior on flash
storage.
Test Plan:
unit test output
==== Test RateLimiterTest.Rate
request size [1 - 1023], limit 10 KB/sec, actual rate: 10.374969 KB/sec, elapsed 2002265
request size [1 - 2047], limit 20 KB/sec, actual rate: 20.771242 KB/sec, elapsed 2002139
request size [1 - 4095], limit 40 KB/sec, actual rate: 41.285299 KB/sec, elapsed 2202424
request size [1 - 8191], limit 80 KB/sec, actual rate: 81.371605 KB/sec, elapsed 2402558
request size [1 - 16383], limit 160 KB/sec, actual rate: 162.541268 KB/sec, elapsed 3303500
Reviewers: yhchiang, igor, sdong
Reviewed By: sdong
Subscribers: leveldb
Differential Revision: https://reviews.facebook.net/D19359
2014-07-08 20:41:57 +02:00
|
|
|
class RateLimiter;
|
2014-01-25 01:15:05 +01:00
|
|
|
class Slice;
|
|
|
|
class SliceTransform;
|
|
|
|
class Statistics;
|
2014-01-27 22:53:22 +01:00
|
|
|
class InternalKeyComparator;
|
2013-01-20 11:07:13 +01:00
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// DB contents are stored in a set of blocks, each of which holds a
|
|
|
|
// sequence of key,value pairs. Each block may be compressed before
|
|
|
|
// being stored in a file. The following enum describes which
|
|
|
|
// compression method (if any) is used to compress a block.
|
2013-09-02 08:23:40 +02:00
|
|
|
enum CompressionType : char {
|
2011-03-18 23:37:00 +01:00
|
|
|
// NOTE: do not change the values of existing entries, as these are
|
|
|
|
// part of the persistent format on disk.
|
2014-02-08 03:12:30 +01:00
|
|
|
kNoCompression = 0x0, kSnappyCompression = 0x1, kZlibCompression = 0x2,
|
|
|
|
kBZip2Compression = 0x3, kLZ4Compression = 0x4, kLZ4HCCompression = 0x5
|
2011-03-18 23:37:00 +01:00
|
|
|
};
|
|
|
|
|
2013-09-02 08:23:40 +02:00
|
|
|
enum CompactionStyle : char {
|
2014-11-27 00:45:11 +01:00
|
|
|
// level based compaction style
|
|
|
|
kCompactionStyleLevel = 0x0,
|
|
|
|
// Universal compaction style
|
|
|
|
// Not supported in ROCKSDB_LITE.
|
|
|
|
kCompactionStyleUniversal = 0x1,
|
|
|
|
// FIFO compaction style
|
|
|
|
// Not supported in ROCKSDB_LITE
|
|
|
|
kCompactionStyleFIFO = 0x2,
|
|
|
|
// Disable background compaction. Compaction jobs are submitted
|
|
|
|
// via CompactFiles().
|
|
|
|
// Not supported in ROCKSDB_LITE
|
|
|
|
kCompactionStyleNone = 0x3,
|
2014-05-21 20:43:35 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
struct CompactionOptionsFIFO {
|
|
|
|
// once the total sum of table files reaches this, we will delete the oldest
|
|
|
|
// table file
|
|
|
|
// Default: 1GB
|
|
|
|
uint64_t max_table_files_size;
|
|
|
|
|
|
|
|
CompactionOptionsFIFO() : max_table_files_size(1 * 1024 * 1024 * 1024) {}
|
2013-07-04 00:32:49 +02:00
|
|
|
};
|
|
|
|
|
2012-11-01 18:50:08 +01:00
|
|
|
// Compression options for different compression algorithms like Zlib
|
|
|
|
struct CompressionOptions {
|
|
|
|
int window_bits;
|
|
|
|
int level;
|
|
|
|
int strategy;
|
2014-01-09 00:06:07 +01:00
|
|
|
CompressionOptions() : window_bits(-14), level(-1), strategy(0) {}
|
2014-04-11 02:18:55 +02:00
|
|
|
CompressionOptions(int wbits, int _lev, int _strategy)
|
|
|
|
: window_bits(wbits), level(_lev), strategy(_strategy) {}
|
2012-11-01 18:50:08 +01:00
|
|
|
};
|
|
|
|
|
Allow callback to change size of existing value. Change return type of the callback function to an enum status to handle 3 cases.
Summary:
This diff fixes 2 hacks:
* The callback function can modify the existing value inplace, if the merged value fits within the existing buffer size. But currently the existing buffer size is not being modified. Now the callback recieves a int* allowing the size to be modified. Since size is encoded as a varint in the internal key for memtable. It might happen that the entire value might have be copied to the new location if the new size varint is smaller than the existing size varint.
* The callback function has 3 functionalities
1. Modify existing buffer inplace, and update size correspondingly. Now to indicate that, Returns 1.
2. Generate a new buffer indicating merged value. Returns 2.
3. Fails to do either of above, based on whatever application logic. Returns 0.
Test Plan: Just make all for now. I'm adding another unit test to test each scenario.
Reviewers: dhruba, haobo
Reviewed By: haobo
CC: leveldb, sdong, kailiu, xinyaohu, sumeet, danguo
Differential Revision: https://reviews.facebook.net/D15195
2014-01-17 00:11:19 +01:00
|
|
|
enum UpdateStatus { // Return status For inplace update callback
|
|
|
|
UPDATE_FAILED = 0, // Nothing to update
|
|
|
|
UPDATED_INPLACE = 1, // Value updated inplace
|
|
|
|
UPDATED = 2, // No inplace update. Merged value set
|
|
|
|
};
|
|
|
|
|
2014-07-15 00:34:30 +02:00
|
|
|
struct DbPath {
|
|
|
|
std::string path;
|
|
|
|
uint64_t target_size; // Target size of total files under the path, in byte.
|
|
|
|
|
|
|
|
DbPath() : target_size(0) {}
|
|
|
|
DbPath(const std::string& p, uint64_t t) : path(p), target_size(t) {}
|
|
|
|
};
|
|
|
|
|
2014-01-06 22:31:06 +01:00
|
|
|
struct Options;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
struct ColumnFamilyOptions {
|
2014-05-10 19:49:33 +02:00
|
|
|
// Some functions that make it easier to optimize RocksDB
|
|
|
|
|
|
|
|
// Use this if you don't need to keep the data sorted, i.e. you'll never use
|
|
|
|
// an iterator, only Put() and Get() API calls
|
2014-11-27 00:45:11 +01:00
|
|
|
//
|
|
|
|
// Not supported in ROCKSDB_LITE
|
2014-08-26 23:15:00 +02:00
|
|
|
ColumnFamilyOptions* OptimizeForPointLookup(
|
|
|
|
uint64_t block_cache_size_mb);
|
2014-05-10 19:49:33 +02:00
|
|
|
|
|
|
|
// Default values for some parameters in ColumnFamilyOptions are not
|
|
|
|
// optimized for heavy workloads and big datasets, which means you might
|
|
|
|
// observe write stalls under some conditions. As a starting point for tuning
|
|
|
|
// RocksDB options, use the following two functions:
|
|
|
|
// * OptimizeLevelStyleCompaction -- optimizes level style compaction
|
|
|
|
// * OptimizeUniversalStyleCompaction -- optimizes universal style compaction
|
|
|
|
// Universal style compaction is focused on reducing Write Amplification
|
|
|
|
// Factor for big data sets, but increases Space Amplification. You can learn
|
|
|
|
// more about the different styles here:
|
|
|
|
// https://github.com/facebook/rocksdb/wiki/Rocksdb-Architecture-Guide
|
2014-05-10 20:25:56 +02:00
|
|
|
// Make sure to also call IncreaseParallelism(), which will provide the
|
|
|
|
// biggest performance gains.
|
2014-05-10 19:49:33 +02:00
|
|
|
// Note: we might use more memory than memtable_memory_budget during high
|
|
|
|
// write rate period
|
2014-11-27 00:45:11 +01:00
|
|
|
//
|
|
|
|
// OptimizeUniversalStyleCompaction is not supported in ROCKSDB_LITE
|
2014-05-10 19:49:33 +02:00
|
|
|
ColumnFamilyOptions* OptimizeLevelStyleCompaction(
|
|
|
|
uint64_t memtable_memory_budget = 512 * 1024 * 1024);
|
|
|
|
ColumnFamilyOptions* OptimizeUniversalStyleCompaction(
|
|
|
|
uint64_t memtable_memory_budget = 512 * 1024 * 1024);
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// -------------------
|
|
|
|
// Parameters that affect behavior
|
|
|
|
|
|
|
|
// Comparator used to define the order of keys in the table.
|
|
|
|
// Default: a comparator that uses lexicographic byte-wise ordering
|
|
|
|
//
|
|
|
|
// REQUIRES: The client must ensure that the comparator supplied
|
|
|
|
// here has the same name and orders keys *exactly* the same as the
|
|
|
|
// comparator provided to previous open calls on the same DB.
|
|
|
|
const Comparator* comparator;
|
|
|
|
|
2013-03-21 23:59:47 +01:00
|
|
|
// REQUIRES: The client must provide a merge operator if Merge operation
|
|
|
|
// needs to be accessed. Calling Merge on a DB without a merge operator
|
|
|
|
// would result in Status::NotSupported. The client must ensure that the
|
|
|
|
// merge operator supplied here has the same name and *exactly* the same
|
|
|
|
// semantics as the merge operator provided to previous open calls on
|
|
|
|
// the same DB. The only exception is reserved for upgrade, where a DB
|
|
|
|
// previously without a merge operator is introduced to Merge operation
|
|
|
|
// for the first time. It's necessary to specify a merge operator when
|
|
|
|
// openning the DB in this case.
|
|
|
|
// Default: nullptr
|
2014-07-08 21:31:49 +02:00
|
|
|
std::shared_ptr<MergeOperator> merge_operator;
|
2013-03-21 23:59:47 +01:00
|
|
|
|
2013-12-02 23:59:23 +01:00
|
|
|
// A single CompactionFilter instance to call into during compaction.
|
2013-05-12 11:36:59 +02:00
|
|
|
// Allows an application to modify/delete a key-value during background
|
|
|
|
// compaction.
|
2013-12-02 23:59:23 +01:00
|
|
|
//
|
|
|
|
// If the client requires a new compaction filter to be used for different
|
|
|
|
// compaction runs, it can specify compaction_filter_factory instead of this
|
|
|
|
// option. The client should specify only one of the two.
|
2013-08-13 19:56:20 +02:00
|
|
|
// compaction_filter takes precedence over compaction_filter_factory if
|
|
|
|
// client specifies both.
|
2013-12-02 23:59:23 +01:00
|
|
|
//
|
|
|
|
// If multithreaded compaction is being used, the supplied CompactionFilter
|
|
|
|
// instance may be used from different threads concurrently and so should be
|
|
|
|
// thread-safe.
|
|
|
|
//
|
2013-05-12 11:36:59 +02:00
|
|
|
// Default: nullptr
|
|
|
|
const CompactionFilter* compaction_filter;
|
|
|
|
|
2013-12-02 23:59:23 +01:00
|
|
|
// This is a factory that provides compaction filter objects which allow
|
|
|
|
// an application to modify/delete a key-value during background compaction.
|
|
|
|
//
|
|
|
|
// A new filter will be created on each compaction run. If multithreaded
|
|
|
|
// compaction is being used, each created CompactionFilter will only be used
|
|
|
|
// from a single thread and so does not need to be thread-safe.
|
|
|
|
//
|
|
|
|
// Default: a factory that doesn't provide any object
|
|
|
|
std::shared_ptr<CompactionFilterFactory> compaction_filter_factory;
|
|
|
|
|
2014-01-10 02:52:11 +01:00
|
|
|
// Version TWO of the compaction_filter_factory
|
|
|
|
// It supports rolling compaction
|
2014-03-27 16:22:59 +01:00
|
|
|
//
|
|
|
|
// Default: a factory that doesn't provide any object
|
2014-01-10 02:52:11 +01:00
|
|
|
std::shared_ptr<CompactionFilterFactoryV2> compaction_filter_factory_v2;
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// -------------------
|
|
|
|
// Parameters that affect performance
|
|
|
|
|
2011-04-12 21:38:58 +02:00
|
|
|
// Amount of data to build up in memory (backed by an unsorted log
|
|
|
|
// on disk) before converting to a sorted on-disk file.
|
2011-03-18 23:37:00 +01:00
|
|
|
//
|
2011-04-12 21:38:58 +02:00
|
|
|
// Larger values increase performance, especially during bulk loads.
|
2012-11-29 01:42:36 +01:00
|
|
|
// Up to max_write_buffer_number write buffers may be held in memory
|
2012-10-19 23:00:53 +02:00
|
|
|
// at the same time,
|
2011-04-12 21:38:58 +02:00
|
|
|
// so you may wish to adjust this parameter to control memory usage.
|
2011-07-15 02:20:57 +02:00
|
|
|
// Also, a larger write buffer will result in a longer recovery time
|
|
|
|
// the next time the database is opened.
|
2011-03-18 23:37:00 +01:00
|
|
|
//
|
2014-12-02 21:09:20 +01:00
|
|
|
// Note that write_buffer_size is enforced per column family.
|
|
|
|
// See db_write_buffer_size for sharing memory across column families.
|
|
|
|
//
|
2011-04-12 21:38:58 +02:00
|
|
|
// Default: 4MB
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2011-03-18 23:37:00 +01:00
|
|
|
size_t write_buffer_size;
|
|
|
|
|
2012-10-19 23:00:53 +02:00
|
|
|
// The maximum number of write buffers that are built up in memory.
|
2014-06-17 01:26:46 +02:00
|
|
|
// The default and the minimum number is 2, so that when 1 write buffer
|
|
|
|
// is being flushed to storage, new writes can continue to the other
|
|
|
|
// write buffer.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
2012-10-19 23:00:53 +02:00
|
|
|
// Default: 2
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-10-19 23:00:53 +02:00
|
|
|
int max_write_buffer_number;
|
|
|
|
|
2013-06-11 23:23:58 +02:00
|
|
|
// The minimum number of write buffers that will be merged together
|
2013-07-09 20:16:39 +02:00
|
|
|
// before writing to storage. If set to 1, then
|
2013-06-11 23:23:58 +02:00
|
|
|
// all write buffers are fushed to L0 as individual files and this increases
|
|
|
|
// read amplification because a get request has to check in all of these
|
|
|
|
// files. Also, an in-memory merge may result in writing lesser
|
|
|
|
// data to storage if there are duplicate records in each of these
|
|
|
|
// individual write buffers. Default: 1
|
|
|
|
int min_write_buffer_number_to_merge;
|
|
|
|
|
2012-08-29 21:29:43 +02:00
|
|
|
// Compress blocks using the specified compression algorithm. This
|
|
|
|
// parameter can be changed dynamically.
|
|
|
|
//
|
|
|
|
// Default: kSnappyCompression, which gives lightweight but fast
|
|
|
|
// compression.
|
|
|
|
//
|
|
|
|
// Typical speeds of kSnappyCompression on an Intel(R) Core(TM)2 2.4GHz:
|
|
|
|
// ~200-500MB/s compression
|
|
|
|
// ~400-800MB/s decompression
|
|
|
|
// Note that these speeds are significantly faster than most
|
|
|
|
// persistent storage speeds, and therefore it is typically never
|
|
|
|
// worth switching to kNoCompression. Even if the input data is
|
|
|
|
// incompressible, the kSnappyCompression implementation will
|
|
|
|
// efficiently detect that and will switch to uncompressed mode.
|
|
|
|
CompressionType compression;
|
|
|
|
|
2012-10-28 07:13:17 +01:00
|
|
|
// Different levels can have different compression policies. There
|
2014-09-10 00:20:49 +02:00
|
|
|
// are cases where most lower levels would like to use quick compression
|
|
|
|
// algorithms while the higher levels (which have more data) use
|
2012-10-28 07:13:17 +01:00
|
|
|
// compression algorithms that have better compression but could
|
2014-09-10 00:20:49 +02:00
|
|
|
// be slower. This array, if non-empty, should have an entry for
|
|
|
|
// each level of the database; these override the value specified in
|
|
|
|
// the previous field 'compression'.
|
2015-03-10 20:35:15 +01:00
|
|
|
//
|
|
|
|
// NOTICE if level_compaction_dynamic_level_bytes=true,
|
|
|
|
// compression_per_level[0] still determines L0, but other elements
|
|
|
|
// of the array are based on base level (the level L0 files are merged
|
|
|
|
// to), and may not match the level users see from info log for metadata.
|
|
|
|
// If L0 files are merged to level-n, then, for i>0, compression_per_level[i]
|
|
|
|
// determines compaction type for level n+i-1.
|
|
|
|
// For example, if we have three 5 levels, and we determine to merge L0
|
|
|
|
// data to L4 (which means L1..L3 will be empty), then the new files go to
|
|
|
|
// L4 uses compression type compression_per_level[1].
|
|
|
|
// If now L0 is merged to L2. Data goes to L2 will be compressed
|
|
|
|
// according to compression_per_level[1], L3 using compression_per_level[2]
|
|
|
|
// and L4 using compression_per_level[3]. Compaction for each level can
|
|
|
|
// change when data grows.
|
2013-01-24 19:54:26 +01:00
|
|
|
std::vector<CompressionType> compression_per_level;
|
2012-10-28 07:13:17 +01:00
|
|
|
|
2014-01-09 00:06:07 +01:00
|
|
|
// different options for compression algorithms
|
2012-11-01 18:50:08 +01:00
|
|
|
CompressionOptions compression_opts;
|
|
|
|
|
2013-08-13 23:04:56 +02:00
|
|
|
// If non-nullptr, use the specified function to determine the
|
|
|
|
// prefixes for keys. These prefixes will be placed in the filter.
|
|
|
|
// Depending on the workload, this can reduce the number of read-IOP
|
|
|
|
// cost for scans when a prefix is passed via ReadOptions to
|
|
|
|
// db.NewIterator(). For prefix filtering to work properly,
|
|
|
|
// "prefix_extractor" and "comparator" must be such that the following
|
|
|
|
// properties hold:
|
|
|
|
//
|
|
|
|
// 1) key.starts_with(prefix(key))
|
|
|
|
// 2) Compare(prefix(key), key) <= 0.
|
|
|
|
// 3) If Compare(k1, k2) <= 0, then Compare(prefix(k1), prefix(k2)) <= 0
|
|
|
|
// 4) prefix(prefix(key)) == prefix(key)
|
|
|
|
//
|
|
|
|
// Default: nullptr
|
2014-03-10 20:56:46 +01:00
|
|
|
std::shared_ptr<const SliceTransform> prefix_extractor;
|
2013-08-13 23:04:56 +02:00
|
|
|
|
2012-06-23 04:30:03 +02:00
|
|
|
// Number of levels for this database
|
|
|
|
int num_levels;
|
|
|
|
|
|
|
|
// Number of files to trigger level-0 compaction. A value <0 means that
|
|
|
|
// level-0 compaction will not be triggered by number of files at all.
|
2014-04-11 21:48:38 +02:00
|
|
|
//
|
|
|
|
// Default: 4
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-06-23 04:30:03 +02:00
|
|
|
int level0_file_num_compaction_trigger;
|
|
|
|
|
2013-08-01 01:20:48 +02:00
|
|
|
// Soft limit on number of level-0 files. We start slowing down writes at this
|
|
|
|
// point. A value <0 means that no writing slow down will be triggered by
|
|
|
|
// number of files in level-0.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-06-23 04:30:03 +02:00
|
|
|
int level0_slowdown_writes_trigger;
|
|
|
|
|
|
|
|
// Maximum number of level-0 files. We stop writes at this point.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-06-23 04:30:03 +02:00
|
|
|
int level0_stop_writes_trigger;
|
|
|
|
|
|
|
|
// Maximum level to which a new compacted memtable is pushed if it
|
|
|
|
// does not create overlap. We try to push to level 2 to avoid the
|
|
|
|
// relatively expensive level 0=>1 compactions and to avoid some
|
|
|
|
// expensive manifest file operations. We do not push all the way to
|
|
|
|
// the largest level since that can generate a lot of wasted disk
|
|
|
|
// space if the same key space is being repeatedly overwritten.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-06-23 04:30:03 +02:00
|
|
|
int max_mem_compaction_level;
|
|
|
|
|
2012-09-18 00:16:49 +02:00
|
|
|
// Target file size for compaction.
|
|
|
|
// target_file_size_base is per-file size for level-1.
|
|
|
|
// Target file size for level L can be calculated by
|
|
|
|
// target_file_size_base * (target_file_size_multiplier ^ (L-1))
|
|
|
|
// For example, if target_file_size_base is 2MB and
|
|
|
|
// target_file_size_multiplier is 10, then each file on level-1 will
|
|
|
|
// be 2MB, and each file on level 2 will be 20MB,
|
|
|
|
// and each file on level-3 will be 200MB.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Default: 2MB.
|
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-09-22 20:15:03 +02:00
|
|
|
uint64_t target_file_size_base;
|
2014-12-04 19:34:06 +01:00
|
|
|
|
2014-11-05 01:23:45 +01:00
|
|
|
// By default target_file_size_multiplier is 1, which means
|
2012-09-18 00:16:49 +02:00
|
|
|
// by default files in different levels will have similar size.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-06-23 04:30:03 +02:00
|
|
|
int target_file_size_multiplier;
|
|
|
|
|
2012-09-18 00:16:49 +02:00
|
|
|
// Control maximum total data size for a level.
|
|
|
|
// max_bytes_for_level_base is the max total for level-1.
|
|
|
|
// Maximum number of bytes for level L can be calculated as
|
|
|
|
// (max_bytes_for_level_base) * (max_bytes_for_level_multiplier ^ (L-1))
|
|
|
|
// For example, if max_bytes_for_level_base is 20MB, and if
|
|
|
|
// max_bytes_for_level_multiplier is 10, total data size for level-1
|
|
|
|
// will be 20MB, total file size for level-2 will be 200MB,
|
|
|
|
// and total file size for level-3 will be 2GB.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Default: 10MB.
|
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-11-09 03:45:19 +01:00
|
|
|
uint64_t max_bytes_for_level_base;
|
2014-12-04 19:34:06 +01:00
|
|
|
|
options.level_compaction_dynamic_level_bytes to allow RocksDB to pick size bases of levels dynamically.
Summary:
When having fixed max_bytes_for_level_base, the ratio of size of largest level and the second one can range from 0 to the multiplier. This makes LSM tree frequently irregular and unpredictable. It can also cause poor space amplification in some cases.
In this improvement (proposed by Igor Kabiljo), we introduce a parameter option.level_compaction_use_dynamic_max_bytes. When turning it on, RocksDB is free to pick a level base in the range of (options.max_bytes_for_level_base/options.max_bytes_for_level_multiplier, options.max_bytes_for_level_base] so that real level ratios are close to options.max_bytes_for_level_multiplier.
Test Plan: New unit tests and pass tests suites including valgrind.
Reviewers: MarkCallaghan, rven, yhchiang, igor, ikabiljo
Reviewed By: ikabiljo
Subscribers: yoshinorim, ikabiljo, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D31437
2015-02-05 20:44:17 +01:00
|
|
|
// If true, RocksDB will pick target size of each level dynamically.
|
|
|
|
// We will pick a base level b >= 1. L0 will be directly merged into level b,
|
|
|
|
// instead of always into level 1. Level 1 to b-1 need to be empty.
|
|
|
|
// We try to pick b and its target size so that
|
|
|
|
// 1. target size is in the range of
|
|
|
|
// (max_bytes_for_level_base / max_bytes_for_level_multiplier,
|
|
|
|
// max_bytes_for_level_base]
|
|
|
|
// 2. target size of the last level (level num_levels-1) equals to extra size
|
|
|
|
// of the level.
|
|
|
|
// At the same time max_bytes_for_level_multiplier and
|
|
|
|
// max_bytes_for_level_multiplier_additional are still satisfied.
|
|
|
|
//
|
|
|
|
// With this option on, from an empty DB, we make last level the base level,
|
|
|
|
// which means merging L0 data into the last level, until it exceeds
|
|
|
|
// max_bytes_for_level_base. And then we make the second last level to be
|
|
|
|
// base level, to start to merge L0 data to second last level, with its
|
|
|
|
// target size to be 1/max_bytes_for_level_multiplier of the last level's
|
|
|
|
// extra size. After the data accumulates more so that we need to move the
|
|
|
|
// base level to the third last one, and so on.
|
|
|
|
//
|
|
|
|
// For example, assume max_bytes_for_level_multiplier=10, num_levels=6,
|
|
|
|
// and max_bytes_for_level_base=10MB.
|
|
|
|
// Target sizes of level 1 to 5 starts with:
|
|
|
|
// [- - - - 10MB]
|
|
|
|
// with base level is level. Target sizes of level 1 to 4 are not applicable
|
|
|
|
// because they will not be used.
|
|
|
|
// Until the size of Level 5 grows to more than 10MB, say 11MB, we make
|
|
|
|
// base target to level 4 and now the targets looks like:
|
|
|
|
// [- - - 1.1MB 11MB]
|
|
|
|
// While data are accumulated, size targets are tuned based on actual data
|
|
|
|
// of level 5. When level 5 has 50MB of data, the target is like:
|
|
|
|
// [- - - 5MB 50MB]
|
|
|
|
// Until level 5's actual size is more than 100MB, say 101MB. Now if we keep
|
|
|
|
// level 4 to be the base level, its target size needs to be 10.1MB, which
|
|
|
|
// doesn't satisfy the target size range. So now we make level 3 the target
|
|
|
|
// size and the target sizes of the levels look like:
|
|
|
|
// [- - 1.01MB 10.1MB 101MB]
|
|
|
|
// In the same way, while level 5 further grows, all levels' targets grow,
|
|
|
|
// like
|
|
|
|
// [- - 5MB 50MB 500MB]
|
|
|
|
// Until level 5 exceeds 1000MB and becomes 1001MB, we make level 2 the
|
|
|
|
// base level and make levels' target sizes like this:
|
|
|
|
// [- 1.001MB 10.01MB 100.1MB 1001MB]
|
|
|
|
// and go on...
|
|
|
|
//
|
|
|
|
// By doing it, we give max_bytes_for_level_multiplier a priority against
|
|
|
|
// max_bytes_for_level_base, for a more predictable LSM tree shape. It is
|
|
|
|
// useful to limit worse case space amplification.
|
|
|
|
//
|
|
|
|
// max_bytes_for_level_multiplier_additional is ignored with this flag on.
|
|
|
|
//
|
|
|
|
// Turning this feature on or off for an existing DB can cause unexpected
|
|
|
|
// LSM tree structure so it's not recommended.
|
|
|
|
//
|
|
|
|
// NOTE: this option is experimental
|
|
|
|
//
|
|
|
|
// Default: false
|
|
|
|
bool level_compaction_dynamic_level_bytes;
|
|
|
|
|
2014-11-05 01:23:45 +01:00
|
|
|
// Default: 10.
|
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-08-16 00:44:23 +02:00
|
|
|
int max_bytes_for_level_multiplier;
|
2012-06-23 04:30:03 +02:00
|
|
|
|
2013-05-21 20:37:06 +02:00
|
|
|
// Different max-size multipliers for different levels.
|
|
|
|
// These are multiplied by max_bytes_for_level_multiplier to arrive
|
|
|
|
// at the max-size of each level.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
2013-05-21 20:37:06 +02:00
|
|
|
// Default: 1
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2013-05-21 20:37:06 +02:00
|
|
|
std::vector<int> max_bytes_for_level_multiplier_additional;
|
|
|
|
|
2012-08-16 00:44:23 +02:00
|
|
|
// Maximum number of bytes in all compacted files. We avoid expanding
|
|
|
|
// the lower level file set of a compaction if it would make the
|
|
|
|
// total compaction cover more than
|
|
|
|
// (expanded_compaction_factor * targetFileSizeLevel()) many bytes.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-08-16 00:44:23 +02:00
|
|
|
int expanded_compaction_factor;
|
2012-06-23 04:30:03 +02:00
|
|
|
|
2012-11-21 08:07:41 +01:00
|
|
|
// Maximum number of bytes in all source files to be compacted in a
|
2012-11-29 01:42:36 +01:00
|
|
|
// single compaction run. We avoid picking too many files in the
|
2012-11-21 08:07:41 +01:00
|
|
|
// source level so that we do not exceed the total source bytes
|
|
|
|
// for compaction to exceed
|
|
|
|
// (source_compaction_factor * targetFileSizeLevel()) many bytes.
|
|
|
|
// Default:1, i.e. pick maxfilesize amount of data as the source of
|
|
|
|
// a compaction.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-11-21 08:07:41 +01:00
|
|
|
int source_compaction_factor;
|
|
|
|
|
2012-08-16 00:44:23 +02:00
|
|
|
// Control maximum bytes of overlaps in grandparent (i.e., level+2) before we
|
|
|
|
// stop building a single file in a level->level+1 compaction.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2012-08-16 00:44:23 +02:00
|
|
|
int max_grandparent_overlap_factor;
|
2012-06-23 04:30:03 +02:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Puts are delayed 0-1 ms when any level has a compaction score that exceeds
|
|
|
|
// soft_rate_limit. This is ignored when == 0.0.
|
|
|
|
// CONSTRAINT: soft_rate_limit <= hard_rate_limit. If this constraint does not
|
|
|
|
// hold, RocksDB will set soft_rate_limit = hard_rate_limit
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Default: 0 (disabled)
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
double soft_rate_limit;
|
|
|
|
|
|
|
|
// Puts are delayed 1ms at a time when any level has a compaction score that
|
|
|
|
// exceeds hard_rate_limit. This is ignored when <= 1.0.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Default: 0 (disabled)
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
double hard_rate_limit;
|
|
|
|
|
Push- instead of pull-model for managing Write stalls
Summary:
Introducing WriteController, which is a source of truth about per-DB write delays. Let's define an DB epoch as a period where there are no flushes and compactions (i.e. new epoch is started when flush or compaction finishes). Each epoch can either:
* proceed with all writes without delay
* delay all writes by fixed time
* stop all writes
The three modes are recomputed at each epoch change (flush, compaction), rather than on every write (which is currently the case).
When we have a lot of column families, our current pull behavior adds a big overhead, since we need to loop over every column family for every write. With new push model, overhead on Write code-path is minimal.
This is just the start. Next step is to also take care of stalls introduced by slow memtable flushes. The final goal is to eliminate function MakeRoomForWrite(), which currently needs to be called for every column family by every write.
Test Plan: make check for now. I'll add some unit tests later. Also, perf test.
Reviewers: dhruba, yhchiang, MarkCallaghan, sdong, ljin
Reviewed By: ljin
Subscribers: leveldb
Differential Revision: https://reviews.facebook.net/D22791
2014-09-08 20:20:25 +02:00
|
|
|
// DEPRECATED -- this options is no longer used
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
unsigned int rate_limit_delay_max_milliseconds;
|
|
|
|
|
2014-01-24 23:30:28 +01:00
|
|
|
// size of one block in arena memory allocation.
|
|
|
|
// If <= 0, a proper value is automatically calculated (usually 1/10 of
|
|
|
|
// writer_buffer_size).
|
|
|
|
//
|
|
|
|
// There are two additonal restriction of the The specified size:
|
|
|
|
// (1) size should be in the range of [4096, 2 << 30] and
|
|
|
|
// (2) be the multiple of the CPU word (which helps with the memory
|
|
|
|
// alignment).
|
|
|
|
//
|
|
|
|
// We'll automatically check and adjust the size number to make sure it
|
|
|
|
// conforms to the restrictions.
|
|
|
|
//
|
|
|
|
// Default: 0
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-01-24 23:30:28 +01:00
|
|
|
size_t arena_block_size;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Disable automatic compactions. Manual compactions can still
|
|
|
|
// be issued on this column family
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
bool disable_auto_compactions;
|
|
|
|
|
|
|
|
// Purge duplicate/deleted keys when a memtable is flushed to storage.
|
|
|
|
// Default: true
|
|
|
|
bool purge_redundant_kvs_while_flush;
|
|
|
|
|
|
|
|
// The compaction style. Default: kCompactionStyleLevel
|
|
|
|
CompactionStyle compaction_style;
|
|
|
|
|
2014-03-11 01:25:10 +01:00
|
|
|
// If true, compaction will verify checksum on every read that happens
|
|
|
|
// as part of compaction
|
2014-11-18 19:20:10 +01:00
|
|
|
//
|
2014-03-11 01:25:10 +01:00
|
|
|
// Default: true
|
2014-11-18 19:20:10 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-03-11 01:25:10 +01:00
|
|
|
bool verify_checksums_in_compaction;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// The options needed to support Universal Style compactions
|
|
|
|
CompactionOptionsUniversal compaction_options_universal;
|
|
|
|
|
2014-05-21 20:43:35 +02:00
|
|
|
// The options for FIFO compaction style
|
|
|
|
CompactionOptionsFIFO compaction_options_fifo;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Use KeyMayExist API to filter deletes when this is true.
|
|
|
|
// If KeyMayExist returns false, i.e. the key definitely does not exist, then
|
|
|
|
// the delete is a noop. KeyMayExist only incurs in-memory look up.
|
|
|
|
// This optimization avoids writing the delete to storage when appropriate.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Default: false
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
bool filter_deletes;
|
|
|
|
|
|
|
|
// An iteration->Next() sequentially skips over keys with the same
|
|
|
|
// user-key unless this option is set. This number specifies the number
|
|
|
|
// of keys (with the same userkey) that will be sequentially
|
|
|
|
// skipped before a reseek is issued.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Default: 8
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
uint64_t max_sequential_skip_in_iterations;
|
|
|
|
|
|
|
|
// This is a factory that provides MemTableRep objects.
|
|
|
|
// Default: a factory that provides a skip-list-based implementation of
|
|
|
|
// MemTableRep.
|
|
|
|
std::shared_ptr<MemTableRepFactory> memtable_factory;
|
|
|
|
|
|
|
|
// This is a factory that provides TableFactory objects.
|
2014-09-04 02:01:34 +02:00
|
|
|
// Default: a block-based table factory that provides a default
|
|
|
|
// implementation of TableBuilder and TableReader with default
|
|
|
|
// BlockBasedTableOptions.
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
std::shared_ptr<TableFactory> table_factory;
|
|
|
|
|
2014-09-04 02:01:34 +02:00
|
|
|
// Block-based table related options are moved to BlockBasedTableOptions.
|
|
|
|
// Related options that were originally here but now moved include:
|
|
|
|
// no_block_cache
|
|
|
|
// block_cache
|
|
|
|
// block_cache_compressed
|
|
|
|
// block_size
|
|
|
|
// block_size_deviation
|
|
|
|
// block_restart_interval
|
|
|
|
// filter_policy
|
|
|
|
// whole_key_filtering
|
|
|
|
// If you'd like to customize some of these options, you will need to
|
|
|
|
// use NewBlockBasedTableFactory() to construct a new table factory.
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// This option allows user to to collect their own interested statistics of
|
|
|
|
// the tables.
|
TablePropertiesCollectorFactory
Summary:
This diff addresses task #4296714 and rethinks how users provide us with TablePropertiesCollectors as part of Options.
Here's description of task #4296714:
I'm debugging #4295529 and noticed that our count of user properties kDeletedKeys is wrong. We're sharing one single InternalKeyPropertiesCollector with all Table Builders. In LOG Files, we're outputting number of kDeletedKeys as connected with a single table, while it's actually the total count of deleted keys since creation of the DB.
For example, this table has 3155 entries and 1391828 deleted keys.
The problem with current approach that we call methods on a single TablePropertiesCollector for all the tables we create. Even worse, we could do it from multiple threads at the same time and TablePropertiesCollector has no way of knowing which table we're calling it for.
Good part: Looks like nobody inside Facebook is using Options::table_properties_collectors. This means we should be able to painfully change the API.
In this change, I introduce TablePropertiesCollectorFactory. For every table we create, we call `CreateTablePropertiesCollector`, which creates a TablePropertiesCollector for a single table. We then use it sequentially from a single thread, which means it doesn't have to be thread-safe.
Test Plan:
Added a test in table_properties_collector_test that fails on master (build two tables, assert that kDeletedKeys count is correct for the second one).
Also, all other tests
Reviewers: sdong, dhruba, haobo, kailiu
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D18579
2014-05-13 21:30:55 +02:00
|
|
|
// Default: empty vector -- no user-defined statistics collection will be
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// performed.
|
TablePropertiesCollectorFactory
Summary:
This diff addresses task #4296714 and rethinks how users provide us with TablePropertiesCollectors as part of Options.
Here's description of task #4296714:
I'm debugging #4295529 and noticed that our count of user properties kDeletedKeys is wrong. We're sharing one single InternalKeyPropertiesCollector with all Table Builders. In LOG Files, we're outputting number of kDeletedKeys as connected with a single table, while it's actually the total count of deleted keys since creation of the DB.
For example, this table has 3155 entries and 1391828 deleted keys.
The problem with current approach that we call methods on a single TablePropertiesCollector for all the tables we create. Even worse, we could do it from multiple threads at the same time and TablePropertiesCollector has no way of knowing which table we're calling it for.
Good part: Looks like nobody inside Facebook is using Options::table_properties_collectors. This means we should be able to painfully change the API.
In this change, I introduce TablePropertiesCollectorFactory. For every table we create, we call `CreateTablePropertiesCollector`, which creates a TablePropertiesCollector for a single table. We then use it sequentially from a single thread, which means it doesn't have to be thread-safe.
Test Plan:
Added a test in table_properties_collector_test that fails on master (build two tables, assert that kDeletedKeys count is correct for the second one).
Also, all other tests
Reviewers: sdong, dhruba, haobo, kailiu
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D18579
2014-05-13 21:30:55 +02:00
|
|
|
typedef std::vector<std::shared_ptr<TablePropertiesCollectorFactory>>
|
|
|
|
TablePropertiesCollectorFactories;
|
|
|
|
TablePropertiesCollectorFactories table_properties_collector_factories;
|
2014-02-07 00:42:16 +01:00
|
|
|
|
2014-07-30 18:32:47 +02:00
|
|
|
// Allows thread-safe inplace updates. If this is true, there is no way to
|
|
|
|
// achieve point-in-time consistency using snapshot or iterator (assuming
|
2015-02-02 23:49:22 +01:00
|
|
|
// concurrent updates). Hence iterator and multi-get will return results
|
|
|
|
// which are not consistent as of any point-in-time.
|
2014-02-07 00:42:16 +01:00
|
|
|
// If inplace_callback function is not set,
|
|
|
|
// Put(key, new_value) will update inplace the existing_value iff
|
|
|
|
// * key exists in current memtable
|
|
|
|
// * new sizeof(new_value) <= sizeof(existing_value)
|
|
|
|
// * existing_value for that key is a put i.e. kTypeValue
|
|
|
|
// If inplace_callback function is set, check doc for inplace_callback.
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Default: false.
|
|
|
|
bool inplace_update_support;
|
|
|
|
|
|
|
|
// Number of locks used for inplace update
|
|
|
|
// Default: 10000, if inplace_update_support = true, else 0.
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
size_t inplace_update_num_locks;
|
|
|
|
|
2014-02-07 00:42:16 +01:00
|
|
|
// existing_value - pointer to previous value (from both memtable and sst).
|
|
|
|
// nullptr if key doesn't exist
|
|
|
|
// existing_value_size - pointer to size of existing_value).
|
|
|
|
// nullptr if key doesn't exist
|
|
|
|
// delta_value - Delta value to be merged with the existing_value.
|
|
|
|
// Stored in transaction logs.
|
|
|
|
// merged_value - Set when delta is applied on the previous value.
|
|
|
|
|
|
|
|
// Applicable only when inplace_update_support is true,
|
|
|
|
// this callback function is called at the time of updating the memtable
|
|
|
|
// as part of a Put operation, lets say Put(key, delta_value). It allows the
|
|
|
|
// 'delta_value' specified as part of the Put operation to be merged with
|
|
|
|
// an 'existing_value' of the key in the database.
|
|
|
|
|
|
|
|
// If the merged value is smaller in size that the 'existing_value',
|
|
|
|
// then this function can update the 'existing_value' buffer inplace and
|
|
|
|
// the corresponding 'existing_value'_size pointer, if it wishes to.
|
|
|
|
// The callback should return UpdateStatus::UPDATED_INPLACE.
|
|
|
|
// In this case. (In this case, the snapshot-semantics of the rocksdb
|
|
|
|
// Iterator is not atomic anymore).
|
|
|
|
|
|
|
|
// If the merged value is larger in size than the 'existing_value' or the
|
|
|
|
// application does not wish to modify the 'existing_value' buffer inplace,
|
|
|
|
// then the merged value should be returned via *merge_value. It is set by
|
|
|
|
// merging the 'existing_value' and the Put 'delta_value'. The callback should
|
|
|
|
// return UpdateStatus::UPDATED in this case. This merged value will be added
|
|
|
|
// to the memtable.
|
|
|
|
|
|
|
|
// If merging fails or the application does not wish to take any action,
|
|
|
|
// then the callback should return UpdateStatus::UPDATE_FAILED.
|
|
|
|
|
|
|
|
// Please remember that the original call from the application is Put(key,
|
|
|
|
// delta_value). So the transaction log (if enabled) will still contain (key,
|
|
|
|
// delta_value). The 'merged_value' is not stored in the transaction log.
|
|
|
|
// Hence the inplace_callback function should be consistent across db reopens.
|
|
|
|
|
|
|
|
// Default: nullptr
|
|
|
|
UpdateStatus (*inplace_callback)(char* existing_value,
|
|
|
|
uint32_t* existing_value_size,
|
|
|
|
Slice delta_value,
|
|
|
|
std::string* merged_value);
|
|
|
|
|
|
|
|
// if prefix_extractor is set and bloom_bits is not 0, create prefix bloom
|
|
|
|
// for memtable
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-02-07 00:42:16 +01:00
|
|
|
uint32_t memtable_prefix_bloom_bits;
|
|
|
|
|
|
|
|
// number of hash probes per key
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-02-07 00:42:16 +01:00
|
|
|
uint32_t memtable_prefix_bloom_probes;
|
|
|
|
|
2014-05-04 22:55:53 +02:00
|
|
|
// Page size for huge page TLB for bloom in memtable. If <=0, not allocate
|
|
|
|
// from huge page TLB but from malloc.
|
|
|
|
// Need to reserve huge pages for it to be allocated. For example:
|
|
|
|
// sysctl -w vm.nr_hugepages=20
|
|
|
|
// See linux doc Documentation/vm/hugetlbpage.txt
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-05-04 22:55:53 +02:00
|
|
|
size_t memtable_prefix_bloom_huge_page_tlb_size;
|
|
|
|
|
2014-03-28 17:21:20 +01:00
|
|
|
// Control locality of bloom filter probes to improve cache miss rate.
|
|
|
|
// This option only applies to memtable prefix bloom and plaintable
|
2014-06-03 01:52:29 +02:00
|
|
|
// prefix bloom. It essentially limits every bloom checking to one cache line.
|
|
|
|
// This optimization is turned off when set to 0, and positive number to turn
|
|
|
|
// it on.
|
2014-03-28 17:21:20 +01:00
|
|
|
// Default: 0
|
|
|
|
uint32_t bloom_locality;
|
|
|
|
|
2014-01-13 18:06:44 +01:00
|
|
|
// Maximum number of successive merge operations on a key in the memtable.
|
|
|
|
//
|
|
|
|
// When a merge operation is added to the memtable and the maximum number of
|
|
|
|
// successive merges is reached, the value of the key will be calculated and
|
|
|
|
// inserted into the memtable instead of the merge operation. This will
|
|
|
|
// ensure that there are never more than max_successive_merges merge
|
|
|
|
// operations in the memtable.
|
|
|
|
//
|
|
|
|
// Default: 0 (disabled)
|
2014-11-05 01:23:45 +01:00
|
|
|
//
|
|
|
|
// Dynamically changeable through SetOptions() API
|
2014-01-13 18:06:44 +01:00
|
|
|
size_t max_successive_merges;
|
|
|
|
|
2014-03-25 01:57:13 +01:00
|
|
|
// The number of partial merge operands to accumulate before partial
|
|
|
|
// merge will be performed. Partial merge will not be called
|
|
|
|
// if the list of values to merge is less than min_partial_merge_operands.
|
|
|
|
//
|
|
|
|
// If min_partial_merge_operands < 2, then it will be treated as 2.
|
|
|
|
//
|
|
|
|
// Default: 2
|
|
|
|
uint32_t min_partial_merge_operands;
|
|
|
|
|
2015-02-17 17:03:45 +01:00
|
|
|
// This flag specifies that the implementation should optimize the filters
|
|
|
|
// mainly for cases where keys are found rather than also optimize for keys
|
|
|
|
// missed. This would be used in cases where the application knows that
|
|
|
|
// there are very few misses or the performance in the case of misses is not
|
|
|
|
// important.
|
|
|
|
//
|
|
|
|
// For now, this flag allows us to not store filters for the last level i.e
|
|
|
|
// the largest level which contains data of the LSM store. For keys which
|
|
|
|
// are hits, the filters in this level are not useful because we will search
|
|
|
|
// for the data anyway. NOTE: the filters in other levels are still useful
|
|
|
|
// even for key hit because they tell us whether to look in that level or go
|
|
|
|
// to the higher level.
|
|
|
|
//
|
|
|
|
// Default: false
|
|
|
|
bool optimize_filters_for_hits;
|
|
|
|
|
2014-11-13 20:39:30 +01:00
|
|
|
#ifndef ROCKSDB_LITE
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
// A vector of EventListeners which call-back functions will be called
|
|
|
|
// when specific RocksDB event happens.
|
|
|
|
std::vector<std::shared_ptr<EventListener>> listeners;
|
2014-11-13 20:39:30 +01:00
|
|
|
#endif // ROCKSDB_LITE
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Create ColumnFamilyOptions with default values for all fields
|
|
|
|
ColumnFamilyOptions();
|
2014-01-06 22:31:06 +01:00
|
|
|
// Create ColumnFamilyOptions from Options
|
|
|
|
explicit ColumnFamilyOptions(const Options& options);
|
2014-02-07 06:39:20 +01:00
|
|
|
|
|
|
|
void Dump(Logger* log) const;
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct DBOptions {
|
2014-05-10 19:49:33 +02:00
|
|
|
// Some functions that make it easier to optimize RocksDB
|
|
|
|
|
2014-11-13 20:39:30 +01:00
|
|
|
#ifndef ROCKSDB_LITE
|
2014-05-10 19:49:33 +02:00
|
|
|
// By default, RocksDB uses only one background thread for flush and
|
|
|
|
// compaction. Calling this function will set it up such that total of
|
|
|
|
// `total_threads` is used. Good value for `total_threads` is the number of
|
|
|
|
// cores. You almost definitely want to call this function if your system is
|
|
|
|
// bottlenecked by RocksDB.
|
|
|
|
DBOptions* IncreaseParallelism(int total_threads = 16);
|
2014-11-13 20:39:30 +01:00
|
|
|
#endif // ROCKSDB_LITE
|
2014-05-10 19:49:33 +02:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// If true, the database will be created if it is missing.
|
|
|
|
// Default: false
|
|
|
|
bool create_if_missing;
|
|
|
|
|
2014-06-07 03:04:56 +02:00
|
|
|
// If true, missing column families will be automatically created.
|
|
|
|
// Default: false
|
|
|
|
bool create_missing_column_families;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// If true, an error is raised if the database already exists.
|
|
|
|
// Default: false
|
|
|
|
bool error_if_exists;
|
|
|
|
|
2014-11-11 15:58:47 +01:00
|
|
|
// If true, RocksDB will aggressively check consistency of the data.
|
|
|
|
// Also, if any of the writes to the database fails (Put, Delete, Merge,
|
|
|
|
// Write), the database will switch to read-only mode and fail all other
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Write operations.
|
2014-11-11 15:58:47 +01:00
|
|
|
// In most cases you want this to be set to true.
|
2014-03-31 21:44:54 +02:00
|
|
|
// Default: true
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
bool paranoid_checks;
|
|
|
|
|
|
|
|
// Use the specified object to interact with the environment,
|
|
|
|
// e.g. to read/write files, schedule background work, etc.
|
|
|
|
// Default: Env::Default()
|
|
|
|
Env* env;
|
|
|
|
|
2014-07-08 21:31:49 +02:00
|
|
|
// Use to control write rate of flush and compaction. Flush has higher
|
|
|
|
// priority than compaction. Rate limiting is disabled if nullptr.
|
2014-08-13 01:42:18 +02:00
|
|
|
// If rate limiter is enabled, bytes_per_sync is set to 1MB by default.
|
2014-07-08 21:31:49 +02:00
|
|
|
// Default: nullptr
|
|
|
|
std::shared_ptr<RateLimiter> rate_limiter;
|
|
|
|
|
2014-02-05 01:31:18 +01:00
|
|
|
// Any internal progress/error information generated by the db will
|
|
|
|
// be written to info_log if it is non-nullptr, or to a file stored
|
|
|
|
// in the same directory as the DB contents if info_log is nullptr.
|
|
|
|
// Default: nullptr
|
2014-07-08 21:31:49 +02:00
|
|
|
std::shared_ptr<Logger> info_log;
|
2014-02-05 01:31:18 +01:00
|
|
|
|
2014-03-06 01:55:51 +01:00
|
|
|
InfoLogLevel info_log_level;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Number of open files that can be used by the DB. You may need to
|
2014-02-07 00:42:16 +01:00
|
|
|
// increase this if your database has a large working set. Value -1 means
|
|
|
|
// files opened are always kept open. You can estimate number of files based
|
|
|
|
// on target_file_size_base and target_file_size_multiplier for level-based
|
|
|
|
// compaction. For universal-style compaction, you can usually set it to -1.
|
2014-03-31 21:44:54 +02:00
|
|
|
// Default: 5000
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
int max_open_files;
|
|
|
|
|
2014-04-30 20:33:40 +02:00
|
|
|
// Once write-ahead logs exceed this size, we will start forcing the flush of
|
|
|
|
// column families whose memtables are backed by the oldest live WAL file
|
|
|
|
// (i.e. the ones that are causing all the space amplification). If set to 0
|
|
|
|
// (default), we will dynamically choose the WAL size limit to be
|
2014-12-08 21:52:18 +01:00
|
|
|
// [sum of all write_buffer_size * max_write_buffer_number] * 4
|
2014-04-30 20:33:40 +02:00
|
|
|
// Default: 0
|
|
|
|
uint64_t max_total_wal_size;
|
|
|
|
|
2014-02-05 01:31:18 +01:00
|
|
|
// If non-null, then we should collect metrics about database operations
|
|
|
|
// Statistics objects should not be shared between DB instances as
|
|
|
|
// it does not use any locks to prevent concurrent updates.
|
2014-07-08 21:31:49 +02:00
|
|
|
std::shared_ptr<Statistics> statistics;
|
2014-02-05 01:31:18 +01:00
|
|
|
|
2014-09-15 20:32:01 +02:00
|
|
|
// If true, then the contents of manifest and data files are not synced
|
2012-08-04 00:20:58 +02:00
|
|
|
// to stable storage. Their contents remain in the OS buffers till the
|
|
|
|
// OS decides to flush them. This option is good for bulk-loading
|
|
|
|
// of data. Once the bulk-loading is complete, please issue a
|
|
|
|
// sync to the OS to flush all dirty buffesrs to stable storage.
|
|
|
|
// Default: false
|
|
|
|
bool disableDataSync;
|
|
|
|
|
2012-08-27 21:10:26 +02:00
|
|
|
// If true, then every store to stable storage will issue a fsync.
|
|
|
|
// If false, then every store to stable storage will issue a fdatasync.
|
|
|
|
// This parameter should be set to true while storing data to
|
2013-11-12 06:02:38 +01:00
|
|
|
// filesystem like ext3 that can lose files after a reboot.
|
2012-08-27 21:10:26 +02:00
|
|
|
// Default: false
|
|
|
|
bool use_fsync;
|
|
|
|
|
2014-07-15 00:34:30 +02:00
|
|
|
// A list of paths where SST files can be put into, with its target size.
|
|
|
|
// Newer data is placed into paths specified earlier in the vector while
|
|
|
|
// older data gradually moves to paths specified later in the vector.
|
|
|
|
//
|
|
|
|
// For example, you have a flash device with 10GB allocated for the DB,
|
|
|
|
// as well as a hard drive of 2TB, you should config it to be:
|
|
|
|
// [{"/flash_path", 10GB}, {"/hard_drive", 2TB}]
|
|
|
|
//
|
|
|
|
// The system will try to guarantee data under each path is close to but
|
|
|
|
// not larger than the target size. But current and future file sizes used
|
|
|
|
// by determining where to place a file are based on best-effort estimation,
|
|
|
|
// which means there is a chance that the actual size under the directory
|
|
|
|
// is slightly more than target size under some workloads. User should give
|
|
|
|
// some buffer room for those cases.
|
|
|
|
//
|
|
|
|
// If none of the paths has sufficient room to place a file, the file will
|
|
|
|
// be placed to the last path anyway, despite to the target size.
|
|
|
|
//
|
|
|
|
// Placing newer data to ealier paths is also best-efforts. User should
|
|
|
|
// expect user files to be placed in higher levels in some extreme cases.
|
|
|
|
//
|
2014-07-02 18:54:20 +02:00
|
|
|
// If left empty, only one path will be used, which is db_name passed when
|
|
|
|
// opening the DB.
|
|
|
|
// Default: empty
|
2014-07-15 00:34:30 +02:00
|
|
|
std::vector<DbPath> db_paths;
|
2014-07-02 18:54:20 +02:00
|
|
|
|
2013-10-01 23:46:52 +02:00
|
|
|
// This specifies the info LOG dir.
|
2012-09-06 02:44:13 +02:00
|
|
|
// If it is empty, the log files will be in the same dir as data.
|
|
|
|
// If it is non empty, the log files will be in the specified dir,
|
|
|
|
// and the db data dir's absolute path will be used as the log file
|
|
|
|
// name's prefix.
|
|
|
|
std::string db_log_dir;
|
|
|
|
|
2013-10-01 23:46:52 +02:00
|
|
|
// This specifies the absolute dir path for write-ahead logs (WAL).
|
|
|
|
// If it is empty, the log files will be in the same dir as data,
|
|
|
|
// dbname is used as the data dir by default
|
|
|
|
// If it is non empty, the log files will be in kept the specified dir.
|
|
|
|
// When destroying the db,
|
|
|
|
// all log files in wal_dir and the dir itself is deleted
|
|
|
|
std::string wal_dir;
|
|
|
|
|
2012-10-16 17:53:46 +02:00
|
|
|
// The periodicity when obsolete files get deleted. The default
|
2013-11-15 03:03:57 +01:00
|
|
|
// value is 6 hours. The files that get out of scope by compaction
|
|
|
|
// process will still get automatically delete on every compaction,
|
|
|
|
// regardless of this setting
|
2012-10-16 17:53:46 +02:00
|
|
|
uint64_t delete_obsolete_files_period_micros;
|
2012-11-29 01:42:36 +01:00
|
|
|
|
2014-02-06 21:59:16 +01:00
|
|
|
// Maximum number of concurrent background compaction jobs, submitted to
|
|
|
|
// the default LOW priority thread pool.
|
|
|
|
// If you're increasing this, also consider increasing number of threads in
|
|
|
|
// LOW priority thread pool. For more information, see
|
|
|
|
// Env::SetBackgroundThreads
|
2012-10-19 23:00:53 +02:00
|
|
|
// Default: 1
|
|
|
|
int max_background_compactions;
|
2012-10-16 17:53:46 +02:00
|
|
|
|
2013-09-13 23:38:37 +02:00
|
|
|
// Maximum number of concurrent background memtable flush jobs, submitted to
|
|
|
|
// the HIGH priority thread pool.
|
2014-02-06 21:59:16 +01:00
|
|
|
//
|
2013-09-13 23:38:37 +02:00
|
|
|
// By default, all background jobs (major compaction and memtable flush) go
|
|
|
|
// to the LOW priority pool. If this option is set to a positive number,
|
|
|
|
// memtable flush jobs will be submitted to the HIGH priority pool.
|
|
|
|
// It is important when the same Env is shared by multiple db instances.
|
|
|
|
// Without a separate pool, long running major compaction jobs could
|
|
|
|
// potentially block memtable flush jobs of other db instances, leading to
|
|
|
|
// unnecessary Put stalls.
|
2014-02-06 21:59:16 +01:00
|
|
|
//
|
|
|
|
// If you're increasing this, also consider increasing number of threads in
|
|
|
|
// HIGH priority thread pool. For more information, see
|
|
|
|
// Env::SetBackgroundThreads
|
|
|
|
// Default: 1
|
2013-09-13 23:38:37 +02:00
|
|
|
int max_background_flushes;
|
|
|
|
|
2012-10-26 23:55:02 +02:00
|
|
|
// Specify the maximal size of the info log file. If the log file
|
|
|
|
// is larger than `max_log_file_size`, a new info log file will
|
|
|
|
// be created.
|
|
|
|
// If max_log_file_size == 0, all logs will be written to one
|
|
|
|
// log file.
|
|
|
|
size_t max_log_file_size;
|
|
|
|
|
2013-02-05 04:42:40 +01:00
|
|
|
// Time for the info log file to roll (in seconds).
|
|
|
|
// If specified with non-zero value, log file will be rolled
|
|
|
|
// if it has been active longer than `log_file_time_to_roll`.
|
|
|
|
// Default: 0 (disabled)
|
|
|
|
size_t log_file_time_to_roll;
|
|
|
|
|
|
|
|
// Maximal info log files to be kept.
|
|
|
|
// Default: 1000
|
|
|
|
size_t keep_log_file_num;
|
|
|
|
|
2013-01-11 02:18:50 +01:00
|
|
|
// manifest file is rolled over on reaching this limit.
|
|
|
|
// The older manifest file be deleted.
|
|
|
|
// The default value is MAX_INT so that roll-over does not take place.
|
|
|
|
uint64_t max_manifest_file_size;
|
|
|
|
|
2014-02-05 01:31:18 +01:00
|
|
|
// Number of shards used for table cache.
|
|
|
|
int table_cache_numshardbits;
|
|
|
|
|
|
|
|
// During data eviction of table's LRU cache, it would be inefficient
|
|
|
|
// to strictly follow LRU because this piece of memory will not really
|
|
|
|
// be released unless its refcount falls to zero. Instead, make two
|
|
|
|
// passes: the first pass will release items with refcount = 1,
|
|
|
|
// and if not enough space releases after scanning the number of
|
|
|
|
// elements specified by this parameter, we will remove items in LRU
|
|
|
|
// order.
|
|
|
|
int table_cache_remove_scan_count_limit;
|
|
|
|
|
2013-11-07 03:46:28 +01:00
|
|
|
// The following two fields affect how archived logs will be deleted.
|
|
|
|
// 1. If both set to 0, logs will be deleted asap and will not get into
|
|
|
|
// the archive.
|
|
|
|
// 2. If WAL_ttl_seconds is 0 and WAL_size_limit_MB is not 0,
|
|
|
|
// WAL files will be checked every 10 min and if total size is greater
|
|
|
|
// then WAL_size_limit_MB, they will be deleted starting with the
|
|
|
|
// earliest until size_limit is met. All empty files will be deleted.
|
|
|
|
// 3. If WAL_ttl_seconds is not 0 and WAL_size_limit_MB is 0, then
|
2013-11-12 06:02:38 +01:00
|
|
|
// WAL files will be checked every WAL_ttl_secondsi / 2 and those that
|
2013-11-07 03:46:28 +01:00
|
|
|
// are older than WAL_ttl_seconds will be deleted.
|
|
|
|
// 4. If both are not 0, WAL files will be checked every 10 min and both
|
|
|
|
// checks will be performed with ttl being first.
|
2012-11-26 22:56:45 +01:00
|
|
|
uint64_t WAL_ttl_seconds;
|
2013-11-07 03:46:28 +01:00
|
|
|
uint64_t WAL_size_limit_MB;
|
2013-01-15 23:05:42 +01:00
|
|
|
|
|
|
|
// Number of bytes to preallocate (via fallocate) the manifest
|
|
|
|
// files. Default is 4mb, which is reasonable to reduce random IO
|
|
|
|
// as well as prevent overallocation for mounts that preallocate
|
|
|
|
// large amounts of data (such as xfs's allocsize option).
|
|
|
|
size_t manifest_preallocation_size;
|
2013-02-28 23:09:30 +01:00
|
|
|
|
2013-03-15 01:00:04 +01:00
|
|
|
// Data being read from file storage may be buffered in the OS
|
|
|
|
// Default: true
|
|
|
|
bool allow_os_buffer;
|
|
|
|
|
2013-06-18 01:13:32 +02:00
|
|
|
// Allow the OS to mmap file for reading sst tables. Default: false
|
2013-03-15 01:00:04 +01:00
|
|
|
bool allow_mmap_reads;
|
|
|
|
|
2014-03-31 21:44:54 +02:00
|
|
|
// Allow the OS to mmap file for writing. Default: false
|
2013-03-15 01:00:04 +01:00
|
|
|
bool allow_mmap_writes;
|
2013-04-10 04:42:07 +02:00
|
|
|
|
|
|
|
// Disable child process inherit open files. Default: true
|
|
|
|
bool is_fd_close_on_exec;
|
2013-05-21 20:53:33 +02:00
|
|
|
|
2015-01-05 22:35:56 +01:00
|
|
|
// DEPRECATED -- this options is no longer used
|
2013-05-21 20:53:33 +02:00
|
|
|
bool skip_log_error_on_recovery;
|
|
|
|
|
2013-10-05 07:32:05 +02:00
|
|
|
// if not zero, dump rocksdb.stats to LOG every stats_dump_period_sec
|
2013-05-11 00:21:04 +02:00
|
|
|
// Default: 3600 (1 hour)
|
|
|
|
unsigned int stats_dump_period_sec;
|
2013-05-15 19:34:02 +02:00
|
|
|
|
2013-05-18 00:53:01 +02:00
|
|
|
// If set true, will hint the underlying file system that the file
|
|
|
|
// access pattern is random, when a sst file is opened.
|
|
|
|
// Default: true
|
|
|
|
bool advise_random_on_open;
|
|
|
|
|
2014-12-02 21:09:20 +01:00
|
|
|
// Amount of data to build up in memtables across all column
|
|
|
|
// families before writing to disk.
|
|
|
|
//
|
|
|
|
// This is distinct from write_buffer_size, which enforces a limit
|
|
|
|
// for a single memtable.
|
|
|
|
//
|
|
|
|
// This feature is disabled by default. Specify a non-zero value
|
|
|
|
// to enable it.
|
|
|
|
//
|
|
|
|
// Default: 0 (disabled)
|
|
|
|
size_t db_write_buffer_size;
|
|
|
|
|
2013-05-18 00:53:01 +02:00
|
|
|
// Specify the file access pattern once a compaction is started.
|
|
|
|
// It will be applied to all input files of a compaction.
|
|
|
|
// Default: NORMAL
|
2014-09-23 23:18:57 +02:00
|
|
|
enum AccessHint {
|
|
|
|
NONE,
|
|
|
|
NORMAL,
|
|
|
|
SEQUENTIAL,
|
|
|
|
WILLNEED
|
|
|
|
};
|
|
|
|
AccessHint access_hint_on_compaction_start;
|
2013-06-01 01:30:17 +02:00
|
|
|
|
|
|
|
// Use adaptive mutex, which spins in the user space before resorting
|
|
|
|
// to kernel. This could reduce context switch when the mutex is not
|
|
|
|
// heavily contended. However, if the mutex is hot, we could end up
|
|
|
|
// wasting spin time.
|
|
|
|
// Default: false
|
|
|
|
bool use_adaptive_mutex;
|
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Create DBOptions with default values for all fields
|
|
|
|
DBOptions();
|
2014-01-06 22:31:06 +01:00
|
|
|
// Create DBOptions from Options
|
|
|
|
explicit DBOptions(const Options& options);
|
2014-02-07 06:39:20 +01:00
|
|
|
|
|
|
|
void Dump(Logger* log) const;
|
2014-08-13 01:42:18 +02:00
|
|
|
|
|
|
|
// Allows OS to incrementally sync files to disk while they are being
|
|
|
|
// written, asynchronously, in the background.
|
|
|
|
// Issue one request for every bytes_per_sync written. 0 turns it off.
|
|
|
|
// Default: 0
|
|
|
|
//
|
|
|
|
// You may consider using rate_limiter to regulate write rate to device.
|
|
|
|
// When rate limiter is enabled, it automatically enables bytes_per_sync
|
|
|
|
// to 1MB.
|
|
|
|
uint64_t bytes_per_sync;
|
2014-11-21 06:13:18 +01:00
|
|
|
|
|
|
|
// If true, then the status of the threads involved in this DB will
|
|
|
|
// be tracked and available via GetThreadList() API.
|
|
|
|
//
|
|
|
|
// Default: false
|
|
|
|
bool enable_thread_tracking;
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
};
|
2013-08-13 19:56:20 +02:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Options to control the behavior of a database (passed to DB::Open)
|
|
|
|
struct Options : public DBOptions, public ColumnFamilyOptions {
|
|
|
|
// Create an Options object with default values for all fields.
|
|
|
|
Options() :
|
|
|
|
DBOptions(),
|
|
|
|
ColumnFamilyOptions() {}
|
2013-10-29 01:54:09 +01:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
Options(const DBOptions& db_options,
|
|
|
|
const ColumnFamilyOptions& column_family_options)
|
|
|
|
: DBOptions(db_options), ColumnFamilyOptions(column_family_options) {}
|
In-place updates for equal keys and similar sized values
Summary:
Currently for each put, a fresh memory is allocated, and a new entry is added to the memtable with a new sequence number irrespective of whether the key already exists in the memtable. This diff is an attempt to update the value inplace for existing keys. It currently handles a very simple case:
1. Key already exists in the current memtable. Does not inplace update values in immutable memtable or snapshot
2. Latest value type is a 'put' ie kTypeValue
3. New value size is less than existing value, to avoid reallocating memory
TODO: For a put of an existing key, deallocate memory take by values, for other value types till a kTypeValue is found, ie. remove kTypeMerge.
TODO: Update the transaction log, to allow consistent reload of the memtable.
Test Plan: Added a unit test verifying the inplace update. But some other unit tests broken due to invalid sequence number checks. WIll fix them next.
Reviewers: xinyaohu, sumeet, haobo, dhruba
CC: leveldb
Differential Revision: https://reviews.facebook.net/D12423
Automatic commit by arc
2013-08-19 23:12:47 +02:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
void Dump(Logger* log) const;
|
In-place updates for equal keys and similar sized values
Summary:
Currently for each put, a fresh memory is allocated, and a new entry is added to the memtable with a new sequence number irrespective of whether the key already exists in the memtable. This diff is an attempt to update the value inplace for existing keys. It currently handles a very simple case:
1. Key already exists in the current memtable. Does not inplace update values in immutable memtable or snapshot
2. Latest value type is a 'put' ie kTypeValue
3. New value size is less than existing value, to avoid reallocating memory
TODO: For a put of an existing key, deallocate memory take by values, for other value types till a kTypeValue is found, ie. remove kTypeMerge.
TODO: Update the transaction log, to allow consistent reload of the memtable.
Test Plan: Added a unit test verifying the inplace update. But some other unit tests broken due to invalid sequence number checks. WIll fix them next.
Reviewers: xinyaohu, sumeet, haobo, dhruba
CC: leveldb
Differential Revision: https://reviews.facebook.net/D12423
Automatic commit by arc
2013-08-19 23:12:47 +02:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// Set appropriate parameters for bulk loading.
|
|
|
|
// The reason that this is a function that returns "this" instead of a
|
|
|
|
// constructor is to enable chaining of multiple similar calls in the future.
|
|
|
|
//
|
2014-03-25 19:09:40 +01:00
|
|
|
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
// All data will be in level 0 without any automatic compaction.
|
|
|
|
// It's recommended to manually call CompactRange(NULL, NULL) before reading
|
|
|
|
// from the database, because otherwise the read can be very slow.
|
|
|
|
Options* PrepareForBulkLoad();
|
2011-03-18 23:37:00 +01:00
|
|
|
};
|
|
|
|
|
2013-08-25 07:48:51 +02:00
|
|
|
//
|
|
|
|
// An application can issue a read request (via Get/Iterators) and specify
|
|
|
|
// if that read should process data that ALREADY resides on a specified cache
|
|
|
|
// level. For example, if an application specifies kBlockCacheTier then the
|
|
|
|
// Get call will process data that is already processed in the memtable or
|
|
|
|
// the block cache. It will not page in data from the OS cache or data that
|
|
|
|
// resides in storage.
|
|
|
|
enum ReadTier {
|
2014-01-09 00:06:07 +01:00
|
|
|
kReadAllTier = 0x0, // data in memtable, block cache, OS cache or storage
|
2013-08-25 07:48:51 +02:00
|
|
|
kBlockCacheTier = 0x1 // data in memtable or block cache
|
|
|
|
};
|
|
|
|
|
2011-03-18 23:37:00 +01:00
|
|
|
// Options that control read operations
|
|
|
|
struct ReadOptions {
|
|
|
|
// If true, all data read from underlying storage will be
|
|
|
|
// verified against corresponding checksums.
|
2014-01-30 23:58:37 +01:00
|
|
|
// Default: true
|
2011-03-18 23:37:00 +01:00
|
|
|
bool verify_checksums;
|
|
|
|
|
2013-11-13 07:46:51 +01:00
|
|
|
// Should the "data block"/"index block"/"filter block" read for this
|
|
|
|
// iteration be cached in memory?
|
2011-03-18 23:37:00 +01:00
|
|
|
// Callers may wish to set this field to false for bulk scans.
|
|
|
|
// Default: true
|
|
|
|
bool fill_cache;
|
|
|
|
|
2013-11-04 01:32:46 +01:00
|
|
|
// If this option is set and memtable implementation allows, Seek
|
|
|
|
// might only return keys with the same prefix as the seek-key
|
2014-04-25 21:21:34 +02:00
|
|
|
//
|
|
|
|
// ! DEPRECATED: prefix_seek is on by default when prefix_extractor
|
|
|
|
// is configured
|
|
|
|
// bool prefix_seek;
|
2013-11-04 01:32:46 +01:00
|
|
|
|
2013-03-01 03:04:58 +01:00
|
|
|
// If "snapshot" is non-nullptr, read as of the supplied snapshot
|
2011-03-18 23:37:00 +01:00
|
|
|
// (which must belong to the DB that is being read and which must
|
2013-03-01 03:04:58 +01:00
|
|
|
// not have been released). If "snapshot" is nullptr, use an impliicit
|
2011-03-18 23:37:00 +01:00
|
|
|
// snapshot of the state at the beginning of this read operation.
|
2013-03-01 03:04:58 +01:00
|
|
|
// Default: nullptr
|
2011-03-18 23:37:00 +01:00
|
|
|
const Snapshot* snapshot;
|
|
|
|
|
2013-08-13 23:04:56 +02:00
|
|
|
// If "prefix" is non-nullptr, and ReadOptions is being passed to
|
|
|
|
// db.NewIterator, only return results when the key begins with this
|
|
|
|
// prefix. This field is ignored by other calls (e.g., Get).
|
|
|
|
// Options.prefix_extractor must also be set, and
|
|
|
|
// prefix_extractor.InRange(prefix) must be true. The iterator
|
|
|
|
// returned by NewIterator when this option is set will behave just
|
|
|
|
// as if the underlying store did not contain any non-matching keys,
|
|
|
|
// with two exceptions. Seek() only accepts keys starting with the
|
|
|
|
// prefix, and SeekToLast() is not supported. prefix filter with this
|
|
|
|
// option will sometimes reduce the number of read IOPs.
|
|
|
|
// Default: nullptr
|
2014-04-25 21:21:34 +02:00
|
|
|
//
|
|
|
|
// ! DEPRECATED
|
|
|
|
// const Slice* prefix;
|
2013-08-13 23:04:56 +02:00
|
|
|
|
2014-09-04 19:48:24 +02:00
|
|
|
// "iterate_upper_bound" defines the extent upto which the forward iterator
|
|
|
|
// can returns entries. Once the bound is reached, Valid() will be false.
|
|
|
|
// "iterate_upper_bound" is exclusive ie the bound value is
|
|
|
|
// not a valid entry. If iterator_extractor is not null, the Seek target
|
|
|
|
// and iterator_upper_bound need to have the same prefix.
|
|
|
|
// This is because ordering is not guaranteed outside of prefix domain.
|
|
|
|
// There is no lower bound on the iterator. If needed, that can be easily
|
|
|
|
// implemented
|
|
|
|
//
|
|
|
|
// Default: nullptr
|
|
|
|
const Slice* iterate_upper_bound;
|
|
|
|
|
2013-08-25 07:48:51 +02:00
|
|
|
// Specify if this read request should process data that ALREADY
|
|
|
|
// resides on a particular cache. If the required data is not
|
2013-08-31 17:40:45 +02:00
|
|
|
// found at the specified cache, then Status::Incomplete is returned.
|
2013-08-25 07:48:51 +02:00
|
|
|
// Default: kReadAllTier
|
|
|
|
ReadTier read_tier;
|
|
|
|
|
2014-01-17 06:56:26 +01:00
|
|
|
// Specify to create a tailing iterator -- a special iterator that has a
|
|
|
|
// view of the complete database (i.e. it can also be used to read newly
|
2014-01-30 23:58:37 +01:00
|
|
|
// added data) and is optimized for sequential reads. It will return records
|
|
|
|
// that were inserted into the database after the creation of the iterator.
|
|
|
|
// Default: false
|
2014-04-15 22:39:26 +02:00
|
|
|
// Not supported in ROCKSDB_LITE mode!
|
2014-01-17 06:56:26 +01:00
|
|
|
bool tailing;
|
|
|
|
|
2015-02-18 20:49:31 +01:00
|
|
|
// Specify to create a managed iterator -- a special iterator that
|
|
|
|
// uses less resources by having the ability to free its underlying
|
|
|
|
// resources on request.
|
|
|
|
// Default: false
|
|
|
|
// Not supported in ROCKSDB_LITE mode!
|
|
|
|
bool managed;
|
|
|
|
|
2014-08-26 01:14:30 +02:00
|
|
|
// Enable a total order seek regardless of index format (e.g. hash index)
|
|
|
|
// used in the table. Some table format (e.g. plain table) may not support
|
|
|
|
// this option.
|
|
|
|
bool total_order_seek;
|
|
|
|
|
2015-02-18 20:49:31 +01:00
|
|
|
ReadOptions();
|
|
|
|
ReadOptions(bool cksum, bool cache);
|
2011-03-18 23:37:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
// Options that control write operations
|
|
|
|
struct WriteOptions {
|
|
|
|
// If true, the write will be flushed from the operating system
|
|
|
|
// buffer cache (by calling WritableFile::Sync()) before the write
|
|
|
|
// is considered complete. If this flag is true, writes will be
|
|
|
|
// slower.
|
|
|
|
//
|
|
|
|
// If this flag is false, and the machine crashes, some recent
|
|
|
|
// writes may be lost. Note that if it is just the process that
|
|
|
|
// crashes (i.e., the machine does not reboot), no writes will be
|
|
|
|
// lost even if sync==false.
|
|
|
|
//
|
2011-04-12 21:38:58 +02:00
|
|
|
// In other words, a DB write with sync==false has similar
|
|
|
|
// crash semantics as the "write()" system call. A DB write
|
|
|
|
// with sync==true has similar crash semantics to a "write()"
|
2013-11-12 06:02:38 +01:00
|
|
|
// system call followed by "fdatasync()".
|
2011-04-12 21:38:58 +02:00
|
|
|
//
|
|
|
|
// Default: false
|
2011-03-18 23:37:00 +01:00
|
|
|
bool sync;
|
|
|
|
|
2012-07-05 22:39:28 +02:00
|
|
|
// If true, writes will not first go to the write ahead log,
|
|
|
|
// and the write may got lost after a crash.
|
|
|
|
bool disableWAL;
|
|
|
|
|
2014-07-04 00:47:02 +02:00
|
|
|
// If non-zero, then associated write waiting longer than the specified
|
|
|
|
// time MAY be aborted and returns Status::TimedOut. A write that takes
|
|
|
|
// less than the specified time is guaranteed to not fail with
|
|
|
|
// Status::TimedOut.
|
|
|
|
//
|
|
|
|
// The number of times a write call encounters a timeout is recorded in
|
|
|
|
// Statistics.WRITE_TIMEDOUT
|
|
|
|
//
|
|
|
|
// Default: 0
|
|
|
|
uint64_t timeout_hint_us;
|
|
|
|
|
2014-09-02 22:29:05 +02:00
|
|
|
// If true and if user is trying to write to column families that don't exist
|
|
|
|
// (they were dropped), ignore the write (don't return an error). If there
|
|
|
|
// are multiple writes in a WriteBatch, other writes will succeed.
|
|
|
|
// Default: false
|
|
|
|
bool ignore_missing_column_families;
|
|
|
|
|
|
|
|
WriteOptions()
|
|
|
|
: sync(false),
|
|
|
|
disableWAL(false),
|
|
|
|
timeout_hint_us(0),
|
|
|
|
ignore_missing_column_families(false) {}
|
2011-03-18 23:37:00 +01:00
|
|
|
};
|
|
|
|
|
2012-07-06 20:42:09 +02:00
|
|
|
// Options that control flush operations
|
|
|
|
struct FlushOptions {
|
|
|
|
// If true, the flush will wait until the flush is done.
|
|
|
|
// Default: true
|
|
|
|
bool wait;
|
|
|
|
|
2014-01-09 00:06:07 +01:00
|
|
|
FlushOptions() : wait(true) {}
|
2012-07-06 20:42:09 +02:00
|
|
|
};
|
|
|
|
|
2014-05-16 19:35:41 +02:00
|
|
|
// Get options based on some guidelines. Now only tune parameter based on
|
|
|
|
// flush/compaction and fill default parameters for other parameters.
|
|
|
|
// total_write_buffer_limit: budget for memory spent for mem tables
|
|
|
|
// read_amplification_threshold: comfortable value of read amplification
|
|
|
|
// write_amplification_threshold: comfortable value of write amplification.
|
|
|
|
// target_db_size: estimated total DB size.
|
|
|
|
extern Options GetOptions(size_t total_write_buffer_limit,
|
|
|
|
int read_amplification_threshold = 8,
|
|
|
|
int write_amplification_threshold = 32,
|
|
|
|
uint64_t target_db_size = 68719476736 /* 64GB */);
|
2014-09-17 21:46:32 +02:00
|
|
|
|
CompactFiles, EventListener and GetDatabaseMetaData
Summary:
This diff adds three sets of APIs to RocksDB.
= GetColumnFamilyMetaData =
* This APIs allow users to obtain the current state of a RocksDB instance on one column family.
* See GetColumnFamilyMetaData in include/rocksdb/db.h
= EventListener =
* A virtual class that allows users to implement a set of
call-back functions which will be called when specific
events of a RocksDB instance happens.
* To register EventListener, simply insert an EventListener to ColumnFamilyOptions::listeners
= CompactFiles =
* CompactFiles API inputs a set of file numbers and an output level, and RocksDB
will try to compact those files into the specified level.
= Example =
* Example code can be found in example/compact_files_example.cc, which implements
a simple external compactor using EventListener, GetColumnFamilyMetaData, and
CompactFiles API.
Test Plan:
listener_test
compactor_test
example/compact_files_example
export ROCKSDB_TESTS=CompactFiles
db_test
export ROCKSDB_TESTS=MetaData
db_test
Reviewers: ljin, igor, rven, sdong
Reviewed By: sdong
Subscribers: MarkCallaghan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D24705
2014-11-07 23:45:18 +01:00
|
|
|
// CompactionOptions are used in CompactFiles() call.
|
|
|
|
struct CompactionOptions {
|
|
|
|
// Compaction output compression type
|
|
|
|
// Default: snappy
|
|
|
|
CompressionType compression;
|
|
|
|
// Compaction will create files of size `output_file_size_limit`.
|
|
|
|
// Default: MAX, which means that compaction will create a single file
|
|
|
|
uint64_t output_file_size_limit;
|
|
|
|
|
|
|
|
CompactionOptions()
|
|
|
|
: compression(kSnappyCompression),
|
|
|
|
output_file_size_limit(std::numeric_limits<uint64_t>::max()) {}
|
|
|
|
};
|
2013-10-04 06:49:15 +02:00
|
|
|
} // namespace rocksdb
|
|
|
|
|
2013-08-23 17:38:13 +02:00
|
|
|
#endif // STORAGE_ROCKSDB_INCLUDE_OPTIONS_H_
|