You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ignite.apache.org by GitBox <gi...@apache.org> on 2021/08/12 10:51:20 UTC

[GitHub] [ignite] ptupitsyn commented on a change in pull request #9312: IGNITE-12177: Java compute tasks for C++

ptupitsyn commented on a change in pull request #9312:
URL: https://github.com/apache/ignite/pull/9312#discussion_r687593126



##########
File path: modules/platforms/cpp/binary/include/ignite/impl/interop/interop_memory.h
##########
@@ -48,7 +48,19 @@ namespace ignite
 
             /** Flag: acquired. */
             const int IGNITE_MEM_FLAG_ACQUIRED = 0x4;
-                
+
+            union BinaryFloatInt32

Review comment:
       Missing comments.

##########
File path: modules/platforms/cpp/core-test/include/ignite/compute_types.h
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CORE_TEST_COMPUTE_TYPES
+#define _IGNITE_CORE_TEST_COMPUTE_TYPES
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/ignite_predicate.h>
+#include <ignite/cluster/cluster_node.h>
+
+namespace ignite_test
+{
+    /*
+     * Check if cluster node contain the attribute with name provided.
+     */
+    class HasAttrName : public ignite::IgnitePredicate<ignite::cluster::ClusterNode>
+    {
+    public:
+        HasAttrName(std::string name) :
+        name(name)

Review comment:
       Missing indentation.

##########
File path: .idea/inspectionProfiles/Project_Default.xml
##########
@@ -1,776 +1,764 @@
-<profile version="1.0">

Review comment:
       Is this huge change intentional?

##########
File path: modules/platforms/cpp/core/include/ignite/impl/compute/compute_impl.h
##########
@@ -198,7 +208,214 @@ namespace ignite
                     return PerformTask<void, F, JobType, TaskType>(Operation::BROADCAST, func);
                 }
 
+                /**
+                 * Executes given Java task on the grid projection. If task for given name has not been deployed yet,
+                 * then 'taskName' will be used as task class name to auto-deploy the task.
+                 *
+                 * @param taskName Java task name.
+                 * @param taskArg Argument of task execution of type A.
+                 * @return Task result of type @c R.
+                 *
+                 * @tparam R Type of task result.
+                 * @tparam A Type of task argument.
+                 */
+                template<typename R, typename A>
+                R ExecuteJavaTask(const std::string& taskName, const A& taskArg)
+                {
+                    return PerformJavaTask<R, A>(taskName, &taskArg);
+                }
+
+                /**
+                 * Executes given Java task on the grid projection. If task for given name has not been deployed yet,
+                 * then 'taskName' will be used as task class name to auto-deploy the task.
+                 *
+                 * @param taskName Java task name.
+                 * @return Task result of type @c R.
+                 *
+                 * @tparam R Type of task result.
+                 */
+                template<typename R>
+                R ExecuteJavaTask(const std::string& taskName)
+                {
+                    return PerformJavaTask<R, int>(taskName, 0);
+                }
+
+                /**
+                 * Asynchronously executes given Java task on the grid projection. If task for given name has not been
+                 * deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.
+                 *
+                 * @param taskName Java task name.
+                 * @param taskArg Argument of task execution of type A.
+                 * @return Future containing a result of type @c R.
+                 *
+                 * @tparam R Type of task result.
+                 * @tparam A Type of task argument.
+                 */
+                template<typename R, typename A>
+                Future<R> ExecuteJavaTaskAsync(const std::string& taskName, const A& taskArg)
+                {
+                    return PerformJavaTaskAsync<R, A>(taskName, &taskArg);
+                }
+
+                /**
+                 * Asynchronously executes given Java task on the grid projection. If task for given name has not been
+                 * deployed yet, then 'taskName' will be used as task class name to auto-deploy the task.
+                 *
+                 * @param taskName Java task name.
+                 * @return Future containing a result of type @c R.
+                 *
+                 * @tparam R Type of task result.
+                 */
+                template<typename R>
+                Future<R> ExecuteJavaTaskAsync(const std::string& taskName)
+                {
+                    return PerformJavaTaskAsync<R, int>(taskName, 0);
+                }
+
             private:
+                IGNITE_NO_COPY_ASSIGNMENT(ComputeImpl);
+
+                struct FutureType
+                {
+                    enum Type
+                    {
+                        F_BYTE = 1,
+                        F_BOOL = 2,
+                        F_SHORT = 3,
+                        F_CHAR = 4,
+                        F_INT = 5,
+                        F_FLOAT = 6,
+                        F_LONG = 7,
+                        F_DOUBLE = 8,
+                        F_OBJECT = 9,
+                    };
+                };
+
+                template<typename T> struct FutureTypeForType { static const int32_t value = FutureType::F_OBJECT; };
+
+                /**
+                 * @return True if projection for the compute contains predicate.
+                 */
+                bool ProjectionContainsPredicate() const;
+
+                /**
+                 * @return Nodes for the compute.
+                 */
+                std::vector<ignite::cluster::ClusterNode> GetNodes();
+
+                /**
+                 * Write Java task using provided writer. If task for given name has not been deployed yet,
+                 * then 'taskName' will be used as task class name to auto-deploy the task.
+                 *
+                 * @param taskName Java task name.
+                 * @param taskArg Argument of task execution of type A.
+                 * @param writer Binary writer.
+                 * @return Task result of type @c R.
+                 *
+                 * @tparam R Type of task result.
+                 * @tparam A Type of task argument.
+                 */
+                template<typename A>
+                void WriteJavaTask(const std::string& taskName, const A* arg, binary::BinaryWriterImpl& writer) {
+                    writer.WriteString(taskName);
+                    // Keep binary flag

Review comment:
       Missing blank line before comment.

##########
File path: modules/platforms/cpp/core-test/include/ignite/compute_types.h
##########
@@ -0,0 +1,81 @@
+/*
+ * 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.
+ */
+
+#ifndef _IGNITE_CORE_TEST_COMPUTE_TYPES
+#define _IGNITE_CORE_TEST_COMPUTE_TYPES
+
+#include <stdint.h>
+#include <string>
+
+#include <ignite/ignite_predicate.h>
+#include <ignite/cluster/cluster_node.h>
+
+namespace ignite_test
+{
+    /*
+     * Check if cluster node contain the attribute with name provided.

Review comment:
       `contains an attribute`




-- 
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: notifications-unsubscribe@ignite.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org