use of org.apache.ignite.internal.util.GridIntIterator in project ignite by apache.
the class GridReduceQueryExecutor method stableDataNodesMap.
/**
* @param topVer Topology version.
* @param cctx Cache context.
* @param parts Partitions.
*/
private Map<ClusterNode, IntArray> stableDataNodesMap(AffinityTopologyVersion topVer, final GridCacheContext<?, ?> cctx, @Nullable final int[] parts) {
Map<ClusterNode, IntArray> mapping = new HashMap<>();
// Explicit partitions mapping is not applicable to replicated cache.
if (cctx.isReplicated()) {
for (ClusterNode clusterNode : cctx.affinity().assignment(topVer).primaryPartitionNodes()) mapping.put(clusterNode, null);
return mapping;
}
List<List<ClusterNode>> assignment = cctx.affinity().assignment(topVer).assignment();
boolean needPartsFilter = parts != null;
GridIntIterator iter = needPartsFilter ? new GridIntList(parts).iterator() : U.forRange(0, cctx.affinity().partitions());
while (iter.hasNext()) {
int partId = iter.next();
List<ClusterNode> partNodes = assignment.get(partId);
if (!partNodes.isEmpty()) {
ClusterNode prim = partNodes.get(0);
if (!needPartsFilter) {
mapping.put(prim, null);
continue;
}
IntArray partIds = mapping.get(prim);
if (partIds == null) {
partIds = new IntArray();
mapping.put(prim, partIds);
}
partIds.add(partId);
}
}
return mapping;
}
Aggregations