Class ComputePartitionQueryMapReduceExample
IgniteCompute.executeMapReduce(org.apache.ignite.compute.TaskDescriptor<T, R>, T) API
together with the __PARTITION_ID virtual SQL column.
In the split phase, ComputePartitionQueryMapReduceExample.PersonCountByPartitionTask enumerates all partitions of the Person table
via PartitionDistribution and dispatches one job per partition to the node that currently holds the primary
replica. Each ComputePartitionQueryMapReduceExample.PartitionPersonCountJob filters rows with __PARTITION_ID and returns the local count.
In the reduce phase the counts are summed.
Note: PartitionDistribution.primaryReplicas() captures partition locations at a point in time.
If a partition is reassigned between the split and job execution, a job may run on a non-primary node, making the
SQL query non-local. For guaranteed local execution use BroadcastJobTarget.table(java.lang.String)
instead — see ComputeBroadcastExample for that approach.
See README.md in the examples directory for execution instructions.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classJob that counts persons in a single partition, identified by partition ID passed as the job argument.static classMapReduce task that counts persons across all partitions of thePersontable. -
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
ComputePartitionQueryMapReduceExample
public ComputePartitionQueryMapReduceExample()
-
-
Method Details
-
main
Main method of the example.- Parameters:
args- The command line arguments.- Throws:
Exception- if any error occurs.
-