38 namespace RangeServerRecovery {
40 void ReplayPlan::insert(int32_t fragment,
const String &location) {
43 auto fragment_it = fragment_index.find(entry.
fragment);
44 if (fragment_it != fragment_index.end())
45 container.erase(fragment_it);
46 container.insert(entry);
49 void ReplayPlan::remove_location(
const String &location) {
51 pair<FragmentReplayPlanLocationIndex::const_iterator, FragmentReplayPlanLocationIndex::const_iterator> bounds =
52 location_index.equal_range(location);
53 auto iter = bounds.first;
54 while (iter != bounds.second)
55 iter = location_index.erase(iter);
58 void ReplayPlan::get_fragments(vector<int32_t> &fragments)
const {
60 for (
auto & entry : fragment_index)
61 fragments.push_back(entry.fragment);
64 void ReplayPlan::get_fragments(
const String &location,
65 vector<int32_t> &fragments)
const {
67 pair<FragmentReplayPlanLocationIndex::const_iterator, FragmentReplayPlanLocationIndex::const_iterator> bounds =
68 location_index.equal_range(location);
69 for (
auto iter = bounds.first; iter != bounds.second; ++iter)
70 fragments.push_back(iter->fragment);
73 void ReplayPlan::get_locations(
StringSet &locations)
const {
76 for (
auto & entry : location_index) {
77 if (entry.location != last_location) {
78 last_location = entry.location;
79 locations.insert(last_location);
84 bool ReplayPlan::get_location(int32_t fragment,
String &location)
const {
86 auto fragment_it = fragment_index.find(fragment);
88 if (fragment_it != fragment_index.end()) {
89 location = fragment_it->location;
95 uint8_t ReplayPlan::encoding_version()
const {
99 size_t ReplayPlan::encoded_length_internal()
const {
102 for (
auto & entry : location_index)
103 length += entry.encoded_length();
126 void ReplayPlan::encode_internal(uint8_t **bufp)
const {
129 for (
auto & entry : location_index)
133 void ReplayPlan::decode_internal(uint8_t version,
const uint8_t **bufp,
136 for (
size_t i=0; i<count; ++i) {
138 entry.
decode(bufp, remainp);
139 container.insert(entry);
std::set< String > StringSet
STL Set managing Strings.
std::string String
A String is simply a typedef to std::string.
Declarations for ReplayPlan.
uint32_t decode_i32(const uint8_t **bufp, size_t *remainp)
Decode a 32-bit integer in little-endian order.
void encode_i32(uint8_t **bufp, uint32_t val)
Encode a 32-bit integer in little-endian order.
Compatibility Macros for C/C++.
Functions to serialize/deserialize primitives to/from a memory buffer.
virtual void decode(const uint8_t **bufp, size_t *remainp)
Reads serialized representation of object from a buffer.