Skip to content

Commit

Permalink
Adapt rocksdb 6.16.3 (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
linxGnu authored Mar 14, 2021
1 parent 0a06eba commit 745de8f
Show file tree
Hide file tree
Showing 18 changed files with 250 additions and 55 deletions.
4 changes: 2 additions & 2 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@ cd $BUILD_PATH && wget https://github.com/lz4/lz4/archive/v${lz4_version}.tar.gz
cmake $CMAKE_REQUIRED_PARAMS -DLZ4_BUILD_LEGACY_LZ4C=OFF -DBUILD_SHARED_LIBS=OFF -DLZ4_POSITION_INDEPENDENT_LIB=ON && make -j16 install && \
cd $BUILD_PATH && rm -rf *

zstd_version="1.4.8"
zstd_version="1.4.9"
cd $BUILD_PATH && wget https://github.com/facebook/zstd/archive/v${zstd_version}.tar.gz && tar xzf v${zstd_version}.tar.gz && \
cd zstd-${zstd_version}/build/cmake && mkdir -p build_place && cd build_place && \
cmake -DZSTD_BUILD_PROGRAMS=OFF -DZSTD_BUILD_CONTRIB=OFF -DZSTD_BUILD_STATIC=ON -DZSTD_BUILD_SHARED=OFF -DZSTD_BUILD_TESTS=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON -DZSTD_ZLIB_SUPPORT=ON -DZSTD_LZMA_SUPPORT=OFF -DCMAKE_BUILD_TYPE=Release .. && make -j$(nproc) install && \
cd $BUILD_PATH && rm -rf * && ldconfig

rocksdb_version="6.15.5"
rocksdb_version="6.16.3"
cd $BUILD_PATH && wget https://github.com/facebook/rocksdb/archive/v${rocksdb_version}.tar.gz && tar xzf v${rocksdb_version}.tar.gz && cd rocksdb-${rocksdb_version}/ && \
mkdir -p build_place && cd build_place && cmake -DCMAKE_BUILD_TYPE=Release $CMAKE_REQUIRED_PARAMS -DCMAKE_PREFIX_PATH=$INSTALL_PREFIX -DWITH_TESTS=OFF -DWITH_GFLAGS=OFF \
-DWITH_BENCHMARK_TOOLS=OFF -DWITH_TOOLS=OFF -DWITH_MD_LIBRARY=OFF -DWITH_RUNTIME_DEBUG=OFF -DROCKSDB_BUILD_SHARED=OFF -DWITH_SNAPPY=ON -DWITH_LZ4=ON -DWITH_ZLIB=ON \
Expand Down
9 changes: 8 additions & 1 deletion dist/linux_amd64/include/rocksdb/advanced_options.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,11 @@ struct AdvancedColumnFamilyOptions {
// Dynamically changeable through SetOptions() API
bool report_bg_io_stats = false;

// Files older than TTL will go through the compaction process.
// Files containing updates older than TTL will go through the compaction
// process. This usually happens in a cascading way so that those entries
// will be compacted to bottommost level/file.
// The feature is used to remove stale entries that have been deleted or
// updated from the file system.
// Pre-req: This needs max_open_files to be set to -1.
// In Level: Non-bottom-level files older than TTL will go through the
// compation process.
Expand All @@ -695,6 +699,9 @@ struct AdvancedColumnFamilyOptions {

// Files older than this value will be picked up for compaction, and
// re-written to the same level as they were before.
// One main use of the feature is to make sure a file goes through compaction
// filters periodically. Users can also use the feature to clear up SST
// files using old format.
//
// A file's age is computed by looking at file_creation_time or creation_time
// table properties in order, if they have valid non-zero values; if not, the
Expand Down
34 changes: 19 additions & 15 deletions dist/linux_amd64/include/rocksdb/db.h
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,9 @@ class DB {
virtual void ReleaseSnapshot(const Snapshot* snapshot) = 0;

#ifndef ROCKSDB_LITE
// Contains all valid property arguments for GetProperty().
// Contains all valid property arguments for GetProperty() or
// GetMapProperty(). Each is a "string" property for retrieval with
// GetProperty() unless noted as a "map" property, for GetMapProperty().
//
// NOTE: Property names cannot end in numbers since those are interpreted as
// arguments, e.g., see kNumFilesAtLevelPrefix.
Expand All @@ -738,19 +740,14 @@ class DB {
// SST files.
static const std::string kSSTables;

// "rocksdb.cfstats" - Both of "rocksdb.cfstats-no-file-histogram" and
// "rocksdb.cf-file-histogram" together. See below for description
// of the two.
// "rocksdb.cfstats" - Raw data from "rocksdb.cfstats-no-file-histogram"
// and "rocksdb.cf-file-histogram" as a "map" property.
static const std::string kCFStats;

// "rocksdb.cfstats-no-file-histogram" - returns a multi-line string with
// general columm family stats per-level over db's lifetime ("L<n>"),
// aggregated over db's lifetime ("Sum"), and aggregated over the
// interval since the last retrieval ("Int").
// It could also be used to return the stats in the format of the map.
// In this case there will a pair of string to array of double for
// each level as well as for "Sum". "Int" stats will not be affected
// when this form of stats are retrieved.
static const std::string kCFStatsNoFileHistogram;

// "rocksdb.cf-file-histogram" - print out how many file reads to every
Expand Down Expand Up @@ -891,8 +888,10 @@ class DB {
// based.
static const std::string kEstimatePendingCompactionBytes;

// "rocksdb.aggregated-table-properties" - returns a string representation
// of the aggregated table properties of the target column family.
// "rocksdb.aggregated-table-properties" - returns a string or map
// representation of the aggregated table properties of the target
// column family. Only properties that make sense for aggregation
// are included.
static const std::string kAggregatedTableProperties;

// "rocksdb.aggregated-table-properties-at-level<N>", same as the previous
Expand Down Expand Up @@ -930,15 +929,19 @@ class DB {
};
#endif /* ROCKSDB_LITE */

// DB implementations can export properties about their state via this method.
// If "property" is a valid property understood by this DB implementation (see
// Properties struct above for valid options), fills "*value" with its current
// value and returns true. Otherwise, returns false.
// DB implementations export properties about their state via this method.
// If "property" is a valid "string" property understood by this DB
// implementation (see Properties struct above for valid options), fills
// "*value" with its current value and returns true. Otherwise, returns
// false.
virtual bool GetProperty(ColumnFamilyHandle* column_family,
const Slice& property, std::string* value) = 0;
virtual bool GetProperty(const Slice& property, std::string* value) {
return GetProperty(DefaultColumnFamily(), property, value);
}

// Like GetProperty but for valid "map" properties. (Some properties can be
// accessed as either "string" properties or "map" properties.)
virtual bool GetMapProperty(ColumnFamilyHandle* column_family,
const Slice& property,
std::map<std::string, std::string>* value) = 0;
Expand Down Expand Up @@ -1032,7 +1035,8 @@ class DB {
(include_flags & SizeApproximationFlags::INCLUDE_MEMTABLES) != 0;
options.include_files =
(include_flags & SizeApproximationFlags::INCLUDE_FILES) != 0;
GetApproximateSizes(options, column_family, ranges, n, sizes);
Status s = GetApproximateSizes(options, column_family, ranges, n, sizes);
s.PermitUncheckedError();
}
virtual void GetApproximateSizes(const Range* ranges, int n, uint64_t* sizes,
uint8_t include_flags = INCLUDE_FILES) {
Expand Down
35 changes: 19 additions & 16 deletions dist/linux_amd64/include/rocksdb/filter_policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <stdlib.h>

#include <algorithm>
#include <memory>
#include <stdexcept>
#include <string>
Expand Down Expand Up @@ -50,23 +51,25 @@ class FilterBitsBuilder {
// The ownership of actual data is set to buf
virtual Slice Finish(std::unique_ptr<const char[]>* buf) = 0;

// Calculate num of keys that can be added and generate a filter
// <= the specified number of bytes.
#if defined(_MSC_VER)
#pragma warning(push)
#pragma warning(disable : 4702) // unreachable code
#endif
virtual int CalculateNumEntry(const uint32_t /*bytes*/) {
#ifndef ROCKSDB_LITE
throw std::runtime_error("CalculateNumEntry not Implemented");
#else
abort();
#endif
return 0;
// Approximate the number of keys that can be added and generate a filter
// <= the specified number of bytes. Callers (including RocksDB) should
// only use this result for optimizing performance and not as a guarantee.
// This default implementation is for compatibility with older custom
// FilterBitsBuilders only implementing deprecated CalculateNumEntry.
virtual size_t ApproximateNumEntries(size_t bytes) {
bytes = std::min(bytes, size_t{0xffffffff});
return static_cast<size_t>(CalculateNumEntry(static_cast<uint32_t>(bytes)));
}

// Old, DEPRECATED version of ApproximateNumEntries. This is not
// called by RocksDB except as the default implementation of
// ApproximateNumEntries for API compatibility.
virtual int CalculateNumEntry(const uint32_t bytes) {
// DEBUG: ideally should not rely on this implementation
assert(false);
// RELEASE: something reasonably conservative: 2 bytes per entry
return static_cast<int>(bytes / 2);
}
#if defined(_MSC_VER)
#pragma warning(pop)
#endif
};

// A class that checks if a key can be in filter
Expand Down
5 changes: 5 additions & 0 deletions dist/linux_amd64/include/rocksdb/listener.h
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,18 @@ enum class FlushReason : int {
kErrorRecoveryRetryFlush = 0xc,
};

// TODO: In the future, BackgroundErrorReason will only be used to indicate
// why the BG Error is happening (e.g., flush, compaction). We may introduce
// other data structure to indicate other essential information such as
// the file type (e.g., Manifest, SST) and special context.
enum class BackgroundErrorReason {
kFlush,
kCompaction,
kWriteCallback,
kMemTable,
kManifestWrite,
kFlushNoWAL,
kManifestWriteNoWAL,
};

enum class WriteStallCondition {
Expand Down
2 changes: 1 addition & 1 deletion dist/linux_amd64/include/rocksdb/merge_operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class MergeOperator {
Slice& existing_operand;
};

// This function applies a stack of merge operands in chrionological order
// This function applies a stack of merge operands in chronological order
// on top of an existing value. There are two ways in which this method is
// being used:
// a) During Get() operation, it used to calculate the final value of a key
Expand Down
14 changes: 5 additions & 9 deletions dist/linux_amd64/include/rocksdb/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,18 +393,14 @@ struct DBOptions {
// Default: true
bool paranoid_checks = true;

// If true, track WALs in MANIFEST and verify them on recovery.
// If true, the log numbers and sizes of the synced WALs are tracked
// in MANIFEST, then during DB recovery, if a synced WAL is missing
// from disk, or the WAL's size does not match the recorded size in
// MANIFEST, an error will be reported and the recovery will be aborted.
//
// If a WAL is tracked in MANIFEST but is missing from disk on recovery,
// or the size of the tracked WAL is larger than the WAL's on-disk size,
// an error is reported and recovery is aborted.
//
// If a WAL is not tracked in MANIFEST, then no verification will happen
// during recovery.
// Note that this option does not work with secondary instance.
//
// Default: false
// FIXME(cheng): This option is part of a work in progress and does not yet
// work
bool track_and_verify_wals_in_manifest = false;

// Use the specified object to interact with the environment,
Expand Down
5 changes: 5 additions & 0 deletions dist/linux_amd64/include/rocksdb/table_properties.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,11 @@ struct TableProperties {
// Aggregate the numerical member variables of the specified
// TableProperties.
void Add(const TableProperties& tp);

// Subset of properties that make sense when added together
// between tables. Keys match field names in this class instead
// of using full property names.
std::map<std::string, uint64_t> GetAggregatablePropertiesAsMap() const;
};

// Extra properties
Expand Down
82 changes: 80 additions & 2 deletions dist/linux_amd64/include/rocksdb/utilities/transaction.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,81 @@ using TransactionName = std::string;

using TransactionID = uint64_t;

// An endpoint for a range of keys.
/*
class Endpoint allows to define prefix ranges.
Prefix ranges are introduced below.
== Basic Ranges ==
Let's start from basic ranges. Key Comparator defines ordering of rowkeys.
Then, one can specify finite closed ranges by just providing rowkeys of their
endpoints:
lower_endpoint <= X <= upper_endpoint
However our goal is to provide a richer set of endpoints. Read on.
== Lexicographic ordering ==
A lexicographic (or dictionary) ordering satisfies these criteria: If there
are two keys in form
key_a = {prefix_a, suffix_a}
key_b = {prefix_b, suffix_b}
and
prefix_a < prefix_b
then
key_a < key_b.
== Prefix ranges ==
With lexicographic ordering, one may want to define ranges in form
"prefix is $PREFIX"
which translates to a range in form
{$PREFIX, -infinity} < X < {$PREFIX, +infinity}
where -infinity will compare less than any possible suffix, and +infinity
will compare as greater than any possible suffix.
class Endpoint allows to define these kind of rangtes.
== Notes ==
BytewiseComparator and ReverseBytewiseComparator produce lexicographic
ordering.
The row comparison function is able to compare key prefixes. If the data
domain includes keys A and B, then the comparison function is able to compare
equal-length prefixes:
min_len= min(byte_length(A), byte_length(B));
cmp(Slice(A, min_len), Slice(B, min_len)); // this call is valid
== Other options ==
As far as MyRocks is concerned, the alternative to prefix ranges would be to
support both open (non-inclusive) and closed (inclusive) range endpoints.
*/

class Endpoint {
// TODO
public:
Slice slice;

/*
true : the key has a "+infinity" suffix. A suffix that would compare as
greater than any other suffix
false : otherwise
*/
bool inf_suffix;

explicit Endpoint(const Slice& slice_arg, bool inf_suffix_arg = false)
: slice(slice_arg), inf_suffix(inf_suffix_arg) {}

explicit Endpoint(const char* s, bool inf_suffix_arg = false)
: slice(s), inf_suffix(inf_suffix_arg) {}

Endpoint(const char* s, size_t size, bool inf_suffix_arg = false)
: slice(s, size), inf_suffix(inf_suffix_arg) {}

Endpoint() : inf_suffix(false) {}
};

// Provides notification to the caller of SetSnapshotOnNextOperation when
Expand Down Expand Up @@ -282,6 +354,12 @@ class Transaction {
}
}

// Get a range lock on [start_endpoint; end_endpoint].
virtual Status GetRangeLock(ColumnFamilyHandle*, const Endpoint&,
const Endpoint&) {
return Status::NotSupported();
}

virtual Status GetForUpdate(const ReadOptions& options, const Slice& key,
std::string* value, bool exclusive = true,
const bool do_validate = true) = 0;
Expand Down
Loading

0 comments on commit 745de8f

Please sign in to comment.