use of org.apache.ignite.internal.util.GridIntList in project ignite by apache.
the class GridIntListSelfTest method testCopyWithout.
/**
* @throws Exception If failed.
*/
@SuppressWarnings("ZeroLengthArrayAllocation")
public void testCopyWithout() throws Exception {
assertCopy(new GridIntList(new int[] {}), new GridIntList(new int[] {}));
assertCopy(new GridIntList(new int[] {}), new GridIntList(new int[] { 1 }));
assertCopy(new GridIntList(new int[] { 1 }), new GridIntList(new int[] {}));
assertCopy(new GridIntList(new int[] { 1, 2, 3 }), new GridIntList(new int[] { 4, 5, 6 }));
assertCopy(new GridIntList(new int[] { 1, 2, 3 }), new GridIntList(new int[] { 1, 2, 3 }));
assertCopy(new GridIntList(new int[] { 1, 2, 3, 4, 5, 1 }), new GridIntList(new int[] { 1, 1 }));
assertCopy(new GridIntList(new int[] { 1, 1, 1, 2, 3, 4, 5, 1, 1, 1 }), new GridIntList(new int[] { 1, 1 }));
assertCopy(new GridIntList(new int[] { 1, 2, 3 }), new GridIntList(new int[] { 1, 1, 2, 2, 3, 3 }));
}
use of org.apache.ignite.internal.util.GridIntList 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).nodes()) 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