ptupitsyn commented on code in PR #3516:
URL: https://github.com/apache/ignite-3/pull/3516#discussion_r1544217058


##########
modules/platforms/cpp/ignite/client/detail/compute/compute_impl.cpp:
##########
@@ -148,24 +291,59 @@ void compute_impl::submit_colocated(const std::string 
&table_name, const ignite_
                     write_primitives_as_binary_tuple(writer, args);
                 };
 
-                auto response_reader_func = [](protocol::reader &reader) {
-                    (void) reader.read_int32(); // Skip schema version.
-                };
-
-                auto notification_reader_func = [](protocol::reader &reader) 
-> std::optional<primitive> {
-                    if (reader.try_read_nil())
-                        return std::nullopt;
-
-                    return read_primitive_from_binary_tuple(reader);
-                };
+                auto handler = 
std::make_shared<response_handler_compute>(self, std::move(callback), true);
 
-                
conn->perform_request_single_notification<std::optional<primitive>>(
-                    protocol::client_operation::COMPUTE_EXECUTE_COLOCATED, 
writer_func, std::move(response_reader_func),
-                    std::move(notification_reader_func), std::move(callback));
+                conn->perform_request_handler(
+                    protocol::client_operation::COMPUTE_EXECUTE_COLOCATED, 
nullptr, writer_func, std::move(handler));
             });
     };
 
     m_tables->get_table_async(table_name, std::move(on_table_get));
 }
 
+void compute_impl::get_status_async(uuid id, 
ignite_callback<std::optional<job_status>> callback) {
+    auto writer_func = [id](protocol::writer &writer) { writer.write(id); };
+
+    auto reader_func = [](protocol::reader &reader) -> 
std::optional<job_status> {
+        return read_job_status_opt(reader);
+    };
+
+    m_connection->perform_request<std::optional<job_status>>(
+        protocol::client_operation::COMPUTE_GET_STATUS, writer_func, 
std::move(reader_func), std::move(callback));

Review Comment:
   Why don't we `std::move(writer_func)`?



##########
modules/platforms/cpp/ignite/client/detail/compute/job_execution_impl.cpp:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/client/detail/compute/job_execution_impl.h"
+#include "ignite/client/detail/compute/compute_impl.h"
+
+namespace ignite::detail {
+
+void 
job_execution_impl::get_result_async(ignite_callback<std::optional<primitive>> 
callback) {
+    std::unique_lock<std::mutex> guard(m_mutex);
+
+    if (m_result) {
+        auto copy{*m_result};
+        guard.unlock();
+
+        callback({std::move(copy)});
+    } else if (m_error) {
+        auto copy{*m_error};
+        guard.unlock();
+
+        callback({std::move(copy)});
+    } else {
+        if (m_result_callback)
+            throw ignite_error("A callback for this result was already 
submitted");

Review Comment:
   Please explain - when does this happen? As a user, can I call 
`get_result_async` multiple times?



##########
modules/platforms/cpp/ignite/client/compute/compute.h:
##########
@@ -48,63 +49,62 @@ class compute {
     compute() = delete;
 
     /**
-     * Submits a compute job represented by the given class for an execution 
on one of the specified nodes.
+     * Executes a compute job represented by the given class for an execution 
on one of the specified nodes.

Review Comment:
   > Executes ... for an execution
   
   Why not keep `Submits`?



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