isapego commented on code in PR #7966:
URL: https://github.com/apache/ignite-3/pull/7966#discussion_r3080245315


##########
modules/platforms/cpp/ignite/protocol/messages.cpp:
##########
@@ -100,4 +100,39 @@ handshake_response parse_handshake_response(bytes_view 
message) {
     return res;
 }
 
+void write_partition_assignment_request(writer &writer, std::int32_t table_id, 
std::int64_t timestamp) {
+    writer.write(table_id);
+    writer.write(timestamp);
+}
+
+std::shared_ptr<partition_assignment> 
read_partition_assignment_response(reader &reader, std::int64_t timestamp) {
+    auto cnt = reader.read_int32();
+    if (cnt <= 0)
+        throw ignite_error("Invalid partition count: " + std::to_string(cnt));
+
+    std::vector<std::optional<std::string>> partitions;
+    partitions.reserve(cnt);
+
+    bool assignment_available = reader.read_bool();
+    if (!assignment_available) {
+        // Invalidate the current assignment so that we can retry on the next 
call.
+        // Return an empty array so that per-partition batches can be 
initialized.
+        // We'll get the actual assignment on the next call.
+        partitions.insert(partitions.end(), cnt, std::nullopt);
+        return std::make_shared<partition_assignment>(0, 
std::move(partitions));
+    }
+
+    // Returned timestamp can be newer than requested.
+    std::int64_t ts = reader.read_int64();
+    if (ts < timestamp)
+        throw ignite_error("Returned timestamp is older than requested: " + 
std::to_string(ts) + " < "
+            + std::to_string(timestamp));

Review Comment:
   Assertion in Java Client is dangerous actually. Maybe we should fix it.



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