Search in sources :

Example 6 with GridIntList

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 }));
}
Also used : GridIntList(org.apache.ignite.internal.util.GridIntList)

Example 7 with GridIntList

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IntArray(org.h2.util.IntArray) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) GridIntIterator(org.apache.ignite.internal.util.GridIntIterator) Collections.singletonList(java.util.Collections.singletonList) GridIntList(org.apache.ignite.internal.util.GridIntList) List(java.util.List) ArrayList(java.util.ArrayList) GridIntList(org.apache.ignite.internal.util.GridIntList)

Aggregations

GridIntList (org.apache.ignite.internal.util.GridIntList)7 ArrayList (java.util.ArrayList)3 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ClusterNode (org.apache.ignite.cluster.ClusterNode)1 CacheStoreManager (org.apache.ignite.internal.processors.cache.store.CacheStoreManager)1 GridIntIterator (org.apache.ignite.internal.util.GridIntIterator)1 GridLongList (org.apache.ignite.internal.util.GridLongList)1 IntArray (org.h2.util.IntArray)1