2017-05-26 04:48:44 +08:00
|
|
|
/*
|
|
|
|
* FDBTypes.h
|
|
|
|
*
|
|
|
|
* This source file is part of the FoundationDB open source project
|
|
|
|
*
|
|
|
|
* Copyright 2013-2018 Apple Inc. and the FoundationDB project authors
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2018-02-22 02:25:11 +08:00
|
|
|
*
|
2017-05-26 04:48:44 +08:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FDBCLIENT_FDBTYPES_H
|
|
|
|
#define FDBCLIENT_FDBTYPES_H
|
|
|
|
|
2019-05-17 04:54:06 +08:00
|
|
|
#include <algorithm>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2021-05-19 14:48:04 +08:00
|
|
|
#include <unordered_set>
|
2019-05-17 04:54:06 +08:00
|
|
|
|
2020-05-03 11:43:50 +08:00
|
|
|
#include "flow/Arena.h"
|
2017-05-26 04:48:44 +08:00
|
|
|
#include "flow/flow.h"
|
|
|
|
|
|
|
|
typedef int64_t Version;
|
|
|
|
typedef uint64_t LogEpoch;
|
|
|
|
typedef uint64_t Sequence;
|
|
|
|
typedef StringRef KeyRef;
|
|
|
|
typedef StringRef ValueRef;
|
|
|
|
typedef int64_t Generation;
|
2020-07-08 00:06:13 +08:00
|
|
|
typedef UID SpanID;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-04-24 06:39:26 +08:00
|
|
|
enum {
|
2020-10-28 00:11:56 +08:00
|
|
|
tagLocalitySpecial = -1, // tag with this locality means it is invalidTag (id=0), txsTag (id=1), or cacheTag (id=2)
|
2019-04-24 06:39:26 +08:00
|
|
|
tagLocalityLogRouter = -2,
|
2021-07-29 05:11:25 +08:00
|
|
|
tagLocalityRemoteLog = -3, // tag created by log router for remote (aka. not in Primary DC) tLogs
|
|
|
|
tagLocalityUpgraded = -4, // tlogs with old log format
|
2019-04-24 06:39:26 +08:00
|
|
|
tagLocalitySatellite = -5,
|
2020-11-12 14:27:52 +08:00
|
|
|
tagLocalityLogRouterMapped = -6, // The pseudo tag used by log routers to pop the real LogRouter tag (i.e., -2)
|
2019-06-20 09:15:09 +08:00
|
|
|
tagLocalityTxs = -7,
|
2021-03-11 02:06:03 +08:00
|
|
|
tagLocalityBackup = -8, // used by backup role to pop from TLogs
|
2019-04-24 06:39:26 +08:00
|
|
|
tagLocalityInvalid = -99
|
2020-10-28 00:11:56 +08:00
|
|
|
}; // The TLog and LogRouter require these number to be as compact as possible
|
2017-08-04 07:16:36 +08:00
|
|
|
|
2019-07-24 02:45:04 +08:00
|
|
|
inline bool isPseudoLocality(int8_t locality) {
|
|
|
|
return locality == tagLocalityLogRouterMapped || locality == tagLocalityBackup;
|
|
|
|
}
|
|
|
|
|
2017-08-04 07:16:36 +08:00
|
|
|
#pragma pack(push, 1)
|
|
|
|
struct Tag {
|
2020-10-28 00:11:56 +08:00
|
|
|
// if locality > 0,
|
|
|
|
// locality decides which DC id the tLog is in;
|
|
|
|
// id decides which SS owns the tag; id <-> SS mapping is in the system keyspace: serverTagKeys.
|
|
|
|
// if locality < 0, locality decides the type of tLog set: satellite, LR, or remote tLog, etc.
|
|
|
|
// id decides which tLog in the tLog type will be used.
|
2017-08-04 07:16:36 +08:00
|
|
|
int8_t locality;
|
|
|
|
uint16_t id;
|
|
|
|
|
|
|
|
Tag() : locality(tagLocalitySpecial), id(0) {}
|
|
|
|
Tag(int8_t locality, uint16_t id) : locality(locality), id(id) {}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(const Tag& r) const { return locality == r.locality && id == r.id; }
|
|
|
|
bool operator!=(const Tag& r) const { return locality != r.locality || id != r.id; }
|
|
|
|
bool operator<(const Tag& r) const { return locality < r.locality || (locality == r.locality && id < r.id); }
|
2017-08-04 07:16:36 +08:00
|
|
|
|
2020-11-28 02:07:26 +08:00
|
|
|
int toTagDataIndex() const { return locality >= 0 ? 2 * locality : 1 - (2 * locality); }
|
2019-04-02 04:56:45 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string toString() const { return format("%d:%d", locality, id); }
|
2017-08-04 07:16:36 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2020-02-05 02:26:18 +08:00
|
|
|
force_inline void serialize_unversioned(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, locality, id);
|
2017-08-04 07:16:36 +08:00
|
|
|
}
|
|
|
|
};
|
2020-05-03 11:43:50 +08:00
|
|
|
|
|
|
|
template <>
|
2020-05-24 13:57:41 +08:00
|
|
|
struct flow_ref<Tag> : std::integral_constant<bool, false> {};
|
2020-05-03 11:43:50 +08:00
|
|
|
|
2017-08-04 07:16:36 +08:00
|
|
|
#pragma pack(pop)
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <class Ar>
|
|
|
|
void load(Ar& ar, Tag& tag) {
|
|
|
|
tag.serialize_unversioned(ar);
|
|
|
|
}
|
|
|
|
template <class Ar>
|
|
|
|
void save(Ar& ar, Tag const& tag) {
|
|
|
|
const_cast<Tag&>(tag).serialize_unversioned(ar);
|
|
|
|
}
|
2017-08-04 07:16:36 +08:00
|
|
|
|
2019-04-14 00:52:04 +08:00
|
|
|
template <>
|
|
|
|
struct struct_like_traits<Tag> : std::true_type {
|
|
|
|
using Member = Tag;
|
|
|
|
using types = pack<uint16_t, int8_t>;
|
|
|
|
|
2019-07-16 03:58:31 +08:00
|
|
|
template <int i, class Context>
|
|
|
|
static const index_t<i, types>& get(const Member& m, Context&) {
|
2019-04-14 00:52:04 +08:00
|
|
|
if constexpr (i == 0) {
|
|
|
|
return m.id;
|
|
|
|
} else {
|
|
|
|
static_assert(i == 1);
|
|
|
|
return m.locality;
|
|
|
|
}
|
2019-01-29 11:38:13 +08:00
|
|
|
}
|
|
|
|
|
2019-07-16 03:58:31 +08:00
|
|
|
template <int i, class Type, class Context>
|
2019-10-27 05:29:05 +08:00
|
|
|
static void assign(Member& m, const Type& t, Context&) {
|
2019-04-14 00:52:04 +08:00
|
|
|
if constexpr (i == 0) {
|
|
|
|
m.id = t;
|
|
|
|
} else {
|
|
|
|
static_assert(i == 1);
|
|
|
|
m.locality = t;
|
|
|
|
}
|
2019-01-29 11:38:13 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2020-03-27 18:31:04 +08:00
|
|
|
struct Traceable<Tag> : std::true_type {
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toString(const Tag& value) { return value.toString(); }
|
2020-03-27 18:31:04 +08:00
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static const Tag invalidTag{ tagLocalitySpecial, 0 };
|
|
|
|
static const Tag txsTag{ tagLocalitySpecial, 1 };
|
|
|
|
static const Tag cacheTag{ tagLocalitySpecial, 2 };
|
2017-08-04 07:16:36 +08:00
|
|
|
|
2018-01-21 02:33:13 +08:00
|
|
|
enum { txsTagOld = -1, invalidTagOld = -100 };
|
|
|
|
|
2018-03-17 07:47:05 +08:00
|
|
|
struct TagsAndMessage {
|
|
|
|
StringRef message;
|
2019-11-06 10:07:30 +08:00
|
|
|
VectorRef<Tag> tags;
|
2018-03-17 07:47:05 +08:00
|
|
|
|
|
|
|
TagsAndMessage() {}
|
2019-11-06 10:07:30 +08:00
|
|
|
TagsAndMessage(StringRef message, VectorRef<Tag> tags) : message(message), tags(tags) {}
|
2019-09-05 05:52:09 +08:00
|
|
|
|
2019-09-05 11:43:56 +08:00
|
|
|
// Loads tags and message from a serialized buffer. "rd" is checkpointed at
|
2019-09-06 04:25:02 +08:00
|
|
|
// its begining position to allow the caller to rewind if needed.
|
|
|
|
// T can be ArenaReader or BinaryReader.
|
|
|
|
template <class T>
|
|
|
|
void loadFromArena(T* rd, uint32_t* messageVersionSub) {
|
2019-09-05 05:52:09 +08:00
|
|
|
int32_t messageLength;
|
|
|
|
uint16_t tagCount;
|
|
|
|
uint32_t sub;
|
|
|
|
|
|
|
|
rd->checkpoint();
|
|
|
|
*rd >> messageLength >> sub >> tagCount;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (messageVersionSub)
|
|
|
|
*messageVersionSub = sub;
|
|
|
|
tags = VectorRef<Tag>((Tag*)rd->readBytes(tagCount * sizeof(Tag)), tagCount);
|
2019-09-05 05:52:09 +08:00
|
|
|
const int32_t rawLength = messageLength + sizeof(messageLength);
|
|
|
|
rd->rewind();
|
2019-09-05 11:43:56 +08:00
|
|
|
rd->checkpoint();
|
2019-09-05 05:52:09 +08:00
|
|
|
message = StringRef((const uint8_t*)rd->readBytes(rawLength), rawLength);
|
|
|
|
}
|
2019-09-05 11:43:56 +08:00
|
|
|
|
|
|
|
// Returns the size of the header, including: msg_length, version.sub, tag_count, tags.
|
|
|
|
int32_t getHeaderSize() const {
|
|
|
|
return sizeof(int32_t) + sizeof(uint32_t) + sizeof(uint16_t) + tags.size() * sizeof(Tag);
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
StringRef getMessageWithoutTags() const { return message.substr(getHeaderSize()); }
|
2019-09-05 11:43:56 +08:00
|
|
|
|
|
|
|
// Returns the message with the header.
|
|
|
|
StringRef getRawMessage() const { return message; }
|
2018-03-17 07:47:05 +08:00
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct KeyRangeRef;
|
|
|
|
struct KeyValueRef;
|
|
|
|
|
2017-12-16 12:13:44 +08:00
|
|
|
template <class Collection>
|
2021-03-11 02:06:03 +08:00
|
|
|
void uniquify(Collection& c) {
|
2017-12-16 12:13:44 +08:00
|
|
|
std::sort(c.begin(), c.end());
|
2021-03-11 02:06:03 +08:00
|
|
|
c.resize(std::unique(c.begin(), c.end()) - c.begin());
|
2017-12-16 12:13:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline std::string describe(const Tag item) {
|
2017-08-04 07:16:36 +08:00
|
|
|
return format("%d:%d", item.locality, item.id);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline std::string describe(const int item) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return format("%d", item);
|
|
|
|
}
|
|
|
|
|
2019-11-09 07:05:18 +08:00
|
|
|
// Allows describeList to work on a vector of std::string
|
2021-10-29 03:42:24 +08:00
|
|
|
std::string describe(const std::string& s);
|
2019-11-09 07:05:18 +08:00
|
|
|
|
2018-11-03 04:15:09 +08:00
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describe(Reference<T> const& item) {
|
2018-11-03 04:15:09 +08:00
|
|
|
return item->toString();
|
|
|
|
}
|
|
|
|
|
2021-10-29 03:42:24 +08:00
|
|
|
std::string describe(UID const& item);
|
2020-11-06 08:13:18 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describe(T const& item) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return item.toString();
|
|
|
|
}
|
2018-02-24 04:26:19 +08:00
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class K, class V>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describe(std::map<K, V> const& items, int max_items = -1) {
|
|
|
|
if (!items.size())
|
2017-05-26 04:48:44 +08:00
|
|
|
return "[no items]";
|
|
|
|
|
|
|
|
std::string s;
|
|
|
|
int count = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto it = items.begin(); it != items.end(); it++) {
|
|
|
|
if (++count > max_items && max_items >= 0)
|
2017-05-26 04:48:44 +08:00
|
|
|
break;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (count > 1)
|
|
|
|
s += ",";
|
2017-05-26 04:48:44 +08:00
|
|
|
s += describe(it->first) + "=>" + describe(it->second);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describeList(T const& items, int max_items) {
|
|
|
|
if (!items.size())
|
2017-05-26 04:48:44 +08:00
|
|
|
return "[no items]";
|
|
|
|
|
|
|
|
std::string s;
|
|
|
|
int count = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
for (auto const& item : items) {
|
|
|
|
if (++count > max_items && max_items >= 0)
|
2017-05-26 04:48:44 +08:00
|
|
|
break;
|
2021-03-11 02:06:03 +08:00
|
|
|
if (count > 1)
|
|
|
|
s += ",";
|
2017-05-26 04:48:44 +08:00
|
|
|
s += describe(item);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describe(std::vector<T> const& items, int max_items = -1) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return describeList(items, max_items);
|
|
|
|
}
|
|
|
|
|
2021-05-19 14:48:04 +08:00
|
|
|
template <class T>
|
|
|
|
std::string describe(std::unordered_set<T> const& items, int max_items = -1) {
|
|
|
|
return describeList(items, max_items);
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <typename T>
|
Clean up and rework the debugMutation API.
As a relatively unknown debugging tool for simulation tests, one could
have simulation print when a particular key is handled in various stages
of the commit process. This functionality was enabled by changing a 0
to a 1 in an #if, and changing a constant to the key in question.
As a proxy and storage server handle mutations, they call debugMutation
or debugKeyRange, which then checks against the mutation against the key
in question, and logs if they match. A mixture of printfs and
TraceEvents would then be emitted, and for this to actually be usable,
one also needs to comment out some particularly spammy debugKeyRange()
calls.
This PR reworks the API of debugMutation/debugKeyRange, pulls it out
into its own file, and trims what is logged by default into something
useful and understandable:
* debugMutation() now returns a TraceEvent, that one can add more details to before it is logged.
* Data distribution and storage server cleanup operations are no longer logged by default
2020-03-27 16:35:26 +08:00
|
|
|
struct Traceable<std::vector<T>> : std::true_type {
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toString(const std::vector<T>& value) { return describe(value); }
|
Clean up and rework the debugMutation API.
As a relatively unknown debugging tool for simulation tests, one could
have simulation print when a particular key is handled in various stages
of the commit process. This functionality was enabled by changing a 0
to a 1 in an #if, and changing a constant to the key in question.
As a proxy and storage server handle mutations, they call debugMutation
or debugKeyRange, which then checks against the mutation against the key
in question, and logs if they match. A mixture of printfs and
TraceEvents would then be emitted, and for this to actually be usable,
one also needs to comment out some particularly spammy debugKeyRange()
calls.
This PR reworks the API of debugMutation/debugKeyRange, pulls it out
into its own file, and trims what is logged by default into something
useful and understandable:
* debugMutation() now returns a TraceEvent, that one can add more details to before it is logged.
* Data distribution and storage server cleanup operations are no longer logged by default
2020-03-27 16:35:26 +08:00
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string describe(std::set<T> const& items, int max_items = -1) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return describeList(items, max_items);
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <typename T>
|
Clean up and rework the debugMutation API.
As a relatively unknown debugging tool for simulation tests, one could
have simulation print when a particular key is handled in various stages
of the commit process. This functionality was enabled by changing a 0
to a 1 in an #if, and changing a constant to the key in question.
As a proxy and storage server handle mutations, they call debugMutation
or debugKeyRange, which then checks against the mutation against the key
in question, and logs if they match. A mixture of printfs and
TraceEvents would then be emitted, and for this to actually be usable,
one also needs to comment out some particularly spammy debugKeyRange()
calls.
This PR reworks the API of debugMutation/debugKeyRange, pulls it out
into its own file, and trims what is logged by default into something
useful and understandable:
* debugMutation() now returns a TraceEvent, that one can add more details to before it is logged.
* Data distribution and storage server cleanup operations are no longer logged by default
2020-03-27 16:35:26 +08:00
|
|
|
struct Traceable<std::set<T>> : std::true_type {
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toString(const std::set<T>& value) { return describe(value); }
|
Clean up and rework the debugMutation API.
As a relatively unknown debugging tool for simulation tests, one could
have simulation print when a particular key is handled in various stages
of the commit process. This functionality was enabled by changing a 0
to a 1 in an #if, and changing a constant to the key in question.
As a proxy and storage server handle mutations, they call debugMutation
or debugKeyRange, which then checks against the mutation against the key
in question, and logs if they match. A mixture of printfs and
TraceEvents would then be emitted, and for this to actually be usable,
one also needs to comment out some particularly spammy debugKeyRange()
calls.
This PR reworks the API of debugMutation/debugKeyRange, pulls it out
into its own file, and trims what is logged by default into something
useful and understandable:
* debugMutation() now returns a TraceEvent, that one can add more details to before it is logged.
* Data distribution and storage server cleanup operations are no longer logged by default
2020-03-27 16:35:26 +08:00
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string printable(const StringRef& val);
|
|
|
|
std::string printable(const std::string& val);
|
|
|
|
std::string printable(const KeyRangeRef& range);
|
|
|
|
std::string printable(const VectorRef<KeyRangeRef>& val);
|
|
|
|
std::string printable(const VectorRef<StringRef>& val);
|
|
|
|
std::string printable(const VectorRef<KeyValueRef>& val);
|
|
|
|
std::string printable(const KeyValueRef& val);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-01-12 01:03:38 +08:00
|
|
|
template <class T>
|
2021-03-11 02:06:03 +08:00
|
|
|
std::string printable(const Optional<T>& val) {
|
|
|
|
if (val.present())
|
|
|
|
return printable(val.get());
|
2019-01-12 01:03:38 +08:00
|
|
|
return "[not set]";
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline bool equalsKeyAfter(const KeyRef& key, const KeyRef& compareKey) {
|
|
|
|
if (key.size() + 1 != compareKey.size() || compareKey[compareKey.size() - 1] != 0)
|
2017-12-16 12:13:44 +08:00
|
|
|
return false;
|
2021-03-11 02:06:03 +08:00
|
|
|
return compareKey.startsWith(key);
|
2017-12-16 12:13:44 +08:00
|
|
|
}
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct KeyRangeRef {
|
|
|
|
const KeyRef begin, end;
|
|
|
|
KeyRangeRef() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRangeRef(const KeyRef& begin, const KeyRef& end) : begin(begin), end(end) {
|
|
|
|
if (begin > end) {
|
2020-07-03 00:10:17 +08:00
|
|
|
TraceEvent("InvertedRange").detail("Begin", begin).detail("End", end);
|
2017-05-26 04:48:44 +08:00
|
|
|
throw inverted_range();
|
|
|
|
}
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRangeRef(Arena& a, const KeyRangeRef& copyFrom) : begin(a, copyFrom.begin), end(a, copyFrom.end) {}
|
|
|
|
bool operator==(const KeyRangeRef& r) const { return begin == r.begin && end == r.end; }
|
|
|
|
bool operator!=(const KeyRangeRef& r) const { return begin != r.begin || end != r.end; }
|
|
|
|
bool contains(const KeyRef& key) const { return begin <= key && key < end; }
|
|
|
|
bool contains(const KeyRangeRef& keys) const { return begin <= keys.begin && keys.end <= end; }
|
|
|
|
bool intersects(const KeyRangeRef& keys) const { return begin < keys.end && keys.begin < end; }
|
2020-08-30 10:53:04 +08:00
|
|
|
bool intersects(const VectorRef<KeyRangeRef>& keysVec) const {
|
|
|
|
for (const auto& keys : keysVec) {
|
|
|
|
if (intersects(keys)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
bool empty() const { return begin == end; }
|
2017-12-16 12:13:44 +08:00
|
|
|
bool singleKeyRange() const { return equalsKeyAfter(begin, end); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
Standalone<KeyRangeRef> withPrefix(const StringRef& prefix) const {
|
|
|
|
return KeyRangeRef(begin.withPrefix(prefix), end.withPrefix(prefix));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2020-04-30 05:09:00 +08:00
|
|
|
KeyRangeRef withPrefix(const StringRef& prefix, Arena& arena) const {
|
|
|
|
return KeyRangeRef(begin.withPrefix(prefix, arena), end.withPrefix(prefix, arena));
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRangeRef removePrefix(const StringRef& prefix) const {
|
|
|
|
return KeyRangeRef(begin.removePrefix(prefix), end.removePrefix(prefix));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
const KeyRangeRef& operator=(const KeyRangeRef& rhs) {
|
2017-05-26 04:48:44 +08:00
|
|
|
const_cast<KeyRef&>(begin) = rhs.begin;
|
|
|
|
const_cast<KeyRef&>(end) = rhs.end;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
int expectedSize() const { return begin.expectedSize() + end.expectedSize(); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
force_inline void serialize(Ar& ar) {
|
2020-01-04 09:46:24 +08:00
|
|
|
if (!ar.isDeserializing && equalsKeyAfter(begin, end)) {
|
2020-05-01 02:13:59 +08:00
|
|
|
StringRef empty;
|
|
|
|
serializer(ar, const_cast<KeyRef&>(end), empty);
|
2020-01-04 09:46:24 +08:00
|
|
|
} else {
|
|
|
|
serializer(ar, const_cast<KeyRef&>(begin), const_cast<KeyRef&>(end));
|
|
|
|
}
|
2020-01-07 06:15:38 +08:00
|
|
|
if (ar.isDeserializing && end == StringRef() && begin != StringRef()) {
|
2021-03-11 02:06:03 +08:00
|
|
|
ASSERT(begin[begin.size() - 1] == '\x00');
|
2020-01-04 09:46:24 +08:00
|
|
|
const_cast<KeyRef&>(end) = begin;
|
2021-03-11 02:06:03 +08:00
|
|
|
const_cast<KeyRef&>(begin) = end.substr(0, end.size() - 1);
|
2020-01-04 09:46:24 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
if (begin > end) {
|
2020-04-23 14:37:29 +08:00
|
|
|
TraceEvent("InvertedRange").detail("Begin", begin).detail("End", end);
|
2017-05-26 04:48:44 +08:00
|
|
|
throw inverted_range();
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
struct ArbitraryOrder {
|
|
|
|
bool operator()(KeyRangeRef const& a, KeyRangeRef const& b) const {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (a.begin < b.begin)
|
|
|
|
return true;
|
|
|
|
if (a.begin > b.begin)
|
|
|
|
return false;
|
2017-05-26 04:48:44 +08:00
|
|
|
return a.end < b.end;
|
|
|
|
}
|
|
|
|
};
|
2018-11-30 02:31:47 +08:00
|
|
|
|
2019-08-02 08:00:13 +08:00
|
|
|
std::string toString() const { return "Begin:" + begin.printable() + "End:" + end.printable(); }
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-03-16 06:32:39 +08:00
|
|
|
struct Traceable<KeyRangeRef> : std::true_type {
|
|
|
|
static std::string toString(const KeyRangeRef& value) {
|
|
|
|
auto begin = Traceable<StringRef>::toString(value.begin);
|
|
|
|
auto end = Traceable<StringRef>::toString(value.end);
|
|
|
|
std::string result;
|
|
|
|
result.reserve(begin.size() + end.size() + 3);
|
|
|
|
std::copy(begin.begin(), begin.end(), std::back_inserter(result));
|
|
|
|
result.push_back(' ');
|
|
|
|
result.push_back('-');
|
|
|
|
result.push_back(' ');
|
|
|
|
std::copy(end.begin(), end.end(), std::back_inserter(result));
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeyRangeRef operator&(const KeyRangeRef& lhs, const KeyRangeRef& rhs) {
|
2017-05-26 04:48:44 +08:00
|
|
|
KeyRef b = std::max(lhs.begin, rhs.begin), e = std::min(lhs.end, rhs.end);
|
|
|
|
if (e < b)
|
|
|
|
return KeyRangeRef();
|
2021-03-11 02:06:03 +08:00
|
|
|
return KeyRangeRef(b, e);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
struct KeyValueRef {
|
|
|
|
KeyRef key;
|
|
|
|
ValueRef value;
|
|
|
|
KeyValueRef() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyValueRef(const KeyRef& key, const ValueRef& value) : key(key), value(value) {}
|
|
|
|
KeyValueRef(Arena& a, const KeyValueRef& copyFrom) : key(a, copyFrom.key), value(a, copyFrom.value) {}
|
|
|
|
bool operator==(const KeyValueRef& r) const { return key == r.key && value == r.value; }
|
|
|
|
bool operator!=(const KeyValueRef& r) const { return key != r.key || value != r.value; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
int expectedSize() const { return key.expectedSize() + value.expectedSize(); }
|
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
force_inline void serialize(Ar& ar) {
|
|
|
|
serializer(ar, key, value);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
struct OrderByKey {
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator()(KeyValueRef const& a, KeyValueRef const& b) const { return a.key < b.key; }
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class T>
|
|
|
|
bool operator()(T const& a, KeyValueRef const& b) const {
|
|
|
|
return a < b.key;
|
|
|
|
}
|
|
|
|
template <class T>
|
|
|
|
bool operator()(KeyValueRef const& a, T const& b) const {
|
|
|
|
return a.key < b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct OrderByKeyBack {
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator()(KeyValueRef const& a, KeyValueRef const& b) const { return a.key > b.key; }
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class T>
|
|
|
|
bool operator()(T const& a, KeyValueRef const& b) const {
|
|
|
|
return a > b.key;
|
|
|
|
}
|
|
|
|
template <class T>
|
|
|
|
bool operator()(KeyValueRef const& a, T const& b) const {
|
|
|
|
return a.key > b;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-07-10 09:07:47 +08:00
|
|
|
struct string_serialized_traits<KeyValueRef> : std::true_type {
|
|
|
|
int32_t getSize(const KeyValueRef& item) const {
|
2021-03-11 02:06:03 +08:00
|
|
|
return 2 * sizeof(uint32_t) + item.key.size() + item.value.size();
|
2019-07-10 09:07:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t save(uint8_t* out, const KeyValueRef& item) const {
|
|
|
|
auto begin = out;
|
|
|
|
uint32_t sz = item.key.size();
|
2019-07-30 08:11:45 +08:00
|
|
|
*reinterpret_cast<decltype(sz)*>(out) = sz;
|
2019-07-10 09:07:47 +08:00
|
|
|
out += sizeof(sz);
|
|
|
|
memcpy(out, item.key.begin(), sz);
|
|
|
|
out += sz;
|
|
|
|
sz = item.value.size();
|
2019-07-30 08:11:45 +08:00
|
|
|
*reinterpret_cast<decltype(sz)*>(out) = sz;
|
2019-07-10 09:07:47 +08:00
|
|
|
out += sizeof(sz);
|
|
|
|
memcpy(out, item.value.begin(), sz);
|
|
|
|
out += sz;
|
|
|
|
return out - begin;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <class Context>
|
|
|
|
uint32_t load(const uint8_t* data, KeyValueRef& t, Context& context) {
|
|
|
|
auto begin = data;
|
|
|
|
uint32_t sz;
|
|
|
|
memcpy(&sz, data, sizeof(sz));
|
|
|
|
data += sizeof(sz);
|
|
|
|
t.key = StringRef(context.tryReadZeroCopy(data, sz), sz);
|
|
|
|
data += sz;
|
|
|
|
memcpy(&sz, data, sizeof(sz));
|
|
|
|
data += sizeof(sz);
|
|
|
|
t.value = StringRef(context.tryReadZeroCopy(data, sz), sz);
|
|
|
|
data += sz;
|
|
|
|
return data - begin;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-03-16 06:32:39 +08:00
|
|
|
struct Traceable<KeyValueRef> : std::true_type {
|
|
|
|
static std::string toString(const KeyValueRef& value) {
|
|
|
|
return Traceable<KeyRef>::toString(value.key) + format(":%d", value.value.size());
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-05-04 06:38:31 +08:00
|
|
|
using Key = Standalone<KeyRef>;
|
|
|
|
using Value = Standalone<ValueRef>;
|
|
|
|
using KeyRange = Standalone<KeyRangeRef>;
|
|
|
|
using KeyValue = Standalone<KeyValueRef>;
|
|
|
|
using KeySelector = Standalone<struct KeySelectorRef>;
|
|
|
|
using RangeResult = Standalone<struct RangeResultRef>;
|
2022-03-11 02:05:44 +08:00
|
|
|
using MappedRangeResult = Standalone<struct MappedRangeResultRef>;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2020-04-18 09:38:11 +08:00
|
|
|
enum { invalidVersion = -1, latestVersion = -2, MAX_VERSION = std::numeric_limits<int64_t>::max() };
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline Key keyAfter(const KeyRef& key) {
|
|
|
|
if (key == LiteralStringRef("\xff\xff"))
|
2017-05-26 04:48:44 +08:00
|
|
|
return key;
|
|
|
|
|
|
|
|
Standalone<StringRef> r;
|
2021-03-11 02:06:03 +08:00
|
|
|
uint8_t* s = new (r.arena()) uint8_t[key.size() + 1];
|
2021-06-05 00:41:10 +08:00
|
|
|
if (key.size() > 0) {
|
|
|
|
memcpy(s, key.begin(), key.size());
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
s[key.size()] = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
((StringRef&)r) = StringRef(s, key.size() + 1);
|
2017-05-26 04:48:44 +08:00
|
|
|
return r;
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeyRef keyAfter(const KeyRef& key, Arena& arena) {
|
|
|
|
if (key == LiteralStringRef("\xff\xff"))
|
2017-05-26 04:48:44 +08:00
|
|
|
return key;
|
2021-03-11 02:06:03 +08:00
|
|
|
uint8_t* t = new (arena) uint8_t[key.size() + 1];
|
|
|
|
memcpy(t, key.begin(), key.size());
|
2017-05-26 04:48:44 +08:00
|
|
|
t[key.size()] = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
return KeyRef(t, key.size() + 1);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeyRange singleKeyRange(const KeyRef& a) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return KeyRangeRef(a, keyAfter(a));
|
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeyRangeRef singleKeyRange(KeyRef const& key, Arena& arena) {
|
|
|
|
uint8_t* t = new (arena) uint8_t[key.size() + 1];
|
|
|
|
memcpy(t, key.begin(), key.size());
|
2017-05-26 04:48:44 +08:00
|
|
|
t[key.size()] = 0;
|
2021-03-11 02:06:03 +08:00
|
|
|
return KeyRangeRef(KeyRef(t, key.size()), KeyRef(t, key.size() + 1));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeyRange prefixRange(KeyRef prefix) {
|
2017-12-15 07:27:43 +08:00
|
|
|
Standalone<KeyRangeRef> range;
|
|
|
|
KeyRef start = KeyRef(range.arena(), prefix);
|
|
|
|
KeyRef end = strinc(prefix, range.arena());
|
|
|
|
range.contents() = KeyRangeRef(start, end);
|
|
|
|
return range;
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-08 05:32:51 +08:00
|
|
|
// Returns (one of) the shortest key(s) either contained in keys or equal to keys.end,
|
|
|
|
// assuming its length is no more than CLIENT_KNOBS->SPLIT_KEY_SIZE_LIMIT. If the length of
|
|
|
|
// the shortest key exceeds that limit, then the end key is returned.
|
|
|
|
// The returned reference is valid as long as keys is valid.
|
|
|
|
KeyRef keyBetween(const KeyRangeRef& keys);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
struct KeySelectorRef {
|
|
|
|
private:
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRef key; // Find the last item less than key
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
public:
|
2021-03-11 02:06:03 +08:00
|
|
|
bool orEqual; // (or equal to key, if this is true)
|
|
|
|
int offset; // and then move forward this many items (or backward if negative)
|
2019-06-21 05:20:59 +08:00
|
|
|
KeySelectorRef() : orEqual(false), offset(0) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeySelectorRef(const KeyRef& key, bool orEqual, int offset) : orEqual(orEqual), offset(offset) { setKey(key); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
KeySelectorRef(Arena& arena, const KeySelectorRef& copyFrom)
|
|
|
|
: key(arena, copyFrom.key), orEqual(copyFrom.orEqual), offset(copyFrom.offset) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
int expectedSize() const { return key.expectedSize(); }
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void removeOrEqual(Arena& arena) {
|
|
|
|
if (orEqual) {
|
2017-05-26 04:48:44 +08:00
|
|
|
setKey(keyAfter(key, arena));
|
|
|
|
orEqual = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRef getKey() const { return key; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-08 05:32:51 +08:00
|
|
|
void setKey(KeyRef const& key);
|
2022-03-05 04:22:05 +08:00
|
|
|
void setKeyUnlimited(KeyRef const& key);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-06-08 05:32:51 +08:00
|
|
|
std::string toString() const;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool isBackward() const {
|
|
|
|
return !orEqual && offset <= 0;
|
|
|
|
} // True if the resolution of the KeySelector depends only on keys less than key
|
|
|
|
bool isFirstGreaterOrEqual() const { return !orEqual && offset == 1; }
|
|
|
|
bool isFirstGreaterThan() const { return orEqual && offset == 1; }
|
|
|
|
bool isLastLessOrEqual() const { return orEqual && offset == 0; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// True iff, regardless of the contents of the database, lhs must resolve to a key > rhs
|
2021-03-11 02:06:03 +08:00
|
|
|
bool isDefinitelyGreater(KeyRef const& k) { return offset >= 1 && (isFirstGreaterOrEqual() ? key > k : key >= k); }
|
2017-05-26 04:48:44 +08:00
|
|
|
// True iff, regardless of the contents of the database, lhs must resolve to a key < rhs
|
2021-03-11 02:06:03 +08:00
|
|
|
bool isDefinitelyLess(KeyRef const& k) { return offset <= 0 && (isLastLessOrEqual() ? key < k : key <= k); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, key, orEqual, offset);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline bool operator==(const KeySelectorRef& lhs, const KeySelectorRef& rhs) {
|
|
|
|
return lhs.getKey() == rhs.getKey() && lhs.orEqual == rhs.orEqual && lhs.offset == rhs.offset;
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef lastLessThan(const KeyRef& k) {
|
|
|
|
return KeySelectorRef(k, false, 0);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef lastLessOrEqual(const KeyRef& k) {
|
|
|
|
return KeySelectorRef(k, true, 0);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef firstGreaterThan(const KeyRef& k) {
|
|
|
|
return KeySelectorRef(k, true, +1);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef firstGreaterOrEqual(const KeyRef& k) {
|
|
|
|
return KeySelectorRef(k, false, +1);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef operator+(const KeySelectorRef& s, int off) {
|
|
|
|
return KeySelectorRef(s.getKey(), s.orEqual, s.offset + off);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2021-03-11 02:06:03 +08:00
|
|
|
inline KeySelectorRef operator-(const KeySelectorRef& s, int off) {
|
|
|
|
return KeySelectorRef(s.getKey(), s.orEqual, s.offset - off);
|
|
|
|
}
|
|
|
|
inline bool selectorInRange(KeySelectorRef const& sel, KeyRangeRef const& range) {
|
2019-11-13 05:01:29 +08:00
|
|
|
// Returns true if the given range suffices to at least begin to resolve the given KeySelectorRef
|
|
|
|
return sel.getKey() >= range.begin && (sel.isBackward() ? sel.getKey() <= range.end : sel.getKey() < range.end);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2022-03-02 00:57:01 +08:00
|
|
|
template <>
|
|
|
|
struct Traceable<KeySelectorRef> : std::true_type {
|
|
|
|
static std::string toString(const KeySelectorRef& value) { return value.toString(); }
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
template <class Val>
|
|
|
|
struct KeyRangeWith : KeyRange {
|
|
|
|
Val value;
|
|
|
|
KeyRangeWith() {}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRangeWith(const KeyRangeRef& range, const Val& value) : KeyRange(range), value(value) {}
|
|
|
|
bool operator==(const KeyRangeWith& r) const { return KeyRangeRef::operator==(r) && value == r.value; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, ((KeyRange&)*this), value);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
template <class Val>
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyRangeWith<Val> keyRangeWith(const KeyRangeRef& range, const Val& value) {
|
2017-05-26 04:48:44 +08:00
|
|
|
return KeyRangeWith<Val>(range, value);
|
|
|
|
}
|
|
|
|
|
2022-03-11 02:05:44 +08:00
|
|
|
struct MappedKeyValueRef;
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct GetRangeLimits {
|
|
|
|
enum { ROW_LIMIT_UNLIMITED = -1, BYTE_LIMIT_UNLIMITED = -1 };
|
|
|
|
|
|
|
|
int rows;
|
|
|
|
int minRows;
|
|
|
|
int bytes;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
GetRangeLimits() : rows(ROW_LIMIT_UNLIMITED), minRows(1), bytes(BYTE_LIMIT_UNLIMITED) {}
|
|
|
|
explicit GetRangeLimits(int rowLimit) : rows(rowLimit), minRows(1), bytes(BYTE_LIMIT_UNLIMITED) {}
|
|
|
|
GetRangeLimits(int rowLimit, int byteLimit) : rows(rowLimit), minRows(1), bytes(byteLimit) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void decrement(VectorRef<KeyValueRef> const& data);
|
|
|
|
void decrement(KeyValueRef const& data);
|
2022-03-11 02:05:44 +08:00
|
|
|
void decrement(VectorRef<MappedKeyValueRef> const& data);
|
|
|
|
void decrement(MappedKeyValueRef const& data);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
// True if either the row or byte limit has been reached
|
|
|
|
bool isReached();
|
|
|
|
|
|
|
|
// True if data would cause the row or byte limit to be reached
|
2021-03-11 02:06:03 +08:00
|
|
|
bool reachedBy(VectorRef<KeyValueRef> const& data);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
bool hasByteLimit();
|
|
|
|
bool hasRowLimit();
|
|
|
|
|
|
|
|
bool hasSatisfiedMinRows();
|
2020-06-21 10:03:33 +08:00
|
|
|
bool isValid() const {
|
|
|
|
return (rows >= 0 || rows == ROW_LIMIT_UNLIMITED) && (bytes >= 0 || bytes == BYTE_LIMIT_UNLIMITED) &&
|
|
|
|
minRows >= 0 && (minRows <= rows || rows == ROW_LIMIT_UNLIMITED);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RangeResultRef : VectorRef<KeyValueRef> {
|
2021-03-11 02:06:03 +08:00
|
|
|
bool more; // True if (but not necessarily only if) values remain in the *key* range requested (possibly beyond the
|
|
|
|
// limits requested) False implies that no such values remain
|
|
|
|
Optional<KeyRef> readThrough; // Only present when 'more' is true. When present, this value represent the end (or
|
|
|
|
// beginning if reverse) of the range which was read to produce these results. This is
|
2022-03-15 07:33:09 +08:00
|
|
|
// guaranteed to be less than the requested range.
|
2017-05-26 04:48:44 +08:00
|
|
|
bool readToBegin;
|
|
|
|
bool readThroughEnd;
|
|
|
|
|
|
|
|
RangeResultRef() : more(false), readToBegin(false), readThroughEnd(false) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
RangeResultRef(Arena& p, const RangeResultRef& toCopy)
|
2021-07-23 13:48:27 +08:00
|
|
|
: VectorRef<KeyValueRef>(p, toCopy), more(toCopy.more),
|
2021-03-11 02:06:03 +08:00
|
|
|
readThrough(toCopy.readThrough.present() ? KeyRef(p, toCopy.readThrough.get()) : Optional<KeyRef>()),
|
2021-07-23 13:48:27 +08:00
|
|
|
readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
RangeResultRef(const VectorRef<KeyValueRef>& value, bool more, Optional<KeyRef> readThrough = Optional<KeyRef>())
|
|
|
|
: VectorRef<KeyValueRef>(value), more(more), readThrough(readThrough), readToBegin(false), readThroughEnd(false) {
|
|
|
|
}
|
|
|
|
RangeResultRef(bool readToBegin, bool readThroughEnd)
|
|
|
|
: more(false), readToBegin(readToBegin), readThroughEnd(readThroughEnd) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, ((VectorRef<KeyValueRef>&)*this), more, readThrough, readToBegin, readThroughEnd);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
2018-11-30 02:31:47 +08:00
|
|
|
|
2021-12-18 07:56:07 +08:00
|
|
|
int logicalSize() const {
|
|
|
|
return VectorRef<KeyValueRef>::expectedSize() - VectorRef<KeyValueRef>::size() * sizeof(KeyValueRef);
|
|
|
|
}
|
|
|
|
|
2018-11-30 02:31:47 +08:00
|
|
|
std::string toString() const {
|
2019-08-02 08:00:13 +08:00
|
|
|
return "more:" + std::to_string(more) +
|
|
|
|
" readThrough:" + (readThrough.present() ? readThrough.get().toString() : "[unset]") +
|
|
|
|
" readToBegin:" + std::to_string(readToBegin) + " readThroughEnd:" + std::to_string(readThroughEnd);
|
2018-11-30 02:31:47 +08:00
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-03-19 11:27:34 +08:00
|
|
|
struct Traceable<RangeResultRef> : std::true_type {
|
|
|
|
static std::string toString(const RangeResultRef& value) {
|
|
|
|
return Traceable<VectorRef<KeyValueRef>>::toString(value);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2022-03-11 02:05:44 +08:00
|
|
|
// Similar to KeyValueRef, but result can be empty.
|
|
|
|
struct GetValueReqAndResultRef {
|
|
|
|
KeyRef key;
|
|
|
|
Optional<ValueRef> result;
|
|
|
|
|
|
|
|
GetValueReqAndResultRef() {}
|
|
|
|
GetValueReqAndResultRef(Arena& a, const GetValueReqAndResultRef& copyFrom)
|
|
|
|
: key(a, copyFrom.key), result(a, copyFrom.result) {}
|
|
|
|
|
|
|
|
bool operator==(const GetValueReqAndResultRef& rhs) const { return key == rhs.key && result == rhs.result; }
|
|
|
|
bool operator!=(const GetValueReqAndResultRef& rhs) const { return !(rhs == *this); }
|
|
|
|
int expectedSize() const { return key.expectedSize() + result.expectedSize(); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, key, result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct GetRangeReqAndResultRef {
|
|
|
|
KeySelectorRef begin, end;
|
|
|
|
RangeResultRef result;
|
|
|
|
|
|
|
|
GetRangeReqAndResultRef() {}
|
|
|
|
// KeyValueRef(const KeyRef& key, const ValueRef& value) : key(key), value(value) {}
|
|
|
|
GetRangeReqAndResultRef(Arena& a, const GetRangeReqAndResultRef& copyFrom)
|
|
|
|
: begin(a, copyFrom.begin), end(a, copyFrom.end), result(a, copyFrom.result) {}
|
|
|
|
|
|
|
|
bool operator==(const GetRangeReqAndResultRef& rhs) const {
|
|
|
|
return begin == rhs.begin && end == rhs.end && result == rhs.result;
|
|
|
|
}
|
|
|
|
bool operator!=(const GetRangeReqAndResultRef& rhs) const { return !(rhs == *this); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, begin, end, result);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
using MappedReqAndResultRef = std::variant<GetValueReqAndResultRef, GetRangeReqAndResultRef>;
|
|
|
|
|
|
|
|
struct MappedKeyValueRef : KeyValueRef {
|
|
|
|
// Save the original key value at the base (KeyValueRef).
|
|
|
|
|
|
|
|
MappedReqAndResultRef reqAndResult;
|
|
|
|
|
|
|
|
MappedKeyValueRef() = default;
|
|
|
|
MappedKeyValueRef(Arena& a, const MappedKeyValueRef& copyFrom) : KeyValueRef(a, copyFrom) {
|
|
|
|
const auto& reqAndResultCopyFrom = copyFrom.reqAndResult;
|
|
|
|
if (std::holds_alternative<GetValueReqAndResultRef>(reqAndResultCopyFrom)) {
|
|
|
|
auto getValue = std::get<GetValueReqAndResultRef>(reqAndResultCopyFrom);
|
|
|
|
reqAndResult = GetValueReqAndResultRef(a, getValue);
|
|
|
|
} else if (std::holds_alternative<GetRangeReqAndResultRef>(reqAndResultCopyFrom)) {
|
|
|
|
auto getRange = std::get<GetRangeReqAndResultRef>(reqAndResultCopyFrom);
|
|
|
|
reqAndResult = GetRangeReqAndResultRef(a, getRange);
|
|
|
|
} else {
|
|
|
|
throw internal_error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const MappedKeyValueRef& rhs) const {
|
|
|
|
return static_cast<const KeyValueRef&>(*this) == static_cast<const KeyValueRef&>(rhs) &&
|
|
|
|
reqAndResult == rhs.reqAndResult;
|
|
|
|
}
|
|
|
|
bool operator!=(const MappedKeyValueRef& rhs) const { return !(rhs == *this); }
|
|
|
|
|
|
|
|
// It relies on the base to provide the expectedSize. TODO: Consider add the underlying request and key values into
|
|
|
|
// expected size?
|
|
|
|
// int expectedSize() const { return ((KeyValueRef*)this)->expectedSisze() + reqA }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, ((KeyValueRef&)*this), reqAndResult);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct MappedRangeResultRef : VectorRef<MappedKeyValueRef> {
|
|
|
|
// Additional information on range result. See comments on RangeResultRef.
|
|
|
|
bool more;
|
|
|
|
Optional<KeyRef> readThrough;
|
|
|
|
bool readToBegin;
|
|
|
|
bool readThroughEnd;
|
|
|
|
|
|
|
|
MappedRangeResultRef() : more(false), readToBegin(false), readThroughEnd(false) {}
|
|
|
|
MappedRangeResultRef(Arena& p, const MappedRangeResultRef& toCopy)
|
|
|
|
: VectorRef<MappedKeyValueRef>(p, toCopy), more(toCopy.more),
|
|
|
|
readThrough(toCopy.readThrough.present() ? KeyRef(p, toCopy.readThrough.get()) : Optional<KeyRef>()),
|
|
|
|
readToBegin(toCopy.readToBegin), readThroughEnd(toCopy.readThroughEnd) {}
|
|
|
|
MappedRangeResultRef(const VectorRef<MappedKeyValueRef>& value,
|
|
|
|
bool more,
|
|
|
|
Optional<KeyRef> readThrough = Optional<KeyRef>())
|
|
|
|
: VectorRef<MappedKeyValueRef>(value), more(more), readThrough(readThrough), readToBegin(false),
|
|
|
|
readThroughEnd(false) {}
|
|
|
|
MappedRangeResultRef(bool readToBegin, bool readThroughEnd)
|
|
|
|
: more(false), readToBegin(readToBegin), readThroughEnd(readThroughEnd) {}
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, ((VectorRef<MappedKeyValueRef>&)*this), more, readThrough, readToBegin, readThroughEnd);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
return "more:" + std::to_string(more) +
|
|
|
|
" readThrough:" + (readThrough.present() ? readThrough.get().toString() : "[unset]") +
|
|
|
|
" readToBegin:" + std::to_string(readToBegin) + " readThroughEnd:" + std::to_string(readThroughEnd);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-05-26 04:48:44 +08:00
|
|
|
struct KeyValueStoreType {
|
2019-01-31 05:53:23 +08:00
|
|
|
constexpr static FileIdentifier file_identifier = 6560359;
|
2019-08-13 01:08:12 +08:00
|
|
|
// These enumerated values are stored in the database configuration, so should NEVER be changed.
|
|
|
|
// Only add new ones just before END.
|
|
|
|
// SS storeType is END before the storageServerInterface is initialized.
|
2021-03-11 02:06:03 +08:00
|
|
|
enum StoreType { SSD_BTREE_V1, MEMORY, SSD_BTREE_V2, SSD_REDWOOD_V1, MEMORY_RADIXTREE, SSD_ROCKSDB_V1, END };
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
KeyValueStoreType() : type(END) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
KeyValueStoreType(StoreType type) : type(type) {
|
2017-05-26 04:48:44 +08:00
|
|
|
if ((uint32_t)type > END)
|
|
|
|
this->type = END;
|
|
|
|
}
|
|
|
|
operator StoreType() const { return StoreType(type); }
|
2020-02-05 03:03:43 +08:00
|
|
|
StoreType storeType() const { return StoreType(type); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, type);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
std::string toString() const {
|
2021-03-11 02:06:03 +08:00
|
|
|
switch (type) {
|
|
|
|
case SSD_BTREE_V1:
|
|
|
|
return "ssd-1";
|
|
|
|
case SSD_BTREE_V2:
|
|
|
|
return "ssd-2";
|
|
|
|
case SSD_REDWOOD_V1:
|
2021-11-16 18:15:22 +08:00
|
|
|
return "ssd-redwood-1-experimental";
|
2021-03-11 02:06:03 +08:00
|
|
|
case SSD_ROCKSDB_V1:
|
|
|
|
return "ssd-rocksdb-experimental";
|
|
|
|
case MEMORY:
|
|
|
|
return "memory";
|
|
|
|
case MEMORY_RADIXTREE:
|
|
|
|
return "memory-radixtree-beta";
|
|
|
|
default:
|
|
|
|
return "unknown";
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
uint32_t type;
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-03-15 09:40:28 +08:00
|
|
|
struct Traceable<KeyValueStoreType> : std::true_type {
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toString(KeyValueStoreType const& value) { return value.toString(); }
|
2019-03-15 09:40:28 +08:00
|
|
|
};
|
|
|
|
|
2019-02-23 04:15:23 +08:00
|
|
|
struct TLogVersion {
|
|
|
|
enum Version {
|
|
|
|
UNSET = 0,
|
|
|
|
// Everything between BEGIN and END should be densely packed, so that we
|
|
|
|
// can iterate over them easily.
|
2020-03-21 09:39:51 +08:00
|
|
|
// V3 was the introduction of spill by reference;
|
|
|
|
// V4 changed how data gets written to satellite TLogs so that we can peek from them;
|
|
|
|
// V5 merged reference and value spilling
|
2020-09-05 07:57:36 +08:00
|
|
|
// V6 added span context to list of serialized mutations sent from proxy to tlogs
|
2022-02-04 06:26:10 +08:00
|
|
|
// V7 use xxhash3 for TLog checksum
|
2019-02-23 04:15:23 +08:00
|
|
|
// V1 = 1, // 4.6 is dispatched to via 6.0
|
|
|
|
V2 = 2, // 6.0
|
|
|
|
V3 = 3, // 6.1
|
2019-07-09 13:22:45 +08:00
|
|
|
V4 = 4, // 6.2
|
2020-05-15 09:39:46 +08:00
|
|
|
V5 = 5, // 6.3
|
2020-09-05 07:57:36 +08:00
|
|
|
V6 = 6, // 7.0
|
2022-02-04 06:26:10 +08:00
|
|
|
V7 = 7, // 7.2
|
2019-02-23 04:15:23 +08:00
|
|
|
MIN_SUPPORTED = V2,
|
2022-02-04 06:26:10 +08:00
|
|
|
MAX_SUPPORTED = V7,
|
|
|
|
MIN_RECRUITABLE = V6,
|
|
|
|
DEFAULT = V6,
|
2019-02-23 04:15:23 +08:00
|
|
|
} version;
|
|
|
|
|
|
|
|
TLogVersion() : version(UNSET) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
TLogVersion(Version v) : version(v) {}
|
2019-02-23 04:15:23 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
operator Version() const { return version; }
|
2019-02-23 04:15:23 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
uint32_t v = (uint32_t)version;
|
|
|
|
serializer(ar, v);
|
|
|
|
version = (Version)v;
|
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static ErrorOr<TLogVersion> FromStringRef(StringRef s) {
|
|
|
|
if (s == LiteralStringRef("2"))
|
|
|
|
return V2;
|
|
|
|
if (s == LiteralStringRef("3"))
|
|
|
|
return V3;
|
|
|
|
if (s == LiteralStringRef("4"))
|
|
|
|
return V4;
|
|
|
|
if (s == LiteralStringRef("5"))
|
|
|
|
return V5;
|
|
|
|
if (s == LiteralStringRef("6"))
|
|
|
|
return V6;
|
2022-02-04 06:26:10 +08:00
|
|
|
if (s == LiteralStringRef("7"))
|
|
|
|
return V7;
|
2019-02-23 04:15:23 +08:00
|
|
|
return default_error_or();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
template <>
|
2019-03-15 09:40:28 +08:00
|
|
|
struct Traceable<TLogVersion> : std::true_type {
|
2021-03-11 02:06:03 +08:00
|
|
|
static std::string toString(TLogVersion const& value) { return Traceable<Version>::toString(value.version); }
|
2019-03-15 09:40:28 +08:00
|
|
|
};
|
|
|
|
|
2019-02-08 09:02:46 +08:00
|
|
|
struct TLogSpillType {
|
2021-03-11 02:06:03 +08:00
|
|
|
// These enumerated values are stored in the database configuration, so can NEVER be changed. Only add new ones
|
|
|
|
// just before END.
|
2019-02-08 09:02:46 +08:00
|
|
|
enum SpillType {
|
2019-02-20 14:04:09 +08:00
|
|
|
UNSET = 0,
|
2019-06-20 07:57:59 +08:00
|
|
|
DEFAULT = 2,
|
2019-02-08 09:02:46 +08:00
|
|
|
VALUE = 1,
|
|
|
|
REFERENCE = 2,
|
2019-02-20 14:04:09 +08:00
|
|
|
END = 3,
|
2019-02-08 09:02:46 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
TLogSpillType() : type(DEFAULT) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
TLogSpillType(SpillType type) : type(type) {
|
2019-02-20 14:04:09 +08:00
|
|
|
if ((uint32_t)type >= END) {
|
2019-02-08 09:02:46 +08:00
|
|
|
this->type = UNSET;
|
2019-02-20 14:04:09 +08:00
|
|
|
}
|
2019-02-08 09:02:46 +08:00
|
|
|
}
|
|
|
|
operator SpillType() const { return SpillType(type); }
|
|
|
|
|
|
|
|
template <class Ar>
|
2021-03-11 02:06:03 +08:00
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, type);
|
|
|
|
}
|
2019-02-08 09:02:46 +08:00
|
|
|
|
|
|
|
std::string toString() const {
|
2021-03-11 02:06:03 +08:00
|
|
|
switch (type) {
|
|
|
|
case VALUE:
|
|
|
|
return "value";
|
|
|
|
case REFERENCE:
|
|
|
|
return "reference";
|
|
|
|
case UNSET:
|
|
|
|
return "unset";
|
|
|
|
default:
|
|
|
|
ASSERT(false);
|
2019-02-08 09:02:46 +08:00
|
|
|
}
|
2019-02-20 14:04:09 +08:00
|
|
|
return "";
|
2019-02-08 09:02:46 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static ErrorOr<TLogSpillType> FromStringRef(StringRef s) {
|
|
|
|
if (s == LiteralStringRef("1"))
|
|
|
|
return VALUE;
|
|
|
|
if (s == LiteralStringRef("2"))
|
|
|
|
return REFERENCE;
|
2019-02-23 04:15:23 +08:00
|
|
|
return default_error_or();
|
|
|
|
}
|
|
|
|
|
2019-02-08 09:02:46 +08:00
|
|
|
uint32_t type;
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// Contains the amount of free and total space for a storage server, in bytes
|
2017-05-26 04:48:44 +08:00
|
|
|
struct StorageBytes {
|
2021-04-08 14:56:20 +08:00
|
|
|
// Free space on the filesystem
|
2017-05-26 04:48:44 +08:00
|
|
|
int64_t free;
|
2021-04-08 14:56:20 +08:00
|
|
|
// Total space on the filesystem
|
2017-05-26 04:48:44 +08:00
|
|
|
int64_t total;
|
2021-04-08 14:56:20 +08:00
|
|
|
// Used by *this* store, not total - free
|
|
|
|
int64_t used;
|
|
|
|
// Amount of space available for use by the store, which includes free space on the filesystem
|
|
|
|
// and internal free space within the store data that is immediately reusable.
|
|
|
|
int64_t available;
|
|
|
|
// Amount of space that could eventually be available for use after garbage collection
|
|
|
|
int64_t temp;
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
StorageBytes() {}
|
2021-04-08 14:56:20 +08:00
|
|
|
StorageBytes(int64_t free, int64_t total, int64_t used, int64_t available, int64_t temp = 0)
|
|
|
|
: free(free), total(total), used(used), available(available), temp(temp) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, free, total, used, available);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-04-08 11:14:16 +08:00
|
|
|
std::string toString() const {
|
2021-04-08 14:56:20 +08:00
|
|
|
return format("{%.2f MB total, %.2f MB free, %.2f MB available, %.2f MB used, %.2f MB temp}",
|
2021-04-08 11:14:16 +08:00
|
|
|
total / 1e6,
|
|
|
|
free / 1e6,
|
|
|
|
available / 1e6,
|
2021-04-08 14:56:20 +08:00
|
|
|
used / 1e6,
|
|
|
|
temp / 1e6);
|
2021-04-08 11:14:16 +08:00
|
|
|
}
|
2021-09-29 09:07:30 +08:00
|
|
|
|
|
|
|
void toTraceEvent(TraceEvent& e) const {
|
|
|
|
e.detail("StorageBytesUsed", used)
|
|
|
|
.detail("StorageBytesTemp", temp)
|
|
|
|
.detail("StorageBytesTotal", total)
|
|
|
|
.detail("StorageBytesFree", free)
|
|
|
|
.detail("StorageBytesAvailable", available);
|
|
|
|
}
|
2021-04-08 11:14:16 +08:00
|
|
|
};
|
2017-05-26 04:48:44 +08:00
|
|
|
struct LogMessageVersion {
|
|
|
|
// Each message pushed into the log system has a unique, totally ordered LogMessageVersion
|
|
|
|
// See ILogSystem::push() for how these are assigned
|
|
|
|
Version version;
|
|
|
|
uint32_t sub;
|
|
|
|
|
|
|
|
void reset(Version v) {
|
|
|
|
version = v;
|
|
|
|
sub = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator<(LogMessageVersion const& r) const {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (version < r.version)
|
|
|
|
return true;
|
|
|
|
if (r.version < version)
|
|
|
|
return false;
|
2017-05-26 04:48:44 +08:00
|
|
|
return sub < r.sub;
|
|
|
|
}
|
2020-07-11 05:37:47 +08:00
|
|
|
bool operator>(LogMessageVersion const& r) const { return r < *this; }
|
|
|
|
bool operator<=(LogMessageVersion const& r) const { return !(*this > r); }
|
|
|
|
bool operator>=(LogMessageVersion const& r) const { return !(*this < r); }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
bool operator==(LogMessageVersion const& r) const { return version == r.version && sub == r.sub; }
|
|
|
|
|
|
|
|
std::string toString() const { return format("%lld.%d", version, sub); }
|
|
|
|
|
|
|
|
LogMessageVersion(Version version, uint32_t sub) : version(version), sub(sub) {}
|
|
|
|
explicit LogMessageVersion(Version version) : version(version), sub(0) {}
|
|
|
|
LogMessageVersion() : version(0), sub(0) {}
|
|
|
|
bool empty() const { return (version == 0) && (sub == 0); }
|
2020-04-12 13:31:55 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, version, sub);
|
|
|
|
}
|
2017-05-26 04:48:44 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
struct AddressExclusion {
|
2019-02-27 10:04:03 +08:00
|
|
|
IPAddress ip;
|
2017-05-26 04:48:44 +08:00
|
|
|
int port;
|
|
|
|
|
|
|
|
AddressExclusion() : ip(0), port(0) {}
|
2019-02-27 10:04:03 +08:00
|
|
|
explicit AddressExclusion(const IPAddress& ip) : ip(ip), port(0) {}
|
|
|
|
explicit AddressExclusion(const IPAddress& ip, int port) : ip(ip), port(port) {}
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2019-02-27 10:04:03 +08:00
|
|
|
bool operator<(AddressExclusion const& r) const {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (ip != r.ip)
|
|
|
|
return ip < r.ip;
|
2019-02-27 10:04:03 +08:00
|
|
|
return port < r.port;
|
|
|
|
}
|
|
|
|
bool operator==(AddressExclusion const& r) const { return ip == r.ip && port == r.port; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
bool isWholeMachine() const { return port == 0; }
|
2019-02-27 10:04:03 +08:00
|
|
|
bool isValid() const { return ip.isValid() || port != 0; }
|
2017-05-26 04:48:44 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool excludes(NetworkAddress const& addr) const {
|
|
|
|
if (isWholeMachine())
|
2017-05-26 04:48:44 +08:00
|
|
|
return ip == addr.ip;
|
|
|
|
return ip == addr.ip && port == addr.port;
|
|
|
|
}
|
|
|
|
|
|
|
|
// This is for debugging and IS NOT to be used for serialization to persistant state
|
|
|
|
std::string toString() const {
|
2019-02-28 18:37:21 +08:00
|
|
|
if (!isWholeMachine())
|
|
|
|
return formatIpPort(ip, port);
|
|
|
|
return ip.toString();
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
static AddressExclusion parse(StringRef const&);
|
2017-05-26 04:48:44 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2019-02-28 18:37:21 +08:00
|
|
|
serializer(ar, ip, port);
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline bool addressExcluded(std::set<AddressExclusion> const& exclusions, NetworkAddress const& addr) {
|
|
|
|
return exclusions.count(AddressExclusion(addr.ip, addr.port)) || exclusions.count(AddressExclusion(addr.ip));
|
2017-05-26 04:48:44 +08:00
|
|
|
}
|
|
|
|
|
2018-02-10 08:48:55 +08:00
|
|
|
struct ClusterControllerPriorityInfo {
|
2021-03-11 02:06:03 +08:00
|
|
|
enum DCFitness {
|
|
|
|
FitnessPrimary,
|
|
|
|
FitnessRemote,
|
|
|
|
FitnessPreferred,
|
|
|
|
FitnessUnknown,
|
|
|
|
FitnessNotPreferred,
|
|
|
|
FitnessBad
|
|
|
|
}; // cannot be larger than 7 because of leader election mask
|
2018-02-10 08:48:55 +08:00
|
|
|
|
2019-05-17 04:54:06 +08:00
|
|
|
static DCFitness calculateDCFitness(Optional<Key> const& dcId, std::vector<Optional<Key>> const& dcPriority) {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (!dcPriority.size()) {
|
2018-02-10 08:48:55 +08:00
|
|
|
return FitnessUnknown;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (dcPriority.size() == 1) {
|
|
|
|
if (dcId == dcPriority[0]) {
|
2018-02-10 08:48:55 +08:00
|
|
|
return FitnessPreferred;
|
|
|
|
} else {
|
2020-05-11 05:20:50 +08:00
|
|
|
return FitnessNotPreferred;
|
2018-02-10 08:48:55 +08:00
|
|
|
}
|
|
|
|
} else {
|
2021-03-11 02:06:03 +08:00
|
|
|
if (dcId == dcPriority[0]) {
|
2018-02-10 08:48:55 +08:00
|
|
|
return FitnessPrimary;
|
2021-03-11 02:06:03 +08:00
|
|
|
} else if (dcId == dcPriority[1]) {
|
2018-02-10 08:48:55 +08:00
|
|
|
return FitnessRemote;
|
|
|
|
} else {
|
|
|
|
return FitnessBad;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t processClassFitness;
|
|
|
|
bool isExcluded;
|
|
|
|
uint8_t dcFitness;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(ClusterControllerPriorityInfo const& r) const {
|
|
|
|
return processClassFitness == r.processClassFitness && isExcluded == r.isExcluded && dcFitness == r.dcFitness;
|
|
|
|
}
|
2020-07-11 05:37:47 +08:00
|
|
|
bool operator!=(ClusterControllerPriorityInfo const& r) const { return !(*this == r); }
|
2019-11-27 02:35:01 +08:00
|
|
|
ClusterControllerPriorityInfo()
|
2021-03-11 02:06:03 +08:00
|
|
|
: ClusterControllerPriorityInfo(/*ProcessClass::UnsetFit*/ 2,
|
|
|
|
false,
|
2019-11-27 02:35:01 +08:00
|
|
|
ClusterControllerPriorityInfo::FitnessUnknown) {}
|
2021-03-11 02:06:03 +08:00
|
|
|
ClusterControllerPriorityInfo(uint8_t processClassFitness, bool isExcluded, uint8_t dcFitness)
|
|
|
|
: processClassFitness(processClassFitness), isExcluded(isExcluded), dcFitness(dcFitness) {}
|
2018-02-10 08:48:55 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// To change this serialization, ProtocolVersion::ClusterControllerPriorityInfo must be updated, and downgrades need
|
|
|
|
// to be considered
|
2018-02-10 08:48:55 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2018-12-29 02:49:26 +08:00
|
|
|
serializer(ar, processClassFitness, isExcluded, dcFitness);
|
2018-02-10 08:48:55 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-11-30 02:31:47 +08:00
|
|
|
class Database;
|
|
|
|
|
2019-02-01 02:40:22 +08:00
|
|
|
struct HealthMetrics {
|
2019-02-21 03:57:41 +08:00
|
|
|
struct StorageStats {
|
|
|
|
int64_t storageQueue;
|
2019-02-28 08:30:01 +08:00
|
|
|
int64_t storageDurabilityLag;
|
2019-02-21 03:57:41 +08:00
|
|
|
double diskUsage;
|
|
|
|
double cpuUsage;
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
bool operator==(StorageStats const& r) const {
|
|
|
|
return ((storageQueue == r.storageQueue) && (storageDurabilityLag == r.storageDurabilityLag) &&
|
|
|
|
(diskUsage == r.diskUsage) && (cpuUsage == r.cpuUsage));
|
2019-02-22 07:50:17 +08:00
|
|
|
}
|
|
|
|
|
2019-02-21 03:57:41 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2019-02-28 08:30:01 +08:00
|
|
|
serializer(ar, storageQueue, storageDurabilityLag, diskUsage, cpuUsage);
|
2019-02-21 03:57:41 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-01 02:40:22 +08:00
|
|
|
int64_t worstStorageQueue;
|
2020-11-14 09:24:57 +08:00
|
|
|
int64_t limitingStorageQueue;
|
2019-02-28 08:30:01 +08:00
|
|
|
int64_t worstStorageDurabilityLag;
|
2020-11-14 09:24:57 +08:00
|
|
|
int64_t limitingStorageDurabilityLag;
|
2019-02-01 02:40:22 +08:00
|
|
|
int64_t worstTLogQueue;
|
|
|
|
double tpsLimit;
|
2019-03-08 02:15:28 +08:00
|
|
|
bool batchLimited;
|
2019-02-21 03:57:41 +08:00
|
|
|
std::map<UID, StorageStats> storageStats;
|
2019-02-01 02:40:22 +08:00
|
|
|
std::map<UID, int64_t> tLogQueue;
|
|
|
|
|
|
|
|
HealthMetrics()
|
2020-11-14 09:24:57 +08:00
|
|
|
: worstStorageQueue(0), limitingStorageQueue(0), worstStorageDurabilityLag(0), limitingStorageDurabilityLag(0),
|
|
|
|
worstTLogQueue(0), tpsLimit(0.0), batchLimited(false) {}
|
2019-02-01 02:40:22 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
void update(const HealthMetrics& hm, bool detailedInput, bool detailedOutput) {
|
2019-02-01 02:40:22 +08:00
|
|
|
worstStorageQueue = hm.worstStorageQueue;
|
2020-11-14 09:24:57 +08:00
|
|
|
limitingStorageQueue = hm.limitingStorageQueue;
|
2019-02-28 08:30:01 +08:00
|
|
|
worstStorageDurabilityLag = hm.worstStorageDurabilityLag;
|
2020-11-14 09:24:57 +08:00
|
|
|
limitingStorageDurabilityLag = hm.limitingStorageDurabilityLag;
|
2019-02-01 02:40:22 +08:00
|
|
|
worstTLogQueue = hm.worstTLogQueue;
|
|
|
|
tpsLimit = hm.tpsLimit;
|
2019-03-08 02:15:28 +08:00
|
|
|
batchLimited = hm.batchLimited;
|
2019-02-01 02:40:22 +08:00
|
|
|
|
|
|
|
if (!detailedOutput) {
|
2019-02-21 03:57:41 +08:00
|
|
|
storageStats.clear();
|
|
|
|
tLogQueue.clear();
|
2019-02-01 02:40:22 +08:00
|
|
|
} else if (detailedInput) {
|
2019-02-21 03:57:41 +08:00
|
|
|
storageStats = hm.storageStats;
|
2019-02-01 02:40:22 +08:00
|
|
|
tLogQueue = hm.tLogQueue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-22 07:50:17 +08:00
|
|
|
bool operator==(HealthMetrics const& r) const {
|
2020-11-14 09:24:57 +08:00
|
|
|
return (worstStorageQueue == r.worstStorageQueue && limitingStorageQueue == r.limitingStorageQueue &&
|
|
|
|
worstStorageDurabilityLag == r.worstStorageDurabilityLag &&
|
|
|
|
limitingStorageDurabilityLag == r.limitingStorageDurabilityLag && worstTLogQueue == r.worstTLogQueue &&
|
|
|
|
storageStats == r.storageStats && tLogQueue == r.tLogQueue && batchLimited == r.batchLimited);
|
2019-02-22 07:50:17 +08:00
|
|
|
}
|
|
|
|
|
2019-02-01 02:40:22 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2021-03-11 02:06:03 +08:00
|
|
|
serializer(ar,
|
|
|
|
worstStorageQueue,
|
|
|
|
worstStorageDurabilityLag,
|
|
|
|
worstTLogQueue,
|
|
|
|
tpsLimit,
|
|
|
|
batchLimited,
|
|
|
|
storageStats,
|
|
|
|
tLogQueue,
|
|
|
|
limitingStorageQueue,
|
|
|
|
limitingStorageDurabilityLag);
|
2019-02-01 02:40:22 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2020-05-09 08:17:27 +08:00
|
|
|
struct DDMetricsRef {
|
2019-06-12 06:45:06 +08:00
|
|
|
int64_t shardBytes;
|
|
|
|
KeyRef beginKey;
|
|
|
|
|
2020-05-09 08:17:27 +08:00
|
|
|
DDMetricsRef() : shardBytes(0) {}
|
2020-05-20 04:32:42 +08:00
|
|
|
DDMetricsRef(int64_t bytes, KeyRef begin) : shardBytes(bytes), beginKey(begin) {}
|
2020-05-09 08:17:27 +08:00
|
|
|
DDMetricsRef(Arena& a, const DDMetricsRef& copyFrom)
|
2020-05-20 04:32:42 +08:00
|
|
|
: shardBytes(copyFrom.shardBytes), beginKey(a, copyFrom.beginKey) {}
|
2019-06-12 06:45:06 +08:00
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-05-20 04:32:42 +08:00
|
|
|
serializer(ar, shardBytes, beginKey);
|
2019-06-12 06:45:06 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-07-30 01:37:42 +08:00
|
|
|
struct WorkerBackupStatus {
|
|
|
|
LogEpoch epoch;
|
|
|
|
Version version;
|
|
|
|
Tag tag;
|
2020-03-10 06:33:15 +08:00
|
|
|
int32_t totalTags;
|
2019-07-30 01:37:42 +08:00
|
|
|
|
|
|
|
WorkerBackupStatus() : epoch(0), version(invalidVersion) {}
|
2020-03-10 06:33:15 +08:00
|
|
|
WorkerBackupStatus(LogEpoch e, Version v, Tag t, int32_t total) : epoch(e), version(v), tag(t), totalTags(total) {}
|
2019-07-30 01:37:42 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
// To change this serialization, ProtocolVersion::BackupProgressValue must be updated, and downgrades need to be
|
|
|
|
// considered
|
2019-07-30 01:37:42 +08:00
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
2020-03-10 06:33:15 +08:00
|
|
|
serializer(ar, epoch, version, tag, totalTags);
|
2019-07-30 01:37:42 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
enum class TransactionPriority : uint8_t { BATCH, DEFAULT, IMMEDIATE, MIN = BATCH, MAX = IMMEDIATE };
|
2020-04-25 02:31:16 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
const std::array<TransactionPriority, (int)TransactionPriority::MAX + 1> allTransactionPriorities = {
|
|
|
|
TransactionPriority::BATCH,
|
|
|
|
TransactionPriority::DEFAULT,
|
|
|
|
TransactionPriority::IMMEDIATE
|
|
|
|
};
|
2020-04-25 02:31:16 +08:00
|
|
|
|
2021-03-11 02:06:03 +08:00
|
|
|
inline const char* transactionPriorityToString(TransactionPriority priority, bool capitalize = true) {
|
|
|
|
switch (priority) {
|
|
|
|
case TransactionPriority::BATCH:
|
|
|
|
return capitalize ? "Batch" : "batch";
|
|
|
|
case TransactionPriority::DEFAULT:
|
|
|
|
return capitalize ? "Default" : "default";
|
|
|
|
case TransactionPriority::IMMEDIATE:
|
|
|
|
return capitalize ? "Immediate" : "immediate";
|
2020-04-25 02:31:16 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(false);
|
|
|
|
throw internal_error();
|
|
|
|
}
|
|
|
|
|
2021-09-08 07:26:43 +08:00
|
|
|
struct StorageMigrationType {
|
|
|
|
// These enumerated values are stored in the database configuration, so can NEVER be changed. Only add new ones
|
|
|
|
// just before END.
|
|
|
|
enum MigrationType { DEFAULT = 1, UNSET = 0, DISABLED = 1, AGGRESSIVE = 2, GRADUAL = 3, END = 4 };
|
|
|
|
|
|
|
|
StorageMigrationType() : type(UNSET) {}
|
|
|
|
StorageMigrationType(MigrationType type) : type(type) {
|
|
|
|
if ((uint32_t)type >= END) {
|
|
|
|
this->type = UNSET;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
operator MigrationType() const { return MigrationType(type); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
switch (type) {
|
|
|
|
case DISABLED:
|
|
|
|
return "disabled";
|
|
|
|
case AGGRESSIVE:
|
|
|
|
return "aggressive";
|
|
|
|
case GRADUAL:
|
|
|
|
return "gradual";
|
|
|
|
case UNSET:
|
|
|
|
return "unset";
|
|
|
|
default:
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t type;
|
|
|
|
};
|
|
|
|
|
2022-02-19 13:22:31 +08:00
|
|
|
struct TenantMode {
|
|
|
|
// These enumerated values are stored in the database configuration, so can NEVER be changed. Only add new ones
|
|
|
|
// just before END.
|
2022-03-09 05:45:29 +08:00
|
|
|
// Note: OPTIONAL_TENANT is not named OPTIONAL because of a collision with a Windows macro.
|
|
|
|
enum Mode { DISABLED = 0, OPTIONAL_TENANT = 1, REQUIRED = 2, END = 3 };
|
2022-02-19 13:22:31 +08:00
|
|
|
|
2022-03-04 07:40:38 +08:00
|
|
|
TenantMode() : mode(DISABLED) {}
|
2022-02-19 13:22:31 +08:00
|
|
|
TenantMode(Mode mode) : mode(mode) {
|
|
|
|
if ((uint32_t)mode >= END) {
|
2022-03-04 07:40:38 +08:00
|
|
|
this->mode = DISABLED;
|
2022-02-19 13:22:31 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
operator Mode() const { return Mode(mode); }
|
|
|
|
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, mode);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string toString() const {
|
|
|
|
switch (mode) {
|
2022-03-04 07:40:38 +08:00
|
|
|
case DISABLED:
|
|
|
|
return "disabled";
|
2022-03-09 05:45:29 +08:00
|
|
|
case OPTIONAL_TENANT:
|
2022-03-04 07:40:38 +08:00
|
|
|
return "optional_experimental";
|
2022-02-19 13:22:31 +08:00
|
|
|
case REQUIRED:
|
2022-03-04 07:40:38 +08:00
|
|
|
return "required_experimental";
|
2022-02-19 13:22:31 +08:00
|
|
|
default:
|
|
|
|
ASSERT(false);
|
|
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t mode;
|
|
|
|
};
|
|
|
|
|
2021-09-18 01:16:26 +08:00
|
|
|
inline bool isValidPerpetualStorageWiggleLocality(std::string locality) {
|
|
|
|
int pos = locality.find(':');
|
|
|
|
// locality should be either 0 or in the format '<non_empty_string>:<non_empty_string>'
|
2021-09-30 21:33:16 +08:00
|
|
|
return ((pos > 0 && pos < locality.size() - 1) || locality == "0");
|
2021-09-18 01:16:26 +08:00
|
|
|
}
|
|
|
|
|
2021-11-02 23:01:23 +08:00
|
|
|
// matches what's in fdb_c.h
|
|
|
|
struct ReadBlobGranuleContext {
|
2021-12-02 07:20:11 +08:00
|
|
|
// User context to pass along to functions
|
2021-11-02 23:01:23 +08:00
|
|
|
void* userContext;
|
2021-12-02 07:20:11 +08:00
|
|
|
|
2021-12-02 07:04:55 +08:00
|
|
|
// Returns a unique id for the load. Asynchronous to support queueing multiple in parallel.
|
|
|
|
int64_t (*start_load_f)(const char* filename, int filenameLength, int64_t offset, int64_t length, void* context);
|
|
|
|
|
|
|
|
// Returns data for the load. Pass the loadId returned by start_load_f
|
|
|
|
uint8_t* (*get_load_f)(int64_t loadId, void* context);
|
|
|
|
|
|
|
|
// Frees data from load. Pass the loadId returned by start_load_f
|
|
|
|
void (*free_load_f)(int64_t loadId, void* context);
|
|
|
|
|
2021-11-09 02:24:45 +08:00
|
|
|
// Set this to true for testing if you don't want to read the granule files,
|
|
|
|
// just do the request to the blob workers
|
|
|
|
bool debugNoMaterialize;
|
2021-11-02 23:01:23 +08:00
|
|
|
};
|
|
|
|
|
2022-02-05 07:04:30 +08:00
|
|
|
// Store metadata associated with each storage server. Now it only contains data be used in perpetual storage wiggle.
|
|
|
|
struct StorageMetadataType {
|
|
|
|
constexpr static FileIdentifier file_identifier = 732123;
|
|
|
|
// when the SS is initialized
|
2022-02-26 04:54:31 +08:00
|
|
|
uint64_t createdTime; // comes from currentTime()
|
2022-02-05 07:04:30 +08:00
|
|
|
StorageMetadataType() : createdTime(0) {}
|
|
|
|
StorageMetadataType(uint64_t t) : createdTime(t) {}
|
|
|
|
|
2022-02-26 04:54:31 +08:00
|
|
|
static uint64_t currentTime() { return g_network->timer() * 1e9; }
|
|
|
|
|
2022-02-05 07:04:30 +08:00
|
|
|
// To change this serialization, ProtocolVersion::StorageMetadata must be updated, and downgrades need
|
|
|
|
// to be considered
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, createdTime);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// store metadata of wiggle action
|
|
|
|
struct StorageWiggleValue {
|
|
|
|
constexpr static FileIdentifier file_identifier = 732124;
|
|
|
|
UID id; // storage id
|
|
|
|
|
|
|
|
StorageWiggleValue(UID id = UID(0, 0)) : id(id) {}
|
|
|
|
|
|
|
|
// To change this serialization, ProtocolVersion::PerpetualWiggleMetadata must be updated, and downgrades need
|
|
|
|
// to be considered
|
|
|
|
template <class Ar>
|
|
|
|
void serialize(Ar& ar) {
|
|
|
|
serializer(ar, id);
|
|
|
|
}
|
|
|
|
};
|
2017-05-26 04:48:44 +08:00
|
|
|
#endif
|