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


Java IntSet类代码示例

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


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

示例1: initializeAsRestore

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
/**
 * Initializes an index, to be restored from snapshot
 */
private Builder initializeAsRestore(IndexMetaData indexMetaData, SnapshotRecoverySource recoverySource, IntSet ignoreShards, boolean asNew, UnassignedInfo unassignedInfo) {
    assert indexMetaData.getIndex().equals(index);
    if (!shards.isEmpty()) {
        throw new IllegalStateException("trying to initialize an index with fresh shards, but already has shards created");
    }
    for (int shardNumber = 0; shardNumber < indexMetaData.getNumberOfShards(); shardNumber++) {
        ShardId shardId = new ShardId(index, shardNumber);
        IndexShardRoutingTable.Builder indexShardRoutingBuilder = new IndexShardRoutingTable.Builder(shardId);
        for (int i = 0; i <= indexMetaData.getNumberOfReplicas(); i++) {
            boolean primary = i == 0;
            if (asNew && ignoreShards.contains(shardNumber)) {
                // This shards wasn't completely snapshotted - restore it as new shard
                indexShardRoutingBuilder.addShard(ShardRouting.newUnassigned(shardId, primary,
                    primary ? StoreRecoverySource.EMPTY_STORE_INSTANCE : PeerRecoverySource.INSTANCE, unassignedInfo));
            } else {
                indexShardRoutingBuilder.addShard(ShardRouting.newUnassigned(shardId, primary,
                    primary ? recoverySource : PeerRecoverySource.INSTANCE, unassignedInfo));
            }
        }
        shards.put(shardNumber, indexShardRoutingBuilder.build());
    }
    return this;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:27,代码来源:IndexRoutingTable.java

示例2: initializeAsRestore

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
/**
 * Initializes an index, to be restored from snapshot
 */
private Builder initializeAsRestore(IndexMetaData indexMetaData, RestoreSource restoreSource, IntSet ignoreShards, boolean asNew, UnassignedInfo unassignedInfo) {
    if (!shards.isEmpty()) {
        throw new IllegalStateException("trying to initialize an index with fresh shards, but already has shards created");
    }
    for (int shardId = 0; shardId < indexMetaData.getNumberOfShards(); shardId++) {
        IndexShardRoutingTable.Builder indexShardRoutingBuilder = new IndexShardRoutingTable.Builder(new ShardId(indexMetaData.getIndex(), shardId));
        for (int i = 0; i <= indexMetaData.getNumberOfReplicas(); i++) {
            if (asNew && ignoreShards.contains(shardId)) {
                // This shards wasn't completely snapshotted - restore it as new shard
                indexShardRoutingBuilder.addShard(ShardRouting.newUnassigned(index, shardId, null, i == 0, unassignedInfo));
            } else {
                indexShardRoutingBuilder.addShard(ShardRouting.newUnassigned(index, shardId, i == 0 ? restoreSource : null, i == 0, unassignedInfo));
            }
        }
        shards.put(shardId, indexShardRoutingBuilder.build());
    }
    return this;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:22,代码来源:IndexRoutingTable.java

示例3: vertexSample

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
/**
 * This method computes the pagerank for each vertex and keeps a sample of 
 * the vertices for each colour
 * @param graph
 * @return sample graph
 */
public ObjectObjectOpenHashMap<Integer, BitSet> vertexSample(ColouredGraph graph){

ColouredVerticesMetric colouredVertices = new ColouredVerticesMetric();
ObjectObjectOpenHashMap<BitSet,IntSet> vertices = colouredVertices.getVerticesForEachColour(graph);
PageRank pageRank = graph.getGraph().getPageRanking(random);
ObjectObjectOpenHashMap<Integer, BitSet> sampleVertices = new ObjectObjectOpenHashMap<Integer,BitSet>();

    for (ObjectCursor<BitSet> colour : vertices.keys()) {
        if(!colour.value.isEmpty()){  //change this based on the colour we have for rdf:type ...
            Map<Integer, Double> verticesPageRank = new HashMap<Integer, Double>();

            for (int i = 0; i < vertices.get(colour.value).size(); i++) {
                verticesPageRank.put(vertices.get(colour.value).toArray()[i], pageRank.getRank(vertices.get(colour.value).toArray()[i]));
            }
            //sort vertices based on pagerank and keep only a part of them
            Map<Integer, Double> sortedVerticesPageRank = sortByValues(verticesPageRank,graph,colour.value);   
                
            for(Map.Entry entry: sortedVerticesPageRank.entrySet()){ 
                sampleVertices.put((Integer) entry.getKey(), colour.value);
            }
        }
    }
    return sampleVertices;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:31,代码来源:Sampling.java

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: processNodeToNodeTransitionQueue

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
private void processNodeToNodeTransitionQueue() {
    while (!pendingTransitions.isEmpty()) {
        DependencyNodeToNodeTransition transition = pendingTransitions.remove();
        IntSet pendingTypes = transition.pendingTypes;
        transition.pendingTypes = null;
        if (pendingTypes.size() == 1) {
            DependencyType type = types.get(pendingTypes.iterator().next().value);
            transition.consume(type);
        } else {
            DependencyType[] typesToPropagate = new DependencyType[pendingTypes.size()];
            int index = 0;
            for (IntCursor cursor : pendingTypes) {
                typesToPropagate[index++] = types.get(cursor.value);
            }
            transition.consume(typesToPropagate);
        }
    }
}
 
开发者ID:konsoletyper,项目名称:teavm,代码行数:19,代码来源:DependencyAnalyzer.java

示例9: initializeAsNewRestore

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
/**
 * Initializes a new empty index, to be restored from a snapshot
 */
public Builder initializeAsNewRestore(IndexMetaData indexMetaData, SnapshotRecoverySource recoverySource, IntSet ignoreShards) {
    final UnassignedInfo unassignedInfo = new UnassignedInfo(UnassignedInfo.Reason.NEW_INDEX_RESTORED,
                                                             "restore_source[" + recoverySource.snapshot().getRepository() + "/" +
                                                                 recoverySource.snapshot().getSnapshotId().getName() + "]");
    return initializeAsRestore(indexMetaData, recoverySource, ignoreShards, true, unassignedInfo);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:IndexRoutingTable.java

示例10: FetchProjector

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
public FetchProjector(TransportFetchNodeAction transportFetchNodeAction,
                      ThreadPool threadPool,
                      Functions functions,
                      UUID jobId,
                      int collectPhaseId,
                      Map<TableIdent, FetchSource> fetchSources,
                      List<Symbol> outputSymbols,
                      Map<String, IntSet> nodeReaders,
                      TreeMap<Integer, String> readerIndices,
                      Map<String, TableIdent> indicesToIdents) {
    this.transportFetchNodeAction = transportFetchNodeAction;
    this.threadPool = threadPool;
    this.jobId = jobId;
    this.collectPhaseId = collectPhaseId;
    this.fetchSources = fetchSources;
    this.nodeReaders = nodeReaders;
    this.readerIndices = readerIndices;
    this.indicesToIdents = indicesToIdents;

    FetchRowInputSymbolVisitor rowInputSymbolVisitor = new FetchRowInputSymbolVisitor(functions);

    this.collectRowContext = new FetchRowInputSymbolVisitor.Context(fetchSources);

    List<Input<?>> inputs = new ArrayList<>(outputSymbols.size());
    for (Symbol symbol : outputSymbols) {
        inputs.add(rowInputSymbolVisitor.process(symbol, collectRowContext));
    }

    outputRow = new InputRow(inputs);
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:31,代码来源:FetchProjector.java

示例11: FetchProjection

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
public FetchProjection(int collectPhaseId,
                       Map<TableIdent, FetchSource> fetchSources,
                       List<Symbol> outputSymbols,
                       Map<String, IntSet> nodeReaders,
                       TreeMap<Integer, String> readerIndices,
                       Map<String, TableIdent> indicesToIdents) {
    this.collectPhaseId = collectPhaseId;
    this.fetchSources = fetchSources;
    this.outputSymbols = outputSymbols;
    this.nodeReaders = nodeReaders;
    this.readerIndices = readerIndices;
    this.indicesToIdents = indicesToIdents;
}
 
开发者ID:baidu,项目名称:Elasticsearch,代码行数:14,代码来源:FetchProjection.java

示例12: vertexColourDistribution

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
public ObjectObjectOpenHashMap<BitSet,Double> vertexColourDistribution(ColouredGraph graph){
    ObjectObjectOpenHashMap<BitSet,Double> distribution = new ObjectObjectOpenHashMap<BitSet,Double>();
    NumberOfVerticesMetric metric = new NumberOfVerticesMetric();
    double gSize = metric.apply(graph);
    
    ColouredVerticesMetric colouredVertices = new ColouredVerticesMetric();
    ObjectObjectOpenHashMap<BitSet, IntSet> map = colouredVertices.getVerticesForEachColour(graph);
    
    for (ObjectCursor<BitSet> colour : map.keys()) {
         distribution.put(colour.value, (map.get(colour.value).size()/gSize));
    }
    return distribution;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:14,代码来源:Sampling.java

示例13: computeColor

import com.carrotsearch.hppc.IntSet; //导入依赖的package包/类
double[] computeColor(CompositeMap compositeMap,
                      List<? extends Domain> domains,
                      IntSet filteredDomains,
                      SignificancePredicate isSignificant,
                      ScoringFunction score,
                      Neighborhood neighborhood,
                      int typeIndex) {
    double[] color = { 0, 0, 0 };
    int[] totalContributions = { 0 };

    Stream<? extends Domain> stream = domains.stream();
    if (filteredDomains != null) {
        stream = stream.filter(d -> filteredDomains.contains(d.getIndex()));
    }

    stream.forEach(domain -> {
        domain.forEachAttribute(j -> {
            if (!isSignificant.test(neighborhood, j) || !compositeMap.isTop(j, typeIndex)) {
                return;
            }

            double opacity = score.get(neighborhood, j);
            double[] attributeColor = Util.multiply(opacity * opacity, domain.getColor());
            Util.addInPlace(attributeColor, color);
            totalContributions[0]++;
        });
    });

    if (totalContributions[0] == 0) {
        return null;
    }

    Util.divideInPlace(totalContributions[0], color);
    return color;
}
 
开发者ID:baryshnikova-lab,项目名称:safe-java,代码行数:36,代码来源:DomainBrowserController.java

示例14: 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

示例15: 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


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