Search in sources :

Example 16 with IntArray

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IntArray(org.h2.util.IntArray) HashMap(java.util.HashMap) List(java.util.List)

Example 17 with IntArray

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;
}
Also used : ClusterNode(org.apache.ignite.cluster.ClusterNode) IntArray(org.h2.util.IntArray) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

IntArray (org.h2.util.IntArray)17 ClusterNode (org.apache.ignite.cluster.ClusterNode)11 HashMap (java.util.HashMap)7 CacheException (javax.cache.CacheException)6 LinkedHashMap (java.util.LinkedHashMap)4 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 List (java.util.List)3 ResultSet (java.sql.ResultSet)2 ArrayList (java.util.ArrayList)2 Collections.singletonList (java.util.Collections.singletonList)2 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 IgniteCheckedException (org.apache.ignite.IgniteCheckedException)2 AffinityTopologyVersion (org.apache.ignite.internal.processors.affinity.AffinityTopologyVersion)2 GridQueryCancelRequest (org.apache.ignite.internal.processors.query.h2.twostep.messages.GridQueryCancelRequest)2 GridIntList (org.apache.ignite.internal.util.GridIntList)2 BitSet (java.util.BitSet)1 Random (java.util.Random)1 UUID (java.util.UUID)1