当前位置: 首页>>代码示例>>Java>>正文


Java IntArray类代码示例

本文整理汇总了Java中org.h2.util.IntArray的典型用法代码示例。如果您正苦于以下问题:Java IntArray类的具体用法?Java IntArray怎么用?Java IntArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IntArray类属于org.h2.util包,在下文中一共展示了IntArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: narrowForQuery

import org.h2.util.IntArray; //导入依赖的package包/类
/** */
private 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;
}
 
开发者ID:apache,项目名称:ignite,代码行数:26,代码来源:GridReduceQueryExecutor.java

示例2: findParams

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @param qry Select.
 * @param params Parameters.
 * @param target Extracted parameters.
 * @param paramIdxs Parameter indexes.
 * @return Extracted parameters list.
 */
@SuppressWarnings("unused")
private static List<Object> findParams(GridSqlQuery qry, Object[] params, ArrayList<Object> target,
    IntArray paramIdxs) {
    if (qry instanceof GridSqlSelect)
        return findParams((GridSqlSelect)qry, params, target, paramIdxs);

    GridSqlUnion union = (GridSqlUnion)qry;

    findParams(union.left(), params, target, paramIdxs);
    findParams(union.right(), params, target, paramIdxs);

    findParams((GridSqlElement)qry.limit(), params, target, paramIdxs);
    findParams((GridSqlElement)qry.offset(), params, target, paramIdxs);

    return target;
}
 
开发者ID:apache,项目名称:ignite,代码行数:24,代码来源:DmlAstUtils.java

示例3: removeUntil

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * Remove all pages until the given data page.
 *
 * @param trunkPage the first trunk page
 * @param firstDataPageToKeep the first data page to keep
 * @return the trunk page of the data page to keep
 */
private int removeUntil(int trunkPage, int firstDataPageToKeep) {
    trace.debug("log.removeUntil " + trunkPage + " " + firstDataPageToKeep);
    int last = trunkPage;
    while (true) {
        Page p = store.getPage(trunkPage);
        PageStreamTrunk t = (PageStreamTrunk) p;
        if (t == null) {
            throw DbException.throwInternalError(
                    "log.removeUntil not found: " + firstDataPageToKeep + " last " + last);
        }
        logKey = t.getLogKey();
        last = t.getPos();
        if (t.contains(firstDataPageToKeep)) {
            return last;
        }
        trunkPage = t.getNextTrunk();
        IntArray list = new IntArray();
        list.add(t.getPos());
        for (int i = 0;; i++) {
            int next = t.getPageData(i);
            if (next == -1) {
                break;
            }
            list.add(next);
        }
        freeLogPages(list);
        pageOut.free(t);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:37,代码来源:PageLog.java

示例4: allocatePages

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * Allocate a number of pages.
 *
 * @param list the list where to add the allocated pages
 * @param pagesToAllocate the number of pages to allocate
 * @param exclude the exclude list
 * @param after all allocated pages are higher than this page
 */
void allocatePages(IntArray list, int pagesToAllocate, BitField exclude,
        int after) {
    list.ensureCapacity(list.size() + pagesToAllocate);
    for (int i = 0; i < pagesToAllocate; i++) {
        int page = allocatePage(exclude, after);
        after = page;
        list.add(page);
    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:18,代码来源:PageStore.java

示例5: testRemoveRange

import org.h2.util.IntArray; //导入依赖的package包/类
private void testRemoveRange() {
    IntArray array = new IntArray(new int[] {1, 2, 3, 4, 5});
    array.removeRange(1, 3);
    assertEquals(3, array.size());
    assertEquals(1, array.get(0));
    assertEquals(4, array.get(1));
    assertEquals(5, array.get(2));
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:9,代码来源:TestIntArray.java

示例6: testRandom

import org.h2.util.IntArray; //导入依赖的package包/类
private void testRandom() {
    IntArray array = new IntArray();
    int[] test = {};
    Random random = new Random(1);
    for (int i = 0; i < 10000; i++) {
        int idx = test.length == 0 ? 0 : random.nextInt(test.length);
        int v = random.nextInt(100);
        int op = random.nextInt(4);
        switch (op) {
        case 0:
            array.add(v);
            test = add(test, v);
            break;
        case 1:
            if (test.length > idx) {
                assertEquals(get(test, idx), array.get(idx));
            }
            break;
        case 2:
            if (test.length > 0) {
                array.remove(idx);
                test = remove(test, idx);
            }
            break;
        case 3:
            assertEquals(test.length, array.size());
            break;
        default:
        }
        assertEquals(test.length, array.size());
        for (int j = 0; j < test.length; j++) {
            assertEquals(test[j], array.get(j));
        }

    }
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:37,代码来源:TestIntArray.java

示例7: toArray

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @param ints Ints.
 * @return Array.
 */
public static int[] toArray(IntArray ints) {
    int[] res = new int[ints.size()];

    ints.toArray(res);

    return res;
}
 
开发者ID:apache,项目名称:ignite,代码行数:12,代码来源:GridReduceQueryExecutor.java

示例8: convert

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @param m Map.
 * @return Converted map.
 */
private static Map<UUID, int[]> convert(Map<ClusterNode, IntArray> m) {
    if (m == null)
        return null;

    Map<UUID, int[]> res = U.newHashMap(m.size());

    for (Map.Entry<ClusterNode,IntArray> entry : m.entrySet())
        res.put(entry.getKey().id(), toArray(entry.getValue()));

    return res;
}
 
开发者ID:apache,项目名称:ignite,代码行数:16,代码来源:GridReduceQueryExecutor.java

示例9: nodesForPartitions

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * Evaluates nodes and nodes to partitions map given a list of cache ids, topology version and partitions.
 *
 * @param cacheIds Cache ids.
 * @param topVer Topology version.
 * @param parts Partitions array.
 * @param isReplicatedOnly Allow only replicated caches.
 * @return Result.
 */
private NodesForPartitionsResult nodesForPartitions(List<Integer> cacheIds, AffinityTopologyVersion topVer,
    int[] parts, boolean isReplicatedOnly) {
    Collection<ClusterNode> nodes = null;
    Map<ClusterNode, IntArray> partsMap = null;
    Map<ClusterNode, IntArray> qryMap = null;

    if (isPreloadingActive(cacheIds)) {
        if (isReplicatedOnly)
            nodes = replicatedUnstableDataNodes(cacheIds);
        else {
            partsMap = partitionedUnstableDataNodes(cacheIds);

            if (partsMap != null) {
                qryMap = narrowForQuery(partsMap, parts);

                nodes = qryMap == null ? null : qryMap.keySet();
            }
        }
    }
    else {
        qryMap = stableDataNodes(isReplicatedOnly, topVer, cacheIds, parts);

        if (qryMap != null)
            nodes = qryMap.keySet();
    }

    return new NodesForPartitionsResult(nodes, partsMap, qryMap);
}
 
开发者ID:apache,项目名称:ignite,代码行数:38,代码来源:GridReduceQueryExecutor.java

示例10: NodesForPartitionsResult

import org.h2.util.IntArray; //导入依赖的package包/类
/** */
NodesForPartitionsResult(Collection<ClusterNode> nodes, Map<ClusterNode, IntArray> partsMap,
    Map<ClusterNode, IntArray> qryMap) {
    this.nodes = nodes;
    this.partsMap = partsMap;
    this.qryMap = qryMap;
}
 
开发者ID:apache,项目名称:ignite,代码行数:8,代码来源:GridReduceQueryExecutor.java

示例11: testInit

import org.h2.util.IntArray; //导入依赖的package包/类
private static void testInit() {
    IntArray array = new IntArray(new int[0]);
    array.add(10);
}
 
开发者ID:vdr007,项目名称:ThriftyPaxos,代码行数:5,代码来源:TestIntArray.java

示例12: stableDataNodes

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @param isReplicatedOnly If we must only have replicated caches.
 * @param topVer Topology version.
 * @param cacheIds Participating cache IDs.
 * @param parts Partitions.
 * @return Data nodes or {@code null} if repartitioning started and we need to retry.
 */
private Map<ClusterNode, IntArray> stableDataNodes(boolean isReplicatedOnly, AffinityTopologyVersion topVer,
    List<Integer> cacheIds, int[] parts) {
    GridCacheContext<?, ?> cctx = cacheContext(cacheIds.get(0));

    Map<ClusterNode, IntArray> map = stableDataNodesMap(topVer, cctx, parts);

    Set<ClusterNode> nodes = map.keySet();

    if (F.isEmpty(map))
        throw new CacheException("Failed to find data nodes for cache: " + cctx.name());

    for (int i = 1; i < cacheIds.size(); i++) {
        GridCacheContext<?,?> extraCctx = cacheContext(cacheIds.get(i));

        String extraCacheName = extraCctx.name();

        if (extraCctx.isLocal())
            continue; // No consistency guaranties for local caches.

        if (isReplicatedOnly && !extraCctx.isReplicated())
            throw new CacheException("Queries running on replicated cache should not contain JOINs " +
                "with partitioned tables [replicatedCache=" + cctx.name() +
                ", partitionedCache=" + extraCacheName + "]");

        Set<ClusterNode> extraNodes = stableDataNodesMap(topVer, extraCctx, parts).keySet();

        if (F.isEmpty(extraNodes))
            throw new CacheException("Failed to find data nodes for cache: " + extraCacheName);

        boolean disjoint;

        if (extraCctx.isReplicated()) {
            if (isReplicatedOnly) {
                nodes.retainAll(extraNodes);

                disjoint = map.isEmpty();
            }
            else
                disjoint = !extraNodes.containsAll(nodes);
        }
        else
            disjoint = !extraNodes.equals(nodes);

        if (disjoint) {
            if (isPreloadingActive(cacheIds))
                return null; // Retry.
            else
                throw new CacheException("Caches have distinct sets of data nodes [cache1=" + cctx.name() +
                    ", cache2=" + extraCacheName + "]");
        }
    }

    return map;
}
 
开发者ID:apache,项目名称:ignite,代码行数:62,代码来源:GridReduceQueryExecutor.java

示例13: ExplicitPartitionsSpecializer

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @param partsMap Partitions map.
 */
public ExplicitPartitionsSpecializer(Map<ClusterNode, IntArray> partsMap) {
    this.partsMap = partsMap;
}
 
开发者ID:apache,项目名称:ignite,代码行数:7,代码来源:GridReduceQueryExecutor.java

示例14: partitionsMap

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @return Maps a node to partition array.
 */
Map<ClusterNode, IntArray> partitionsMap() {
    return partsMap;
}
 
开发者ID:apache,项目名称:ignite,代码行数:7,代码来源:GridReduceQueryExecutor.java

示例15: queryPartitionsMap

import org.h2.util.IntArray; //导入依赖的package包/类
/**
 * @return Maps a node to partition array.
 */
Map<ClusterNode, IntArray> queryPartitionsMap() {
    return qryMap;
}
 
开发者ID:apache,项目名称:ignite,代码行数:7,代码来源:GridReduceQueryExecutor.java


注:本文中的org.h2.util.IntArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。