use of org.h2.util.IntArray in project ignite by apache.
the class ReducePartitionMapper method stableDataNodesMap.
/**
* @param topVer Topology version.
* @param cctx Cache context.
* @param parts Partitions.
*/
private Map<ClusterNode, IntArray> stableDataNodesMap(AffinityTopologyVersion topVer, final GridCacheContext<?, ?> cctx, @NotNull final int[] parts) {
assert !cctx.isReplicated();
List<List<ClusterNode>> assignment = cctx.affinity().assignment(topVer).assignment();
Map<ClusterNode, IntArray> mapping = new HashMap<>();
for (int part : parts) {
List<ClusterNode> partNodes = assignment.get(part);
if (!partNodes.isEmpty()) {
ClusterNode prim = partNodes.get(0);
IntArray partIds = mapping.get(prim);
if (partIds == null) {
partIds = new IntArray();
mapping.put(prim, partIds);
}
partIds.add(part);
}
}
return mapping;
}
use of org.h2.util.IntArray in project ignite by apache.
the class ReducePartitionMapper method narrowForQuery.
/**
* @param partsMap Partitions map.
* @param parts Partitions.
* @return Result.
*/
private static Map<ClusterNode, IntArray> narrowForQuery(Map<ClusterNode, IntArray> partsMap, int[] parts) {
if (parts == null)
return partsMap;
Map<ClusterNode, IntArray> cp = U.newHashMap(partsMap.size());
for (Map.Entry<ClusterNode, IntArray> entry : partsMap.entrySet()) {
IntArray filtered = new IntArray(parts.length);
IntArray orig = entry.getValue();
for (int i = 0; i < orig.size(); i++) {
int p = orig.get(i);
if (Arrays.binarySearch(parts, p) >= 0)
filtered.add(p);
}
if (filtered.size() > 0)
cp.put(entry.getKey(), filtered);
}
return cp.isEmpty() ? null : cp;
}
Aggregations