2017-07-28 13:55:19 -07:00
|
|
|
// Copyright (c) 2017-present, Facebook, Inc. All rights reserved.
|
2017-07-15 16:03:42 -07:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2017-05-12 14:59:57 -07:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE
|
|
|
|
|
|
|
|
#include "rocksdb/db.h"
|
|
|
|
#include "rocksdb/types.h"
|
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
// Data associated with a particular version of a key. A database may internally
|
|
|
|
// store multiple versions of a same user key due to snapshots, compaction not
|
|
|
|
// happening yet, etc.
|
|
|
|
struct KeyVersion {
|
Blob DB: Inline small values in base DB
Summary:
Adding the `min_blob_size` option to allow storing small values in base db (in LSM tree) together with the key. The goal is to improve performance for small values, while taking advantage of blob db's low write amplification for large values.
Also adding expiration timestamp to blob index. It will be useful to evict stale blob indexes in base db by adding a compaction filter. I'll work on the compaction filter in future patches.
See blob_index.h for the new blob index format. There are 4 cases when writing a new key:
* small value w/o TTL: put in base db as normal value (i.e. ValueType::kTypeValue)
* small value w/ TTL: put (type, expiration, value) to base db.
* large value w/o TTL: write value to blob log and put (type, file, offset, size, compression) to base db.
* large value w/TTL: write value to blob log and put (type, expiration, file, offset, size, compression) to base db.
Closes https://github.com/facebook/rocksdb/pull/3066
Differential Revision: D6142115
Pulled By: yiwu-arbug
fbshipit-source-id: 9526e76e19f0839310a3f5f2a43772a4ad182cd0
2017-10-26 12:19:43 -07:00
|
|
|
KeyVersion() : user_key(""), value(""), sequence(0), type(0) {}
|
|
|
|
|
2017-05-12 14:59:57 -07:00
|
|
|
KeyVersion(const std::string& _user_key, const std::string& _value,
|
|
|
|
SequenceNumber _sequence, int _type)
|
|
|
|
: user_key(_user_key), value(_value), sequence(_sequence), type(_type) {}
|
|
|
|
|
|
|
|
std::string user_key;
|
|
|
|
std::string value;
|
|
|
|
SequenceNumber sequence;
|
|
|
|
// TODO(ajkr): we should provide a helper function that converts the int to a
|
|
|
|
// string describing the type for easier debugging.
|
|
|
|
int type;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Returns listing of all versions of keys in the provided user key range.
|
|
|
|
// The range is inclusive-inclusive, i.e., [`begin_key`, `end_key`].
|
|
|
|
// The result is inserted into the provided vector, `key_versions`.
|
|
|
|
Status GetAllKeyVersions(DB* db, Slice begin_key, Slice end_key,
|
|
|
|
std::vector<KeyVersion>* key_versions);
|
|
|
|
|
|
|
|
} // namespace rocksdb
|
|
|
|
|
|
|
|
#endif // ROCKSDB_LITE
|