// K = key
// V = value
// O = optype aka value type
-// T = timestamp
// S = seqno
// C = CF ID
//
// Then, for example, a class that protects an entry consisting of key, value,
-// optype, timestamp, and CF ID (i.e., a `WriteBatch` entry) would be named
-// `ProtectionInfoKVOTC`.
+// optype, and CF ID (i.e., a `WriteBatch` entry) would be named
+// `ProtectionInfoKVOC`.
//
// The `ProtectionInfo.*` classes are templated on the integer type used to hold
// the XOR of hashes for each field. Only unsigned integer types are supported,
template <typename T>
class ProtectionInfo;
template <typename T>
-class ProtectionInfoKVOT;
+class ProtectionInfoKVO;
template <typename T>
-class ProtectionInfoKVOTC;
+class ProtectionInfoKVOC;
template <typename T>
-class ProtectionInfoKVOTS;
+class ProtectionInfoKVOS;
// Aliases for 64-bit protection infos.
using ProtectionInfo64 = ProtectionInfo<uint64_t>;
-using ProtectionInfoKVOT64 = ProtectionInfoKVOT<uint64_t>;
-using ProtectionInfoKVOTC64 = ProtectionInfoKVOTC<uint64_t>;
-using ProtectionInfoKVOTS64 = ProtectionInfoKVOTS<uint64_t>;
+using ProtectionInfoKVO64 = ProtectionInfoKVO<uint64_t>;
+using ProtectionInfoKVOC64 = ProtectionInfoKVOC<uint64_t>;
+using ProtectionInfoKVOS64 = ProtectionInfoKVOS<uint64_t>;
template <typename T>
class ProtectionInfo {
ProtectionInfo<T>() = default;
Status GetStatus() const;
- ProtectionInfoKVOT<T> ProtectKVOT(const Slice& key, const Slice& value,
- ValueType op_type) const;
- ProtectionInfoKVOT<T> ProtectKVOT(const SliceParts& key,
- const SliceParts& value,
- ValueType op_type) const;
+ ProtectionInfoKVO<T> ProtectKVO(const Slice& key, const Slice& value,
+ ValueType op_type) const;
+ ProtectionInfoKVO<T> ProtectKVO(const SliceParts& key,
+ const SliceParts& value,
+ ValueType op_type) const;
private:
- friend class ProtectionInfoKVOT<T>;
- friend class ProtectionInfoKVOTS<T>;
- friend class ProtectionInfoKVOTC<T>;
+ friend class ProtectionInfoKVO<T>;
+ friend class ProtectionInfoKVOS<T>;
+ friend class ProtectionInfoKVOC<T>;
// Each field is hashed with an independent value so we can catch fields being
// swapped. Per the `NPHash64()` docs, using consecutive seeds is a pitfall,
static const uint64_t kSeedK = 0;
static const uint64_t kSeedV = 0xD28AAD72F49BD50B;
static const uint64_t kSeedO = 0xA5155AE5E937AA16;
- static const uint64_t kSeedT = 0x77A00858DDD37F21;
- static const uint64_t kSeedS = 0x4A2AB5CBD26F542C;
- static const uint64_t kSeedC = 0x1CB5633EC70B2937;
+ static const uint64_t kSeedS = 0x77A00858DDD37F21;
+ static const uint64_t kSeedC = 0x4A2AB5CBD26F542C;
ProtectionInfo<T>(T val) : val_(val) {
static_assert(sizeof(ProtectionInfo<T>) == sizeof(T), "");
};
template <typename T>
-class ProtectionInfoKVOT {
+class ProtectionInfoKVO {
public:
- ProtectionInfoKVOT<T>() = default;
+ ProtectionInfoKVO<T>() = default;
- ProtectionInfo<T> StripKVOT(const Slice& key, const Slice& value,
- ValueType op_type, const Slice& timestamp) const;
- ProtectionInfo<T> StripKVOT(const SliceParts& key, const SliceParts& value,
- ValueType op_type, const Slice& timestamp) const;
+ ProtectionInfo<T> StripKVO(const Slice& key, const Slice& value,
+ ValueType op_type) const;
+ ProtectionInfo<T> StripKVO(const SliceParts& key, const SliceParts& value,
+ ValueType op_type) const;
- ProtectionInfoKVOTC<T> ProtectC(ColumnFamilyId column_family_id) const;
- ProtectionInfoKVOTS<T> ProtectS(SequenceNumber sequence_number) const;
+ ProtectionInfoKVOC<T> ProtectC(ColumnFamilyId column_family_id) const;
+ ProtectionInfoKVOS<T> ProtectS(SequenceNumber sequence_number) const;
void UpdateK(const Slice& old_key, const Slice& new_key);
void UpdateK(const SliceParts& old_key, const SliceParts& new_key);
void UpdateV(const Slice& old_value, const Slice& new_value);
void UpdateV(const SliceParts& old_value, const SliceParts& new_value);
void UpdateO(ValueType old_op_type, ValueType new_op_type);
- void UpdateT(const Slice& old_timestamp, const Slice& new_timestamp);
private:
friend class ProtectionInfo<T>;
- friend class ProtectionInfoKVOTS<T>;
- friend class ProtectionInfoKVOTC<T>;
+ friend class ProtectionInfoKVOS<T>;
+ friend class ProtectionInfoKVOC<T>;
- ProtectionInfoKVOT<T>(T val) : info_(val) {
- static_assert(sizeof(ProtectionInfoKVOT<T>) == sizeof(T), "");
+ ProtectionInfoKVO<T>(T val) : info_(val) {
+ static_assert(sizeof(ProtectionInfoKVO<T>) == sizeof(T), "");
}
T GetVal() const { return info_.GetVal(); }
};
template <typename T>
-class ProtectionInfoKVOTC {
+class ProtectionInfoKVOC {
public:
- ProtectionInfoKVOTC<T>() = default;
+ ProtectionInfoKVOC<T>() = default;
- ProtectionInfoKVOT<T> StripC(ColumnFamilyId column_family_id) const;
+ ProtectionInfoKVO<T> StripC(ColumnFamilyId column_family_id) const;
void UpdateK(const Slice& old_key, const Slice& new_key) {
- kvot_.UpdateK(old_key, new_key);
+ kvo_.UpdateK(old_key, new_key);
}
void UpdateK(const SliceParts& old_key, const SliceParts& new_key) {
- kvot_.UpdateK(old_key, new_key);
+ kvo_.UpdateK(old_key, new_key);
}
void UpdateV(const Slice& old_value, const Slice& new_value) {
- kvot_.UpdateV(old_value, new_value);
+ kvo_.UpdateV(old_value, new_value);
}
void UpdateV(const SliceParts& old_value, const SliceParts& new_value) {
- kvot_.UpdateV(old_value, new_value);
+ kvo_.UpdateV(old_value, new_value);
}
void UpdateO(ValueType old_op_type, ValueType new_op_type) {
- kvot_.UpdateO(old_op_type, new_op_type);
- }
- void UpdateT(const Slice& old_timestamp, const Slice& new_timestamp) {
- kvot_.UpdateT(old_timestamp, new_timestamp);
+ kvo_.UpdateO(old_op_type, new_op_type);
}
void UpdateC(ColumnFamilyId old_column_family_id,
ColumnFamilyId new_column_family_id);
private:
- friend class ProtectionInfoKVOT<T>;
+ friend class ProtectionInfoKVO<T>;
- ProtectionInfoKVOTC<T>(T val) : kvot_(val) {
- static_assert(sizeof(ProtectionInfoKVOTC<T>) == sizeof(T), "");
+ ProtectionInfoKVOC<T>(T val) : kvo_(val) {
+ static_assert(sizeof(ProtectionInfoKVOC<T>) == sizeof(T), "");
}
- T GetVal() const { return kvot_.GetVal(); }
- void SetVal(T val) { kvot_.SetVal(val); }
+ T GetVal() const { return kvo_.GetVal(); }
+ void SetVal(T val) { kvo_.SetVal(val); }
- ProtectionInfoKVOT<T> kvot_;
+ ProtectionInfoKVO<T> kvo_;
};
template <typename T>
-class ProtectionInfoKVOTS {
+class ProtectionInfoKVOS {
public:
- ProtectionInfoKVOTS<T>() = default;
+ ProtectionInfoKVOS<T>() = default;
- ProtectionInfoKVOT<T> StripS(SequenceNumber sequence_number) const;
+ ProtectionInfoKVO<T> StripS(SequenceNumber sequence_number) const;
void UpdateK(const Slice& old_key, const Slice& new_key) {
- kvot_.UpdateK(old_key, new_key);
+ kvo_.UpdateK(old_key, new_key);
}
void UpdateK(const SliceParts& old_key, const SliceParts& new_key) {
- kvot_.UpdateK(old_key, new_key);
+ kvo_.UpdateK(old_key, new_key);
}
void UpdateV(const Slice& old_value, const Slice& new_value) {
- kvot_.UpdateV(old_value, new_value);
+ kvo_.UpdateV(old_value, new_value);
}
void UpdateV(const SliceParts& old_value, const SliceParts& new_value) {
- kvot_.UpdateV(old_value, new_value);
+ kvo_.UpdateV(old_value, new_value);
}
void UpdateO(ValueType old_op_type, ValueType new_op_type) {
- kvot_.UpdateO(old_op_type, new_op_type);
- }
- void UpdateT(const Slice& old_timestamp, const Slice& new_timestamp) {
- kvot_.UpdateT(old_timestamp, new_timestamp);
+ kvo_.UpdateO(old_op_type, new_op_type);
}
void UpdateS(SequenceNumber old_sequence_number,
SequenceNumber new_sequence_number);
private:
- friend class ProtectionInfoKVOT<T>;
+ friend class ProtectionInfoKVO<T>;
- ProtectionInfoKVOTS<T>(T val) : kvot_(val) {
- static_assert(sizeof(ProtectionInfoKVOTS<T>) == sizeof(T), "");
+ ProtectionInfoKVOS<T>(T val) : kvo_(val) {
+ static_assert(sizeof(ProtectionInfoKVOS<T>) == sizeof(T), "");
}
- T GetVal() const { return kvot_.GetVal(); }
- void SetVal(T val) { kvot_.SetVal(val); }
+ T GetVal() const { return kvo_.GetVal(); }
+ void SetVal(T val) { kvo_.SetVal(val); }
- ProtectionInfoKVOT<T> kvot_;
+ ProtectionInfoKVO<T> kvo_;
};
template <typename T>
}
template <typename T>
-ProtectionInfoKVOT<T> ProtectionInfo<T>::ProtectKVOT(const Slice& key,
- const Slice& value,
- ValueType op_type) const {
+ProtectionInfoKVO<T> ProtectionInfo<T>::ProtectKVO(const Slice& key,
+ const Slice& value,
+ ValueType op_type) const {
T val = GetVal();
val = val ^ static_cast<T>(GetSliceNPHash64(key, ProtectionInfo<T>::kSeedK));
val =
val = val ^
static_cast<T>(NPHash64(reinterpret_cast<char*>(&op_type),
sizeof(op_type), ProtectionInfo<T>::kSeedO));
- return ProtectionInfoKVOT<T>(val);
+ return ProtectionInfoKVO<T>(val);
}
template <typename T>
-ProtectionInfoKVOT<T> ProtectionInfo<T>::ProtectKVOT(const SliceParts& key,
- const SliceParts& value,
- ValueType op_type) const {
+ProtectionInfoKVO<T> ProtectionInfo<T>::ProtectKVO(const SliceParts& key,
+ const SliceParts& value,
+ ValueType op_type) const {
T val = GetVal();
val = val ^
static_cast<T>(GetSlicePartsNPHash64(key, ProtectionInfo<T>::kSeedK));
val = val ^
static_cast<T>(NPHash64(reinterpret_cast<char*>(&op_type),
sizeof(op_type), ProtectionInfo<T>::kSeedO));
- return ProtectionInfoKVOT<T>(val);
+ return ProtectionInfoKVO<T>(val);
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateK(const Slice& old_key,
- const Slice& new_key) {
+void ProtectionInfoKVO<T>::UpdateK(const Slice& old_key, const Slice& new_key) {
T val = GetVal();
val = val ^
static_cast<T>(GetSliceNPHash64(old_key, ProtectionInfo<T>::kSeedK));
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateK(const SliceParts& old_key,
- const SliceParts& new_key) {
+void ProtectionInfoKVO<T>::UpdateK(const SliceParts& old_key,
+ const SliceParts& new_key) {
T val = GetVal();
val = val ^ static_cast<T>(
GetSlicePartsNPHash64(old_key, ProtectionInfo<T>::kSeedK));
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateV(const Slice& old_value,
- const Slice& new_value) {
+void ProtectionInfoKVO<T>::UpdateV(const Slice& old_value,
+ const Slice& new_value) {
T val = GetVal();
val = val ^
static_cast<T>(GetSliceNPHash64(old_value, ProtectionInfo<T>::kSeedV));
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateV(const SliceParts& old_value,
- const SliceParts& new_value) {
+void ProtectionInfoKVO<T>::UpdateV(const SliceParts& old_value,
+ const SliceParts& new_value) {
T val = GetVal();
val = val ^ static_cast<T>(
GetSlicePartsNPHash64(old_value, ProtectionInfo<T>::kSeedV));
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateO(ValueType old_op_type,
- ValueType new_op_type) {
+void ProtectionInfoKVO<T>::UpdateO(ValueType old_op_type,
+ ValueType new_op_type) {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(reinterpret_cast<char*>(&old_op_type),
sizeof(old_op_type),
}
template <typename T>
-void ProtectionInfoKVOT<T>::UpdateT(const Slice& old_timestamp,
- const Slice& new_timestamp) {
- T val = GetVal();
- val = val ^ static_cast<T>(
- GetSliceNPHash64(old_timestamp, ProtectionInfo<T>::kSeedT));
- val = val ^ static_cast<T>(
- GetSliceNPHash64(new_timestamp, ProtectionInfo<T>::kSeedT));
- SetVal(val);
-}
-
-template <typename T>
-ProtectionInfo<T> ProtectionInfoKVOT<T>::StripKVOT(
- const Slice& key, const Slice& value, ValueType op_type,
- const Slice& timestamp) const {
+ProtectionInfo<T> ProtectionInfoKVO<T>::StripKVO(const Slice& key,
+ const Slice& value,
+ ValueType op_type) const {
T val = GetVal();
val = val ^ static_cast<T>(GetSliceNPHash64(key, ProtectionInfo<T>::kSeedK));
val =
val = val ^
static_cast<T>(NPHash64(reinterpret_cast<char*>(&op_type),
sizeof(op_type), ProtectionInfo<T>::kSeedO));
- val = val ^
- static_cast<T>(GetSliceNPHash64(timestamp, ProtectionInfo<T>::kSeedT));
return ProtectionInfo<T>(val);
}
template <typename T>
-ProtectionInfo<T> ProtectionInfoKVOT<T>::StripKVOT(
- const SliceParts& key, const SliceParts& value, ValueType op_type,
- const Slice& timestamp) const {
+ProtectionInfo<T> ProtectionInfoKVO<T>::StripKVO(const SliceParts& key,
+ const SliceParts& value,
+ ValueType op_type) const {
T val = GetVal();
val = val ^
static_cast<T>(GetSlicePartsNPHash64(key, ProtectionInfo<T>::kSeedK));
val = val ^
static_cast<T>(NPHash64(reinterpret_cast<char*>(&op_type),
sizeof(op_type), ProtectionInfo<T>::kSeedO));
- val = val ^
- static_cast<T>(GetSliceNPHash64(timestamp, ProtectionInfo<T>::kSeedT));
return ProtectionInfo<T>(val);
}
template <typename T>
-ProtectionInfoKVOTC<T> ProtectionInfoKVOT<T>::ProtectC(
+ProtectionInfoKVOC<T> ProtectionInfoKVO<T>::ProtectC(
ColumnFamilyId column_family_id) const {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(
reinterpret_cast<char*>(&column_family_id),
sizeof(column_family_id), ProtectionInfo<T>::kSeedC));
- return ProtectionInfoKVOTC<T>(val);
+ return ProtectionInfoKVOC<T>(val);
}
template <typename T>
-ProtectionInfoKVOT<T> ProtectionInfoKVOTC<T>::StripC(
+ProtectionInfoKVO<T> ProtectionInfoKVOC<T>::StripC(
ColumnFamilyId column_family_id) const {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(
reinterpret_cast<char*>(&column_family_id),
sizeof(column_family_id), ProtectionInfo<T>::kSeedC));
- return ProtectionInfoKVOT<T>(val);
+ return ProtectionInfoKVO<T>(val);
}
template <typename T>
-void ProtectionInfoKVOTC<T>::UpdateC(ColumnFamilyId old_column_family_id,
- ColumnFamilyId new_column_family_id) {
+void ProtectionInfoKVOC<T>::UpdateC(ColumnFamilyId old_column_family_id,
+ ColumnFamilyId new_column_family_id) {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(
reinterpret_cast<char*>(&old_column_family_id),
}
template <typename T>
-ProtectionInfoKVOTS<T> ProtectionInfoKVOT<T>::ProtectS(
+ProtectionInfoKVOS<T> ProtectionInfoKVO<T>::ProtectS(
SequenceNumber sequence_number) const {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(reinterpret_cast<char*>(&sequence_number),
sizeof(sequence_number),
ProtectionInfo<T>::kSeedS));
- return ProtectionInfoKVOTS<T>(val);
+ return ProtectionInfoKVOS<T>(val);
}
template <typename T>
-ProtectionInfoKVOT<T> ProtectionInfoKVOTS<T>::StripS(
+ProtectionInfoKVO<T> ProtectionInfoKVOS<T>::StripS(
SequenceNumber sequence_number) const {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(reinterpret_cast<char*>(&sequence_number),
sizeof(sequence_number),
ProtectionInfo<T>::kSeedS));
- return ProtectionInfoKVOT<T>(val);
+ return ProtectionInfoKVO<T>(val);
}
template <typename T>
-void ProtectionInfoKVOTS<T>::UpdateS(SequenceNumber old_sequence_number,
- SequenceNumber new_sequence_number) {
+void ProtectionInfoKVOS<T>::UpdateS(SequenceNumber old_sequence_number,
+ SequenceNumber new_sequence_number) {
T val = GetVal();
val = val ^ static_cast<T>(NPHash64(
reinterpret_cast<char*>(&old_sequence_number),
}
Status MemTable::VerifyEncodedEntry(Slice encoded,
- const ProtectionInfoKVOTS64& kv_prot_info) {
+ const ProtectionInfoKVOS64& kv_prot_info) {
uint32_t ikey_len = 0;
if (!GetVarint32(&encoded, &ikey_len)) {
return Status::Corruption("Unable to parse internal key length");
return Status::Corruption("Internal key length too long");
}
uint32_t value_len = 0;
- const size_t key_without_ts_len = ikey_len - ts_sz - 8;
- Slice key(encoded.data(), key_without_ts_len);
- encoded.remove_prefix(key_without_ts_len);
-
- Slice timestamp(encoded.data(), ts_sz);
- encoded.remove_prefix(ts_sz);
+ const size_t user_key_len = ikey_len - 8;
+ Slice key(encoded.data(), user_key_len);
+ encoded.remove_prefix(user_key_len);
uint64_t packed = DecodeFixed64(encoded.data());
ValueType value_type = kMaxValue;
Slice value(encoded.data(), value_len);
return kv_prot_info.StripS(sequence_number)
- .StripKVOT(key, value, value_type, timestamp)
+ .StripKVO(key, value, value_type)
.GetStatus();
}
Status MemTable::Add(SequenceNumber s, ValueType type,
const Slice& key, /* user key */
const Slice& value,
- const ProtectionInfoKVOTS64* kv_prot_info,
+ const ProtectionInfoKVOS64* kv_prot_info,
bool allow_concurrent,
MemTablePostProcessInfo* post_process_info, void** hint) {
// Format of an entry is concatenation of:
Status MemTable::Update(SequenceNumber seq, const Slice& key,
const Slice& value,
- const ProtectionInfoKVOTS64* kv_prot_info) {
+ const ProtectionInfoKVOS64* kv_prot_info) {
LookupKey lkey(key, seq);
Slice mem_key = lkey.memtable_key();
VarintLength(value.size()) + value.size()));
RecordTick(moptions_.statistics, NUMBER_KEYS_UPDATED);
if (kv_prot_info != nullptr) {
- ProtectionInfoKVOTS64 updated_kv_prot_info(*kv_prot_info);
+ ProtectionInfoKVOS64 updated_kv_prot_info(*kv_prot_info);
// `seq` is swallowed and `existing_seq` prevails.
updated_kv_prot_info.UpdateS(seq, existing_seq);
Slice encoded(entry, p + value.size() - entry);
Status MemTable::UpdateCallback(SequenceNumber seq, const Slice& key,
const Slice& delta,
- const ProtectionInfoKVOTS64* kv_prot_info) {
+ const ProtectionInfoKVOS64* kv_prot_info) {
LookupKey lkey(key, seq);
Slice memkey = lkey.memtable_key();
RecordTick(moptions_.statistics, NUMBER_KEYS_UPDATED);
UpdateFlushState();
if (kv_prot_info != nullptr) {
- ProtectionInfoKVOTS64 updated_kv_prot_info(*kv_prot_info);
+ ProtectionInfoKVOS64 updated_kv_prot_info(*kv_prot_info);
// `seq` is swallowed and `existing_seq` prevails.
updated_kv_prot_info.UpdateS(seq, existing_seq);
updated_kv_prot_info.UpdateV(delta,
} else if (status == UpdateStatus::UPDATED) {
Status s;
if (kv_prot_info != nullptr) {
- ProtectionInfoKVOTS64 updated_kv_prot_info(*kv_prot_info);
+ ProtectionInfoKVOS64 updated_kv_prot_info(*kv_prot_info);
updated_kv_prot_info.UpdateV(delta, str_value);
s = Add(seq, kTypeValue, key, Slice(str_value),
&updated_kv_prot_info);
const ReadOptions& read_options, SequenceNumber read_seq);
Status VerifyEncodedEntry(Slice encoded,
- const ProtectionInfoKVOTS64& kv_prot_info);
+ const ProtectionInfoKVOS64& kv_prot_info);
// Add an entry into memtable that maps key to value at the
// specified sequence number and with the specified type.
// in the memtable and `MemTableRepFactory::CanHandleDuplicatedKey()` is true.
// The next attempt should try a larger value for `seq`.
Status Add(SequenceNumber seq, ValueType type, const Slice& key,
- const Slice& value, const ProtectionInfoKVOTS64* kv_prot_info,
+ const Slice& value, const ProtectionInfoKVOS64* kv_prot_info,
bool allow_concurrent = false,
MemTablePostProcessInfo* post_process_info = nullptr,
void** hint = nullptr);
// REQUIRES: external synchronization to prevent simultaneous
// operations on the same MemTable.
Status Update(SequenceNumber seq, const Slice& key, const Slice& value,
- const ProtectionInfoKVOTS64* kv_prot_info);
+ const ProtectionInfoKVOS64* kv_prot_info);
// If `key` exists in current memtable with type `kTypeValue` and the existing
// value is at least as large as the new value, updates it in-place. Otherwise
// operations on the same MemTable.
Status UpdateCallback(SequenceNumber seq, const Slice& key,
const Slice& delta,
- const ProtectionInfoKVOTS64* kv_prot_info);
+ const ProtectionInfoKVOS64* kv_prot_info);
// Returns the number of successive merge entries starting from the newest
// entry for the key up to the last non-merge entry or last entry for the
// This key does not have timestamp, so skip.
return;
}
- char* ptr = const_cast<char*>(key.data() + key.size() - ts_sz);
if (prot_info_ != nullptr) {
- Slice old_ts(ptr, ts_sz), new_ts(ts.data(), ts_sz);
- prot_info_->entries_[idx_].UpdateT(old_ts, new_ts);
+ SliceParts old_key(&key, 1);
+ Slice key_no_ts(key.data(), key.size() - ts_sz);
+ std::array<Slice, 2> new_key_cmpts{{key_no_ts, ts}};
+ SliceParts new_key(new_key_cmpts.data(), 2);
+ prot_info_->entries_[idx_].UpdateK(old_key, new_key);
}
+ char* ptr = const_cast<char*>(key.data() + key.size() - ts_sz);
memcpy(ptr, ts.data(), ts_sz);
}
// (a missing/extra encoded CF ID would corrupt another field). It is
// convenient to consolidate on `kTypeValue` here as that is what will be
// inserted into memtable.
- b->prot_info_->entries_.emplace_back(
- ProtectionInfo64()
- .ProtectKVOT(key, value, kTypeValue)
- .ProtectC(column_family_id));
+ b->prot_info_->entries_.emplace_back(ProtectionInfo64()
+ .ProtectKVO(key, value, kTypeValue)
+ .ProtectC(column_family_id));
}
return save.commit();
}
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
- b->prot_info_->entries_.emplace_back(
- ProtectionInfo64()
- .ProtectKVOT(key, value, kTypeValue)
- .ProtectC(column_family_id));
+ // `ValueType` argument passed to `ProtectKVO()`.
+ b->prot_info_->entries_.emplace_back(ProtectionInfo64()
+ .ProtectKVO(key, value, kTypeValue)
+ .ProtectC(column_family_id));
}
return save.commit();
}
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(key, "" /* value */, kTypeDeletion)
+ .ProtectKVO(key, "" /* value */, kTypeDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(key,
- SliceParts(nullptr /* _parts */, 0 /* _num_parts */),
- kTypeDeletion)
+ .ProtectKVO(key,
+ SliceParts(nullptr /* _parts */, 0 /* _num_parts */),
+ kTypeDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(key, "" /* value */, kTypeSingleDeletion)
+ .ProtectKVO(key, "" /* value */, kTypeSingleDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(key,
- SliceParts(nullptr /* _parts */,
- 0 /* _num_parts */) /* value */,
- kTypeSingleDeletion)
+ .ProtectKVO(key,
+ SliceParts(nullptr /* _parts */,
+ 0 /* _num_parts */) /* value */,
+ kTypeSingleDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
// In `DeleteRange()`, the end key is treated as the value.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(begin_key, end_key, kTypeRangeDeletion)
+ .ProtectKVO(begin_key, end_key, kTypeRangeDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
// In `DeleteRange()`, the end key is treated as the value.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(begin_key, end_key, kTypeRangeDeletion)
+ .ProtectKVO(begin_key, end_key, kTypeRangeDeletion)
.ProtectC(column_family_id));
}
return save.commit();
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
- b->prot_info_->entries_.emplace_back(
- ProtectionInfo64()
- .ProtectKVOT(key, value, kTypeMerge)
- .ProtectC(column_family_id));
+ // `ValueType` argument passed to `ProtectKVO()`.
+ b->prot_info_->entries_.emplace_back(ProtectionInfo64()
+ .ProtectKVO(key, value, kTypeMerge)
+ .ProtectC(column_family_id));
}
return save.commit();
}
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
- b->prot_info_->entries_.emplace_back(
- ProtectionInfo64()
- .ProtectKVOT(key, value, kTypeMerge)
- .ProtectC(column_family_id));
+ // `ValueType` argument passed to `ProtectKVO()`.
+ b->prot_info_->entries_.emplace_back(ProtectionInfo64()
+ .ProtectKVO(key, value, kTypeMerge)
+ .ProtectC(column_family_id));
}
return save.commit();
}
std::memory_order_relaxed);
if (b->prot_info_ != nullptr) {
// See comment in first `WriteBatchInternal::Put()` overload concerning the
- // `ValueType` argument passed to `ProtectKVOT()`.
+ // `ValueType` argument passed to `ProtectKVO()`.
b->prot_info_->entries_.emplace_back(
ProtectionInfo64()
- .ProtectKVOT(key, value, kTypeBlobIndex)
+ .ProtectKVO(key, value, kTypeBlobIndex)
.ProtectC(column_family_id));
}
return save.commit();
(&duplicate_detector_)->IsDuplicateKeySeq(column_family_id, key, sequence_);
}
- const ProtectionInfoKVOTC64* NextProtectionInfo() {
- const ProtectionInfoKVOTC64* res = nullptr;
+ const ProtectionInfoKVOC64* NextProtectionInfo() {
+ const ProtectionInfoKVOC64* res = nullptr;
if (prot_info_ != nullptr) {
assert(prot_info_idx_ < prot_info_->entries_.size());
res = &prot_info_->entries_[prot_info_idx_];
Status PutCFImpl(uint32_t column_family_id, const Slice& key,
const Slice& value, ValueType value_type,
- const ProtectionInfoKVOTS64* kv_prot_info) {
+ const ProtectionInfoKVOS64* kv_prot_info) {
// optimize for non-recovery mode
if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
return WriteBatchInternal::Put(rebuilding_trx_, column_family_id, key,
value);
// else insert the values to the memtable right away
assert(!write_after_commit_);
// The CF is probably flushed and hence no need for insert but we still
// need to keep track of the keys for upcoming rollback/commit.
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
key, value);
if (ret_status.ok()) {
if (update_status == UpdateStatus::UPDATED_INPLACE) {
assert(get_status.ok());
if (kv_prot_info != nullptr) {
- ProtectionInfoKVOTS64 updated_kv_prot_info(*kv_prot_info);
+ ProtectionInfoKVOS64 updated_kv_prot_info(*kv_prot_info);
updated_kv_prot_info.UpdateV(value,
Slice(prev_buffer, prev_size));
// prev_value is updated in-place with final value.
}
} else if (update_status == UpdateStatus::UPDATED) {
if (kv_prot_info != nullptr) {
- ProtectionInfoKVOTS64 updated_kv_prot_info(*kv_prot_info);
+ ProtectionInfoKVOS64 updated_kv_prot_info(*kv_prot_info);
updated_kv_prot_info.UpdateV(value, merged_value);
// merged_value contains the final value.
ret_status = mem->Add(sequence_, value_type, key,
// away. So we only need to add to it when `ret_status.ok()`.
if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
assert(!write_after_commit_);
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::Put(rebuilding_trx_, column_family_id,
key, value);
}
Status DeleteImpl(uint32_t /*column_family_id*/, const Slice& key,
const Slice& value, ValueType delete_type,
- const ProtectionInfoKVOTS64* kv_prot_info) {
+ const ProtectionInfoKVOS64* kv_prot_info) {
Status ret_status;
MemTable* mem = cf_mems_->GetMemTable();
ret_status =
const auto* kv_prot_info = NextProtectionInfo();
// optimize for non-recovery mode
if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
return WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
// else insert the values to the memtable right away
}
assert(!write_after_commit_);
// The CF is probably flushed and hence no need for insert but we still
// need to keep track of the keys for upcoming rollback/commit.
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status =
WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
if (ret_status.ok()) {
// away. So we only need to add to it when `ret_status.ok()`.
if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
assert(!write_after_commit_);
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status =
WriteBatchInternal::Delete(rebuilding_trx_, column_family_id, key);
}
const auto* kv_prot_info = NextProtectionInfo();
// optimize for non-recovery mode
if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
return WriteBatchInternal::SingleDelete(rebuilding_trx_, column_family_id,
key);
// else insert the values to the memtable right away
assert(!write_after_commit_);
// The CF is probably flushed and hence no need for insert but we still
// need to keep track of the keys for upcoming rollback/commit.
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::SingleDelete(rebuilding_trx_,
column_family_id, key);
if (ret_status.ok()) {
// away. So we only need to add to it when `ret_status.ok()`.
if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
assert(!write_after_commit_);
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::SingleDelete(rebuilding_trx_,
column_family_id, key);
}
const auto* kv_prot_info = NextProtectionInfo();
// optimize for non-recovery mode
if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
return WriteBatchInternal::DeleteRange(rebuilding_trx_, column_family_id,
begin_key, end_key);
// else insert the values to the memtable right away
assert(!write_after_commit_);
// The CF is probably flushed and hence no need for insert but we still
// need to keep track of the keys for upcoming rollback/commit.
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::DeleteRange(
rebuilding_trx_, column_family_id, begin_key, end_key);
if (ret_status.ok()) {
// away. So we only need to add to it when `ret_status.ok()`.
if (UNLIKELY(!ret_status.IsTryAgain() && rebuilding_trx_ != nullptr)) {
assert(!write_after_commit_);
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::DeleteRange(
rebuilding_trx_, column_family_id, begin_key, end_key);
}
const auto* kv_prot_info = NextProtectionInfo();
// optimize for non-recovery mode
if (UNLIKELY(write_after_commit_ && rebuilding_trx_ != nullptr)) {
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
return WriteBatchInternal::Merge(rebuilding_trx_, column_family_id, key,
value);
// else insert the values to the memtable right away
assert(!write_after_commit_);
// The CF is probably flushed and hence no need for insert but we still
// need to keep track of the keys for upcoming rollback/commit.
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::Merge(rebuilding_trx_,
column_family_id, key, value);
if (ret_status.ok()) {
// away. So we only need to add to it when `ret_status.ok()`.
if (UNLIKELY(ret_status.ok() && rebuilding_trx_ != nullptr)) {
assert(!write_after_commit_);
- // TODO(ajkr): propagate `ProtectionInfoKVOTS64`.
+ // TODO(ajkr): propagate `ProtectionInfoKVOS64`.
ret_status = WriteBatchInternal::Merge(rebuilding_trx_, column_family_id,
key, value);
}
struct WriteBatch::ProtectionInfo {
// `WriteBatch` usually doesn't contain a huge number of keys so protecting
// with a fixed, non-configurable eight bytes per key may work well enough.
- autovector<ProtectionInfoKVOTC64> entries_;
+ autovector<ProtectionInfoKVOC64> entries_;
size_t GetBytesPerKey() const { return 8; }
};