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


Java IntSet.add方法代码示例

本文整理汇总了Java中com.carrotsearch.hppc.IntSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java IntSet.add方法的具体用法?Java IntSet.add怎么用?Java IntSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.carrotsearch.hppc.IntSet的用法示例。


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

示例1: testKeybasedGraphPartitioning

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
@Test
public void testKeybasedGraphPartitioning() {
    Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), false,
                        option(VertexIDAssigner.PLACEMENT_STRATEGY), PropertyPlacementStrategy.class.getName(),
            option(PropertyPlacementStrategy.PARTITION_KEY), "clusterId"};
    clopen(options);

    int[] groupDegrees = {5,5,5,5,5,5,5,5};
    int numVertices = setupGroupClusters(groupDegrees,CommitMode.PER_VERTEX);

    IntSet partitionIds = new IntHashSet(numVertices); //to track the "spread" of partition ids
    for (int i=0;i<groupDegrees.length;i++) {
        TitanVertex g = getOnlyVertex(tx.query().has("groupid","group"+i));
        int partitionId = -1;
        for (TitanVertex v : g.query().direction(Direction.IN).labels("member").vertices()) {
            if (partitionId<0) partitionId = getPartitionID(v);
            assertEquals(partitionId,getPartitionID(v));
            partitionIds.add(partitionId);
        }
    }
    assertTrue(partitionIds.size()>numPartitions/2); //This is a probabilistic test that might fail
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:23,代码来源:TitanPartitionGraphTest.java

示例2: findCondition

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
private boolean findCondition() {
    IntSet tailNodes = new IntOpenHashSet(program.basicBlockCount());
    for (int tailCandidate : cfg.incomingEdges(head)) {
        if (nodes.contains(tailCandidate)) {
            tailNodes.add(tailCandidate);
        }
    }

    bodyStart = dom.commonDominatorOf(tailNodes.toArray());
    int candidate = bodyStart;
    while (bodyStart != head) {
        int currentCandidate = candidate;
        if (Arrays.stream(exits.toArray()).anyMatch(exit -> dom.dominates(currentCandidate, exit))) {
            break;
        }
        bodyStart = candidate;
        candidate = dom.immediateDominatorOf(candidate);
    }

    return candidate != bodyStart;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:22,代码来源:LoopInversionImpl.java

示例3: propagatePhiUsageInformation

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
private void propagatePhiUsageInformation() {
    IntDeque worklist = new IntArrayDeque();
    for (int receiverIndex : phisByReceiver.keys().toArray()) {
        if (usedPhis.get(receiverIndex)) {
            worklist.addLast(receiverIndex);
        }
    }

    IntSet visited = new IntOpenHashSet();
    while (!worklist.isEmpty()) {
        int varIndex = worklist.removeFirst();
        if (!visited.add(varIndex)) {
            continue;
        }
        usedPhis.set(varIndex);

        Phi phi = phisByReceiver.get(varIndex);
        if (phi != null) {
            for (Incoming incoming : phi.getIncomings()) {
                if (!visited.contains(incoming.getValue().getIndex())) {
                    worklist.addLast(incoming.getValue().getIndex());
                }
            }
        }
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:27,代码来源:PhiUpdater.java

示例4: addEdge

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
public void addEdge(int from, int to) {
    if (to < 0 || from < 0) {
        throw new IllegalArgumentException();
    }
    sz = Math.max(sz, Math.max(from, to) + 1);
    builtGraph = null;
    if (addedEdges.size() == from) {
        addedEdges.add(IntOpenHashSet.from(to));
    } else if (addedEdges.size() <= from) {
        addedEdges.addAll(Collections.nCopies(from - addedEdges.size(), null));
        addedEdges.add(IntOpenHashSet.from(to));
    } else {
        IntSet set = addedEdges.get(from);
        if (set == null) {
            addedEdges.set(from, IntOpenHashSet.from(to));
        } else {
            set.add(to);
        }
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:21,代码来源:GraphBuilder.java

示例5: testPartitionSpread

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
private void testPartitionSpread(boolean flush, boolean batchCommit) {
    Object[] options = {option(GraphDatabaseConfiguration.IDS_FLUSH), flush};
    clopen(options);

    int[] groupDegrees = {10,15,10,17,10,4,7,20,11};
    int numVertices = setupGroupClusters(groupDegrees,batchCommit?CommitMode.BATCH:CommitMode.PER_VERTEX);

    IntSet partitionIds = new IntHashSet(numVertices); //to track the "spread" of partition ids
    for (int i=0;i<groupDegrees.length;i++) {
        TitanVertex g = getOnlyVertex(tx.query().has("groupid","group"+i));
        assertCount(groupDegrees[i],g.edges(Direction.OUT,"contain"));
        assertCount(groupDegrees[i],g.edges(Direction.IN,"member"));
        assertCount(groupDegrees[i],g.query().direction(Direction.OUT).edges());
        assertCount(groupDegrees[i],g.query().direction(Direction.IN).edges());
        assertCount(groupDegrees[i]*2,g.query().edges());
        for (TitanVertex v : g.query().direction(Direction.IN).labels("member").vertices()) {
            int pid = getPartitionID(v);
            partitionIds.add(pid);
            assertEquals(g, getOnlyElement(v.query().direction(Direction.OUT).labels("member").vertices()));
            VertexList vlist = v.query().direction(Direction.IN).labels("contain").vertexIds();
            assertEquals(1,vlist.size());
            assertEquals(pid,idManager.getPartitionId(vlist.getID(0)));
            assertEquals(g,vlist.get(0));
        }
    }
    if (flush || !batchCommit) { //In these cases we would expect significant spread across partitions
        assertTrue(partitionIds.size()>numPartitions/2); //This is a probabilistic test that might fail
    } else {
        assertEquals(1,partitionIds.size()); //No spread in this case
    }
}
 
开发者ID:graben1437,项目名称:titan1withtp3.1,代码行数:32,代码来源:TitanPartitionGraphTest.java

示例6: toIntSet

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
public static IntSet toIntSet(final byte[] bytes) {
    IntSet bits = new IntHashSet(bytes == null ? 0 : DEFAULT_EXPECTED_ELEMENTS);
    if (bytes != null && bytes.length > 0) {
        for (int i = 0; i < (bytes.length * 8); i++) {
            if ((bytes[i / 8] & (1 << (7 - (i % 8)))) != 0) {
                bits.add(i);
            }
        }
    }
    return bits;
}
 
开发者ID:PhantomThief,项目名称:jedis-helper,代码行数:12,代码来源:JedisUtils.java

示例7: nodesToCopy

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
private IntSet nodesToCopy() {
    IntSet result = new IntOpenHashSet();
    for (int node : nodes.toArray()) {
        if (node == head || (node != bodyStart && !dom.dominates(bodyStart, node))) {
            result.add(node);
        }
    }
    return result;
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:10,代码来源:LoopInversionImpl.java

示例8: withoutCopies

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
private int[] withoutCopies(int[] nodesWithCopies) {
    IntSet visited = new IntOpenHashSet();
    int[] nodes = new int[nodesWithCopies.length];
    int sz = 0;
    for (int node : nodesWithCopies) {
        node = nodeOriginals.get(node);
        if (visited.add(node)) {
            nodes[sz++] = node;
        }
    }
    return Arrays.copyOf(nodes, sz);
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:13,代码来源:IrreducibleGraphConverter.java

示例9: testRestoreIndexWithShardsMissingInLocalGateway

import com.carrotsearch.hppc.IntSet; //导入方法依赖的package包/类
public void testRestoreIndexWithShardsMissingInLocalGateway() throws Exception {
    logger.info("--> start 2 nodes");
    Settings nodeSettings = Settings.builder()
            .put(EnableAllocationDecider.CLUSTER_ROUTING_REBALANCE_ENABLE_SETTING.getKey(), EnableAllocationDecider.Rebalance.NONE)
            .build();

    internalCluster().startNode(nodeSettings);
    internalCluster().startNode(nodeSettings);
    cluster().wipeIndices("_all");

    logger.info("--> create repository");
    PutRepositoryResponse putRepositoryResponse = client().admin().cluster().preparePutRepository("test-repo")
            .setType("fs").setSettings(Settings.builder().put("location", randomRepoPath())).execute().actionGet();
    assertThat(putRepositoryResponse.isAcknowledged(), equalTo(true));
    int numberOfShards = 6;
    logger.info("--> create an index that will have some unallocated shards");
    assertAcked(prepareCreate("test-idx", 2, Settings.builder().put("number_of_shards", numberOfShards)
            .put("number_of_replicas", 0)));
    ensureGreen();

    logger.info("--> indexing some data into test-idx");
    for (int i = 0; i < 100; i++) {
        index("test-idx", "doc", Integer.toString(i), "foo", "bar" + i);
    }
    refresh();
    assertThat(client().prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));

    logger.info("--> start snapshot");
    assertThat(client().admin().cluster().prepareCreateSnapshot("test-repo", "test-snap-1").setIndices("test-idx").setWaitForCompletion(true).get().getSnapshotInfo().state(), equalTo(SnapshotState.SUCCESS));

    logger.info("--> close the index");
    assertAcked(client().admin().indices().prepareClose("test-idx"));

    logger.info("--> shutdown one of the nodes that should make half of the shards unavailable");
    internalCluster().restartRandomDataNode(new InternalTestCluster.RestartCallback() {
        @Override
        public boolean clearData(String nodeName) {
            return true;
        }
    });

    assertThat(client().admin().cluster().prepareHealth().setWaitForEvents(Priority.LANGUID).setTimeout("1m").setWaitForNodes("2").execute().actionGet().isTimedOut(), equalTo(false));

    logger.info("--> restore index snapshot");
    assertThat(client().admin().cluster().prepareRestoreSnapshot("test-repo", "test-snap-1").setRestoreGlobalState(false).setWaitForCompletion(true).get().getRestoreInfo().successfulShards(), equalTo(6));

    ensureGreen("test-idx");
    assertThat(client().prepareSearch("test-idx").setSize(0).get().getHits().getTotalHits(), equalTo(100L));

    IntSet reusedShards = new IntHashSet();
    for (RecoveryState recoveryState : client().admin().indices().prepareRecoveries("test-idx").get().shardRecoveryStates().get("test-idx")) {
        if (recoveryState.getIndex().reusedBytes() > 0) {
            reusedShards.add(recoveryState.getShardId().getId());
        }
    }
    logger.info("--> check that at least half of the shards had some reuse: [{}]", reusedShards);
    assertThat(reusedShards.size(), greaterThanOrEqualTo(numberOfShards / 2));
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:59,代码来源:DedicatedClusterSnapshotRestoreIT.java


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