HolyLow commented on code in PR #3410:
URL: https://github.com/apache/celeborn/pull/3410#discussion_r2265932601


##########
cpp/celeborn/protocol/ControlMessages.cpp:
##########
@@ -20,6 +20,84 @@
 
 namespace celeborn {
 namespace protocol {
+
+namespace {
+std::vector<std::unique_ptr<const PartitionLocation>>
+fromPbPackedPartitionLocationsPair(
+    const PbPackedPartitionLocationsPair& pbPackedPartitionLocationsPair) {
+  std::vector<std::unique_ptr<const PartitionLocation>> finalLocations;
+  std::vector<std::unique_ptr<PartitionLocation>> partialLocations;
+  int inputLocationSize = pbPackedPartitionLocationsPair.inputlocationsize();
+  auto& pbPackedPartitionLocations = 
pbPackedPartitionLocationsPair.locations();
+  auto& pbIds = pbPackedPartitionLocations.ids();
+  for (int idx = 0; idx < pbIds.size(); idx++) {
+    partialLocations.push_back(
+        PartitionLocation::fromPackedPb(pbPackedPartitionLocations, idx));
+  }
+  for (int idx = 0; idx < inputLocationSize; idx++) {
+    auto replicaIdx = pbPackedPartitionLocationsPair.peerindexes(idx);
+    // Has peer.
+    if (replicaIdx != INT_MAX) {
+      CELEBORN_CHECK_GE(replicaIdx, inputLocationSize);
+      CELEBORN_CHECK_LT(replicaIdx, partialLocations.size());
+      auto location = std::move(partialLocations[idx]);
+      auto peerLocation = std::move(partialLocations[replicaIdx]);
+      // Make sure the location is primary and peer location is replica.
+      if (location->mode == PartitionLocation::Mode::REPLICA) {
+        std::swap(location, peerLocation);
+      }
+      CELEBORN_CHECK(location->mode == PartitionLocation::Mode::PRIMARY);
+      CELEBORN_CHECK(peerLocation->mode == PartitionLocation::Mode::REPLICA);
+      location->replicaPeer = std::move(peerLocation);
+      finalLocations.push_back(std::move(location));
+    }
+    // Has no peer.
+    else {
+      finalLocations.push_back(std::move(partialLocations[idx]));
+    }
+  }
+  return finalLocations;
+}
+
+} // namespace
+
+TransportMessage RegisterShuffle::toTransportMessage() const {
+  MessageType type = REGISTER_SHUFFLE;
+  PbRegisterShuffle pb;
+  pb.set_shuffleid(shuffleId);

Review Comment:
   Though this won't be a problem, we should align the type of shuffleId to int 
rather than long.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to