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


##########
cpp/celeborn/protocol/ControlMessages.h:
##########
@@ -26,6 +26,23 @@
 
 namespace celeborn {
 namespace protocol {
+
+struct RegisterShuffle {
+  long shuffleId;

Review Comment:
   According to the protobuf definition, the first field should be an int 
instead of a long.



##########
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:
   Will this be a problem because this place changes a large type to a small 
type (casting long to int)?



-- 
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