2016-02-09 23:12:00 +00:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-15 23:03:42 +00: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).
|
2013-10-16 21:59:46 +00:00
|
|
|
//
|
2011-03-18 22:37:00 +00: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.
|
2014-01-27 21:53:22 +00:00
|
|
|
#include "db/dbformat.h"
|
2011-03-18 22:37:00 +00:00
|
|
|
|
2019-09-20 19:00:55 +00:00
|
|
|
#include <cinttypes>
|
2024-01-05 19:53:57 +00:00
|
|
|
#include <cstdio>
|
2021-09-29 11:01:57 +00:00
|
|
|
|
|
|
|
#include "db/lookup_key.h"
|
2017-04-06 02:02:00 +00:00
|
|
|
#include "monitoring/perf_context_imp.h"
|
2011-03-18 22:37:00 +00:00
|
|
|
#include "port/port.h"
|
|
|
|
#include "util/coding.h"
|
2017-04-06 21:49:13 +00:00
|
|
|
#include "util/string_util.h"
|
2011-03-18 22:37:00 +00:00
|
|
|
|
2020-02-20 20:07:53 +00:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2011-03-18 22:37:00 +00:00
|
|
|
|
2016-09-28 01:20:57 +00:00
|
|
|
// kValueTypeForSeek defines the ValueType that should be passed when
|
|
|
|
// constructing a ParsedInternalKey object for seeking to a particular
|
|
|
|
// sequence number (since we sort sequence numbers in decreasing order
|
|
|
|
// and the value type is embedded as the low 8 bits in the sequence
|
|
|
|
// number in internal keys, we need to use the highest-numbered
|
|
|
|
// ValueType, not the lowest).
|
2022-06-21 01:04:08 +00:00
|
|
|
const ValueType kValueTypeForSeek = kTypeWideColumnEntity;
|
2016-09-28 01:20:57 +00:00
|
|
|
const ValueType kValueTypeForSeekForPrev = kTypeDeletion;
|
2024-01-05 19:53:57 +00:00
|
|
|
const std::string kDisableUserTimestamp;
|
2016-09-28 01:20:57 +00:00
|
|
|
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 01:43:29 +00:00
|
|
|
EntryType GetEntryType(ValueType value_type) {
|
|
|
|
switch (value_type) {
|
|
|
|
case kTypeValue:
|
|
|
|
return kEntryPut;
|
|
|
|
case kTypeDeletion:
|
|
|
|
return kEntryDelete;
|
2020-08-17 23:24:35 +00:00
|
|
|
case kTypeDeletionWithTimestamp:
|
|
|
|
return kEntryDeleteWithTimestamp;
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 01:43:29 +00:00
|
|
|
case kTypeSingleDeletion:
|
|
|
|
return kEntrySingleDelete;
|
|
|
|
case kTypeMerge:
|
|
|
|
return kEntryMerge;
|
2018-04-13 18:13:38 +00:00
|
|
|
case kTypeRangeDeletion:
|
|
|
|
return kEntryRangeDeletion;
|
2018-08-07 01:12:25 +00:00
|
|
|
case kTypeBlobIndex:
|
|
|
|
return kEntryBlobIndex;
|
2022-06-21 01:04:08 +00:00
|
|
|
case kTypeWideColumnEntity:
|
|
|
|
return kEntryWideColumnEntity;
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 01:43:29 +00:00
|
|
|
default:
|
|
|
|
return kEntryOther;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-18 22:37:00 +00:00
|
|
|
void AppendInternalKey(std::string* result, const ParsedInternalKey& key) {
|
|
|
|
result->append(key.user_key.data(), key.user_key.size());
|
|
|
|
PutFixed64(result, PackSequenceAndType(key.sequence, key.type));
|
|
|
|
}
|
|
|
|
|
2020-03-07 00:21:03 +00:00
|
|
|
void AppendInternalKeyWithDifferentTimestamp(std::string* result,
|
|
|
|
const ParsedInternalKey& key,
|
|
|
|
const Slice& ts) {
|
|
|
|
assert(key.user_key.size() >= ts.size());
|
|
|
|
result->append(key.user_key.data(), key.user_key.size() - ts.size());
|
|
|
|
result->append(ts.data(), ts.size());
|
|
|
|
PutFixed64(result, PackSequenceAndType(key.sequence, key.type));
|
|
|
|
}
|
|
|
|
|
2016-12-01 15:00:17 +00:00
|
|
|
void AppendInternalKeyFooter(std::string* result, SequenceNumber s,
|
|
|
|
ValueType t) {
|
|
|
|
PutFixed64(result, PackSequenceAndType(s, t));
|
|
|
|
}
|
|
|
|
|
2020-12-02 20:59:23 +00:00
|
|
|
void AppendKeyWithMinTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(ts_sz > 0);
|
|
|
|
const std::string kTsMin(ts_sz, static_cast<unsigned char>(0));
|
|
|
|
result->append(key.data(), key.size());
|
|
|
|
result->append(kTsMin.data(), ts_sz);
|
|
|
|
}
|
|
|
|
|
|
|
|
void AppendKeyWithMaxTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(ts_sz > 0);
|
|
|
|
const std::string kTsMax(ts_sz, static_cast<unsigned char>(0xff));
|
|
|
|
result->append(key.data(), key.size());
|
|
|
|
result->append(kTsMax.data(), ts_sz);
|
|
|
|
}
|
|
|
|
|
2023-08-15 05:04:18 +00:00
|
|
|
void AppendUserKeyWithMinTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(ts_sz > 0);
|
|
|
|
result->append(key.data(), key.size() - ts_sz);
|
|
|
|
result->append(ts_sz, static_cast<unsigned char>(0));
|
|
|
|
}
|
|
|
|
|
2022-09-30 23:13:03 +00:00
|
|
|
void AppendUserKeyWithMaxTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(ts_sz > 0);
|
|
|
|
result->append(key.data(), key.size() - ts_sz);
|
|
|
|
|
|
|
|
static constexpr char kTsMax[] = "\xff\xff\xff\xff\xff\xff\xff\xff\xff";
|
|
|
|
if (ts_sz < strlen(kTsMax)) {
|
|
|
|
result->append(kTsMax, ts_sz);
|
|
|
|
} else {
|
|
|
|
result->append(std::string(ts_sz, '\xff'));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-05-25 22:41:32 +00:00
|
|
|
void PadInternalKeyWithMinTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(ts_sz > 0);
|
|
|
|
size_t user_key_size = key.size() - kNumInternalBytes;
|
|
|
|
result->reserve(key.size() + ts_sz);
|
|
|
|
result->append(key.data(), user_key_size);
|
|
|
|
result->append(ts_sz, static_cast<unsigned char>(0));
|
|
|
|
result->append(key.data() + user_key_size, kNumInternalBytes);
|
|
|
|
}
|
|
|
|
|
|
|
|
void StripTimestampFromInternalKey(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
assert(key.size() >= ts_sz + kNumInternalBytes);
|
|
|
|
result->reserve(key.size() - ts_sz);
|
|
|
|
result->append(key.data(), key.size() - kNumInternalBytes - ts_sz);
|
|
|
|
result->append(key.data() + key.size() - kNumInternalBytes,
|
|
|
|
kNumInternalBytes);
|
|
|
|
}
|
|
|
|
|
Logically strip timestamp during flush (#11557)
Summary:
Logically strip the user-defined timestamp when L0 files are created during flush when `AdvancedColumnFamilyOptions.persist_user_defined_timestamps` is false. Logically stripping timestamp here means replacing the original user-defined timestamp with a mininum timestamp, which for now is hard coded to be all zeros bytes.
While working on this, I caught a missing piece on the `BlockBuilder` level for this feature. The current quick path `std::min(buffer_size, last_key_size)` needs a bit tweaking to work for this feature. When user-defined timestamp is stripped during block building, on writing first entry or right after resetting, `buffer` is empty and `buffer_size` is zero as usual. However, in follow-up writes, depending on the size of the stripped user-defined timestamp, and the size of the value, what's in `buffer` can sometimes be smaller than `last_key_size`, leading `std::min(buffer_size, last_key_size)` to truncate the `last_key`. Previous test doesn't caught the bug because in those tests, the size of the stripped user-defined timestamps bytes is smaller than the length of the value. In order to avoid the conditional operation, this PR changed the original trivial `std::min` operation into an arithmetic operation. Since this is a change in a hot and performance critical path, I did the following benchmark to check no observable regression is introduced.
```TEST_TMPDIR=/dev/shm/rocksdb1 ./db_bench -benchmarks=fillseq -memtablerep=vector -allow_concurrent_memtable_write=false -num=50000000```
Compiled with DEBUG_LEVEL=0
Test vs. control runs simulaneous for better accuracy, units = ops/sec
PR vs base:
Round 1: 350652 vs 349055
Round 2: 365733 vs 364308
Round 3: 355681 vs 354475
Pull Request resolved: https://github.com/facebook/rocksdb/pull/11557
Test Plan:
New timestamp specific test added or existing tests augmented, both are parameterized with `UserDefinedTimestampTestMode`:
`UserDefinedTimestampTestMode::kNormal` -> UDT feature enabled, write / read with min timestamp
`UserDefinedTimestampTestMode::kStripUserDefinedTimestamps` -> UDT feature enabled, write / read with min timestamp, set Options.persist_user_defined_timestamps to false.
```
make all check
./db_wal_test --gtest_filter="*WithTimestamp*"
./flush_job_test --gtest_filter="*WithTimestamp*"
./repair_test --gtest_filter="*WithTimestamp*"
./block_based_table_reader_test
```
Reviewed By: pdillinger
Differential Revision: D47027664
Pulled By: jowlyzhang
fbshipit-source-id: e729193b6334dfc63aaa736d684d907a022571f5
2023-06-29 22:50:50 +00:00
|
|
|
void ReplaceInternalKeyWithMinTimestamp(std::string* result, const Slice& key,
|
|
|
|
size_t ts_sz) {
|
|
|
|
const size_t key_sz = key.size();
|
|
|
|
assert(key_sz >= ts_sz + kNumInternalBytes);
|
|
|
|
result->reserve(key_sz);
|
|
|
|
result->append(key.data(), key_sz - kNumInternalBytes - ts_sz);
|
|
|
|
result->append(ts_sz, static_cast<unsigned char>(0));
|
|
|
|
result->append(key.data() + key_sz - kNumInternalBytes, kNumInternalBytes);
|
|
|
|
}
|
|
|
|
|
2020-10-28 17:11:13 +00:00
|
|
|
std::string ParsedInternalKey::DebugString(bool log_err_key, bool hex) const {
|
|
|
|
std::string result = "'";
|
|
|
|
if (log_err_key) {
|
|
|
|
result += user_key.ToString(hex);
|
|
|
|
} else {
|
|
|
|
result += "<redacted>";
|
|
|
|
}
|
|
|
|
|
2011-03-18 22:37:00 +00:00
|
|
|
char buf[50];
|
2017-03-13 17:24:52 +00:00
|
|
|
snprintf(buf, sizeof(buf), "' seq:%" PRIu64 ", type:%d", sequence,
|
2015-06-17 05:26:34 +00:00
|
|
|
static_cast<int>(type));
|
2020-10-28 17:11:13 +00:00
|
|
|
|
2011-03-18 22:37:00 +00:00
|
|
|
result += buf;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2012-12-16 02:28:36 +00:00
|
|
|
std::string InternalKey::DebugString(bool hex) const {
|
2011-10-05 23:30:28 +00:00
|
|
|
std::string result;
|
|
|
|
ParsedInternalKey parsed;
|
2020-10-28 17:11:13 +00:00
|
|
|
if (ParseInternalKey(rep_, &parsed, false /* log_err_key */).ok()) {
|
|
|
|
result = parsed.DebugString(true /* log_err_key */, hex); // TODO
|
2011-10-05 23:30:28 +00:00
|
|
|
} else {
|
|
|
|
result = "(bad)";
|
|
|
|
result.append(EscapeString(rep_));
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-01-27 21:53:22 +00:00
|
|
|
int InternalKeyComparator::Compare(const ParsedInternalKey& a,
|
|
|
|
const ParsedInternalKey& b) const {
|
|
|
|
// Order by:
|
|
|
|
// increasing user key (according to user-supplied comparator)
|
|
|
|
// decreasing sequence number
|
|
|
|
// decreasing type (though sequence# should be enough to disambiguate)
|
2019-03-27 17:24:16 +00:00
|
|
|
int r = user_comparator_.Compare(a.user_key, b.user_key);
|
2014-01-27 21:53:22 +00:00
|
|
|
if (r == 0) {
|
|
|
|
if (a.sequence > b.sequence) {
|
|
|
|
r = -1;
|
|
|
|
} else if (a.sequence < b.sequence) {
|
|
|
|
r = +1;
|
|
|
|
} else if (a.type > b.type) {
|
|
|
|
r = -1;
|
|
|
|
} else if (a.type < b.type) {
|
|
|
|
r = +1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2022-11-29 03:27:22 +00:00
|
|
|
int InternalKeyComparator::Compare(const Slice& a,
|
|
|
|
const ParsedInternalKey& b) const {
|
|
|
|
// Order by:
|
|
|
|
// increasing user key (according to user-supplied comparator)
|
|
|
|
// decreasing sequence number
|
|
|
|
// decreasing type (though sequence# should be enough to disambiguate)
|
|
|
|
int r = user_comparator_.Compare(ExtractUserKey(a), b.user_key);
|
|
|
|
if (r == 0) {
|
|
|
|
const uint64_t anum =
|
|
|
|
DecodeFixed64(a.data() + a.size() - kNumInternalBytes);
|
|
|
|
const uint64_t bnum = (b.sequence << 8) | b.type;
|
|
|
|
if (anum > bnum) {
|
|
|
|
r = -1;
|
|
|
|
} else if (anum < bnum) {
|
|
|
|
r = +1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
|
|
|
int InternalKeyComparator::Compare(const ParsedInternalKey& a,
|
|
|
|
const Slice& b) const {
|
|
|
|
return -Compare(b, a);
|
|
|
|
}
|
|
|
|
|
2019-07-25 22:23:46 +00:00
|
|
|
LookupKey::LookupKey(const Slice& _user_key, SequenceNumber s,
|
|
|
|
const Slice* ts) {
|
2014-11-06 19:14:28 +00:00
|
|
|
size_t usize = _user_key.size();
|
2019-07-25 22:23:46 +00:00
|
|
|
size_t ts_sz = (nullptr == ts) ? 0 : ts->size();
|
|
|
|
size_t needed = usize + ts_sz + 13; // A conservative estimate
|
2011-06-22 02:36:45 +00:00
|
|
|
char* dst;
|
|
|
|
if (needed <= sizeof(space_)) {
|
|
|
|
dst = space_;
|
|
|
|
} else {
|
|
|
|
dst = new char[needed];
|
|
|
|
}
|
|
|
|
start_ = dst;
|
2014-11-11 21:47:22 +00:00
|
|
|
// NOTE: We don't support users keys of more than 2GB :)
|
2019-07-25 22:23:46 +00:00
|
|
|
dst = EncodeVarint32(dst, static_cast<uint32_t>(usize + ts_sz + 8));
|
2011-06-22 02:36:45 +00:00
|
|
|
kstart_ = dst;
|
2014-11-06 19:14:28 +00:00
|
|
|
memcpy(dst, _user_key.data(), usize);
|
2011-06-22 02:36:45 +00:00
|
|
|
dst += usize;
|
2019-07-25 22:23:46 +00:00
|
|
|
if (nullptr != ts) {
|
|
|
|
memcpy(dst, ts->data(), ts_sz);
|
|
|
|
dst += ts_sz;
|
|
|
|
}
|
2011-06-22 02:36:45 +00:00
|
|
|
EncodeFixed64(dst, PackSequenceAndType(s, kValueTypeForSeek));
|
|
|
|
dst += 8;
|
|
|
|
end_ = dst;
|
|
|
|
}
|
|
|
|
|
2017-09-14 22:41:19 +00:00
|
|
|
void IterKey::EnlargeBuffer(size_t key_size) {
|
|
|
|
// If size is smaller than buffer size, continue using current buffer,
|
|
|
|
// or the static allocated one, as default
|
|
|
|
assert(key_size > buf_size_);
|
|
|
|
// Need to enlarge the buffer.
|
|
|
|
ResetBuffer();
|
|
|
|
buf_ = new char[key_size];
|
|
|
|
buf_size_ = key_size;
|
|
|
|
}
|
2020-02-20 20:07:53 +00:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|