diff --git a/fdbclient/SystemData.cpp b/fdbclient/SystemData.cpp index a810808139..6c71afde56 100644 --- a/fdbclient/SystemData.cpp +++ b/fdbclient/SystemData.cpp @@ -1341,26 +1341,22 @@ Key uidPrefixKey(KeyRef keyPrefix, UID logUid) { return bw.toValue(); } -std::tuple decodeConstructKeys(KeyRef keyValue) { - uint64_t start, stop, length; - BinaryReader rd(keyValue.removePrefix(constructDataKey), Unversioned()); - rd >> start; - start = stop = length = 0; - rd >> stop; - rd >> length; - return std::make_tuple(start, stop, length); +std::tuple, uint64_t, uint64_t> decodeConstructKeys(ValueRef value) { + StringRef keyStart; + uint64_t keySize, keyCount; + BinaryReader rd(value, Unversioned()); + rd >> keyStart; + rd >> keySize; + rd >> keyCount; + return std::make_tuple(keyStart, keySize, keyCount); } -Value encodeConstructKeys(uint64_t keyNum) { +Value encodeConstructValue(StringRef keyStart, uint64_t keySize, uint64_t keyCount, uint64_t seed) { BinaryWriter wr(Unversioned()); - wr.serializeBytes("\xbf/constructData/"_sr); - wr << bigEndian64(keyNum); - return wr.toValue(); -} - -Value encodeConstructValue(uint64_t seed) { - BinaryWriter wr(Unversioned()); - wr << bigEndian64(seed); + wr << keyStart; + wr << keySize; + wr << keyCount; + // wr << seed; return wr.toValue(); } diff --git a/fdbclient/include/fdbclient/SystemData.h b/fdbclient/include/fdbclient/SystemData.h index 9e4c0ba369..55d0e1af50 100644 --- a/fdbclient/include/fdbclient/SystemData.h +++ b/fdbclient/include/fdbclient/SystemData.h @@ -545,9 +545,8 @@ Key logRangesEncodeValue(KeyRef keyEnd, KeyRef destPath); // the given uid encoded at the end Key uidPrefixKey(KeyRef keyPrefix, UID logUid); -extern std::tuple decodeConstructKeys(KeyRef keyValue); -extern Value encodeConstructKeys(uint64_t keyNum); -extern Value encodeConstructValue(uint64_t seed); +extern std::tuple, uint64_t, uint64_t> decodeConstructKeys(ValueRef value); +extern Value encodeConstructValue(StringRef keyStart, uint64_t keySize, uint64_t keyCount, uint64_t seed); /// Apply mutations constant variables diff --git a/fdbserver/ApplyMetadataMutation.cpp b/fdbserver/ApplyMetadataMutation.cpp index a0e987b05e..e7f5232763 100644 --- a/fdbserver/ApplyMetadataMutation.cpp +++ b/fdbserver/ApplyMetadataMutation.cpp @@ -585,14 +585,19 @@ private: } if (m.param1.startsWith(constructDataKey)) { - std::tuple t = decodeConstructKeys(m.param1); - uint64_t first_element, second_element, third_element; - std::tie(first_element, second_element, third_element) = t; + TraceEvent("DANHERE").detail("V", m.param2); + // std::string safeLocality = BinaryReader::fromStringRef(m.param2, Unversioned()); + // TraceEvent("DANHERE2").detail("V",safeLocality); + + std::tuple, uint64_t, uint64_t> t = decodeConstructKeys(m.param2); + uint64_t second_element = std::get<1>(t), third_element = std::get<2>(t); + Standalone first_element = std::get<0>(t); + // m.param2 = encodelConstructValue("\xcf\xdf"_sr, second_element, third_element, 0); TraceEvent("DANHERE") .detail("F1", first_element) .detail("F2", second_element) .detail("F3", third_element) - .detail("S", m.param1.size()); + .detail("S", m.param2); } } diff --git a/fdbserver/storageserver.actor.cpp b/fdbserver/storageserver.actor.cpp index d5f40502bc..0602c4232f 100644 --- a/fdbserver/storageserver.actor.cpp +++ b/fdbserver/storageserver.actor.cpp @@ -1013,7 +1013,7 @@ public: pendingAddRanges; // Pending requests to add ranges to physical shards std::map> pendingRemoveRanges; // Pending requests to remove ranges from physical shards - std::deque constructedData; + std::deque, Standalone>> constructedData; bool shardAware; // True if the storage server is aware of the physical shards. @@ -10857,19 +10857,34 @@ private: } } } else if (m.param1.substr(1).startsWith(constructDataKey)) { - MutationRef constructedMutation; - constructedMutation.type = MutationRef::SetValue; - TraceEvent("DANCONSTRUCTSS2").detail("S", constructedMutation.param1.size()); - std::tuple t = decodeConstructKeys(m.param1.substr(1)); - uint64_t first_element, second_element, third_element; - std::tie(first_element, second_element, third_element) = t; - constructedMutation.param1 = "\xbf/constructData/"_sr; // encodeConstructKeys(first_element); - constructedMutation.param2 = encodeConstructValue(23); - data->constructedData.push_back(constructedMutation); + std::tuple, uint64_t, uint64_t> t = decodeConstructKeys(m.param2); + std::pair, Standalone> m; + uint64_t second_element, third_element; + std::tie(m.first, second_element, third_element) = t; + // constructedMutation.param1 = first_element; + m.second = "23"_sr; // ;//encodeConstructValue(23); + data->constructedData.push_back(m); TraceEvent("DANCONSTRUCTSS") - .detail("F1", first_element) + .detail("F1", data->constructedData.front().first) .detail("F2", second_element) .detail("F3", third_element); + // int seed=0; // from constructData + // for (int key=0; keyconstructedData.push_back(constructedMutation); + // TraceEvent("DANCONSTRUCTSS") + // .detail("F1", firstKey) + // .detail("F2", sizeValue) + // .detail("F3", numKeys); + // } } else { ASSERT(false); // Unknown private mutation } @@ -11350,7 +11365,10 @@ ACTOR Future update(StorageServer* data, bool* pReceivedUpdate) { } else if (ver != invalidVersion) { // This change belongs to a version < minVersion if (data->constructedData.size()) { - MutationRef constructedMutation = data->constructedData.front(); + MutationRef constructedMutation; + constructedMutation.type = MutationRef::SetValue; + constructedMutation.param1 = data->constructedData.front().first; + constructedMutation.param2 = data->constructedData.front().second; TraceEvent("DANPULL").detail("T", constructedMutation.param1); updater.applyMutation(data, constructedMutation, encryptedMutation, ver, false); data->constructedData.pop_front();