rpuch commented on code in PR #857:
URL: https://github.com/apache/ignite-3/pull/857#discussion_r891080809


##########
docs/_docs/compute/compute.adoc:
##########
@@ -0,0 +1,80 @@
+= Distributed Computing
+
+Apache Ignite 3 provides an API for distributing computations across cluster 
nodes in a balanced and fault-tolerant manner. You can submit individual tasks 
for execution from Java and .NET clients.
+
+You can use Java or .NET client to execute compute jobs. Make sure the 
required classes are deployed to the cluster before executing code.
+
+Here is how you can execute a simple compute job:
+
+
+[tabs]
+--
+tab:Java[]
+[source, java]
+----
+private void example() {
+    IgniteClient client = client();
+    IgniteCompute compute = client.compute();
+    Set<ClusterNode> nodes = new HashSet<>(client.clusterNodes());
+
+    compute.execute(nodes, NodeNameJob.class, "Hello");
+}
+
+private static class NodeNameJob implements ComputeJob<String> {
+    @Override
+    public String execute(JobExecutionContext context, Object... args) {
+        return context.ignite().name() + "_" + args[0];
+    }
+}
+----
+
+
+NOTE: Unlike Ignite 2, jobs are not serialized. Only the class name and 
arguments are sent to the node.
+
+tab:.NET[]
+[source, csharp]
+----
+IIgniteClient client = Client;
+ICompute compute = client.Compute;
+IList<IClusterNode> nodes = await Client.GetClusterNodesAsync();
+string res = await compute.ExecuteAsync<string>(nodes, jobClassName: 
"org.foo.bar.NodeNameJob", "Hello!");
+----
+--
+
+
+== Colocated Computations
+
+In Apache Ignite 3 you can execute colocated computation with 
`executeColocated` method. When you do it, the data set required for the 
compute task is guaranteed to be on the nodes that execute the task. This can 
significantly reduce execution time if your tasks require data.
+
+In this example we will need a table to colocate:
+
+
+
+[source, java]
+----
+executeSql("CREATE TABLE test (k int, v int, CONSTRAINT PK PRIMARY KEY (k))");
+executeSql("INSERT INTO test(k, v) VALUES (1, 101)");
+----
+
+[tabs]
+--
+tab:Tuple[]
+[source, java]
+----
+String actualNodeName = ignite.compute()
+        .executeColocated("PUBLIC.test", Tuple.create(Map.of("k", 1)), 
GetNodeNameJob.class)

Review Comment:
   Should it be replaced with a call to `NodeNameJob`? If not, then 
`GetNodeNameJob` code is missing.



##########
docs/_docs/compute/compute.adoc:
##########
@@ -0,0 +1,80 @@
+= Distributed Computing
+
+Apache Ignite 3 provides an API for distributing computations across cluster 
nodes in a balanced and fault-tolerant manner. You can submit individual tasks 
for execution from Java and .NET clients.
+
+You can use Java or .NET client to execute compute jobs. Make sure the 
required classes are deployed to the cluster before executing code.
+
+Here is how you can execute a simple compute job:
+
+
+[tabs]
+--
+tab:Java[]
+[source, java]
+----
+private void example() {
+    IgniteClient client = client();
+    IgniteCompute compute = client.compute();
+    Set<ClusterNode> nodes = new HashSet<>(client.clusterNodes());
+
+    compute.execute(nodes, NodeNameJob.class, "Hello");
+}
+
+private static class NodeNameJob implements ComputeJob<String> {
+    @Override
+    public String execute(JobExecutionContext context, Object... args) {
+        return context.ignite().name() + "_" + args[0];
+    }
+}
+----
+
+
+NOTE: Unlike Ignite 2, jobs are not serialized. Only the class name and 
arguments are sent to the node.
+
+tab:.NET[]
+[source, csharp]
+----
+IIgniteClient client = Client;
+ICompute compute = client.Compute;
+IList<IClusterNode> nodes = await Client.GetClusterNodesAsync();
+string res = await compute.ExecuteAsync<string>(nodes, jobClassName: 
"org.foo.bar.NodeNameJob", "Hello!");
+----
+--
+
+
+== Colocated Computations
+
+In Apache Ignite 3 you can execute colocated computation with 
`executeColocated` method. When you do it, the data set required for the 
compute task is guaranteed to be on the nodes that execute the task. This can 
significantly reduce execution time if your tasks require data.
+
+In this example we will need a table to colocate:
+
+
+
+[source, java]
+----
+executeSql("CREATE TABLE test (k int, v int, CONSTRAINT PK PRIMARY KEY (k))");
+executeSql("INSERT INTO test(k, v) VALUES (1, 101)");
+----
+
+[tabs]
+--
+tab:Tuple[]
+[source, java]
+----
+String actualNodeName = ignite.compute()
+        .executeColocated("PUBLIC.test", Tuple.create(Map.of("k", 1)), 
GetNodeNameJob.class)
+        .get(1, TimeUnit.SECONDS);
+
+System.out.println(actualNodeName);
+----
+
+tab:Mapper[]
+[source, java]
+----
+String actualNodeName = ignite.compute()
+        .executeColocated("PUBLIC.test", 1, Mapper.of(Integer.class), 
GetNodeNameJob.class)

Review Comment:
   Same thing about the job



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