Java 类it.unimi.dsi.fastutil.ints.Int2ObjectMap 实例源码

项目:angel    文件:ClockVectorManager.java   
/**
 * Adjust clock values
 * @param taskToMatrixClocks taskId->(matrixId->clock) map
 */
public void adjustClocks(Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskToMatrixClocks) {
  ObjectIterator<Int2ObjectMap.Entry<Int2IntOpenHashMap>> taskIter =
    taskToMatrixClocks.int2ObjectEntrySet().fastIterator();
  Int2ObjectMap.Entry<Int2IntOpenHashMap> taskEntry = null;
  int taskId = 0;
  Int2IntOpenHashMap matrixIdToClockMap = null;
  ObjectIterator<Int2IntMap.Entry> matrixIter = null;
  Int2IntMap.Entry matrixEntry = null;

  while(taskIter.hasNext()) {
    taskEntry = taskIter.next();
    taskId = taskEntry.getIntKey();
    matrixIdToClockMap = taskEntry.getValue();
    matrixIter = matrixIdToClockMap.int2IntEntrySet().fastIterator();
    while (matrixIter.hasNext()) {
      matrixEntry = matrixIter.next();
      updateClock(matrixEntry.getIntKey(), taskId, matrixEntry.getIntValue());
    }
  }
}
项目:Diorite-old    文件:SimpleEnum.java   
protected static Entry<Map<String, SimpleEnum<?>>, Int2ObjectMap<SimpleEnum<?>>> init(final Class<?> clazz, final int size)
{
    Map<String, SimpleEnum<?>> byName = ASimpleEnum.byName.get(clazz);
    if (byName == null)
    {
        byName = new CaseInsensitiveMap<>(size, SMALL_LOAD_FACTOR);
        ASimpleEnum.byName.put(clazz, byName);
    }
    Int2ObjectMap<SimpleEnum<?>> byID = ASimpleEnum.byOrdinal.get(clazz);
    if (byID == null)
    {
        byID = new Int2ObjectOpenHashMap<>(size, SMALL_LOAD_FACTOR);
        ASimpleEnum.byOrdinal.put(clazz, byID);
    }
    return new SimpleEntry<>(byName, byID);
}
项目:incubator-hivemall    文件:SlimUDTF.java   
private static double predict(final int user, final int itemI,
        @Nonnull final Int2ObjectMap<Int2FloatMap> knnItems, final int excludeIndex,
        @Nonnull final FloatMatrix weightMatrix) {
    final Int2FloatMap kNNu = knnItems.get(user);
    if (kNNu == null) {
        return 0.d;
    }

    double pred = 0.d;
    for (Int2FloatMap.Entry e : Fastutil.fastIterable(kNNu)) {
        final int itemK = e.getIntKey();
        if (itemK == excludeIndex) {
            continue;
        }
        float ruk = e.getFloatValue();
        pred += ruk * weightMatrix.get(itemI, itemK, 0.d);
    }
    return pred;
}
项目:incubator-hivemall    文件:SlimUDTF.java   
private void replayTrain(@Nonnull final ByteBuffer buf) {
    final int itemI = buf.getInt();
    final int knnSize = buf.getInt();

    final Int2ObjectMap<Int2FloatMap> knnItems = new Int2ObjectOpenHashMap<>(1024);
    final IntSet pairItems = new IntOpenHashSet();
    for (int i = 0; i < knnSize; i++) {
        int user = buf.getInt();
        int ruSize = buf.getInt();
        Int2FloatMap ru = new Int2FloatOpenHashMap(ruSize);
        ru.defaultReturnValue(0.f);

        for (int j = 0; j < ruSize; j++) {
            int itemK = buf.getInt();
            pairItems.add(itemK);
            float ruk = buf.getFloat();
            ru.put(itemK, ruk);
        }
        knnItems.put(user, ru);
    }

    for (int itemJ : pairItems) {
        train(itemI, knnItems, itemJ);
    }
}
项目:incubator-hivemall    文件:SlimUDTF.java   
@Nonnull
private static Int2ObjectMap<Int2FloatMap> kNNentries(@Nonnull final Object kNNiObj,
        @Nonnull final MapObjectInspector knnItemsOI,
        @Nonnull final PrimitiveObjectInspector knnItemsKeyOI,
        @Nonnull final MapObjectInspector knnItemsValueOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueKeyOI,
        @Nonnull final PrimitiveObjectInspector knnItemsValueValueOI,
        @Nullable Int2ObjectMap<Int2FloatMap> knnItems, @Nonnull final MutableInt nnzKNNi) {
    if (knnItems == null) {
        knnItems = new Int2ObjectOpenHashMap<>(1024);
    } else {
        knnItems.clear();
    }

    int numElementOfKNNItems = 0;
    for (Map.Entry<?, ?> entry : knnItemsOI.getMap(kNNiObj).entrySet()) {
        int user = PrimitiveObjectInspectorUtils.getInt(entry.getKey(), knnItemsKeyOI);
        Int2FloatMap ru = int2floatMap(knnItemsValueOI.getMap(entry.getValue()),
            knnItemsValueKeyOI, knnItemsValueValueOI);
        knnItems.put(user, ru);
        numElementOfKNNItems += ru.size();
    }

    nnzKNNi.setValue(numElementOfKNNItems);
    return knnItems;
}
项目:FinanceAnalytics    文件:TuplesUtil.java   
public static Int2ObjectMap.Entry pairToEntry(final IntObjectPair pair) {
  return new Int2ObjectMap.Entry() {
    @Override
    public int getIntKey() {
      return pair.getFirstInt();
    }

    @Override
    public Object getKey() {
      return pair.getFirst();
    }

    @Override
    public Object getValue() {
      return pair.getSecond();
    }

    @Override
    public Object setValue(Object value) {
      throw new UnsupportedOperationException("This entry is immutable");
    }
  };
}
项目:apex-malhar    文件:CustomTimeBucketRegistry.java   
private int initialize(Int2ObjectMap<CustomTimeBucket> idToTimeBucket)
{
  Preconditions.checkNotNull(idToTimeBucket);

  int tempId = Integer.MIN_VALUE;

  for (int timeBucketId : idToTimeBucket.keySet()) {
    tempId = Math.max(tempId, timeBucketId);
    CustomTimeBucket customTimeBucket = idToTimeBucket.get(timeBucketId);
    textToTimeBucket.put(customTimeBucket.getText(), customTimeBucket);
    Preconditions.checkNotNull(customTimeBucket);
    timeBucketToId.put(customTimeBucket, timeBucketId);
  }

  return tempId;
}
项目:apex-malhar    文件:DimensionalConfigurationSchema.java   
protected void buildNonCompositeAggregatorIDMap(String aggregatorName, FieldsDescriptor inputDescriptor,
    IntArrayList aggIDList, Int2ObjectMap<FieldsDescriptor> inputMap, Int2ObjectMap<FieldsDescriptor> outputMap)
{
  IncrementalAggregator incrementalAggregator = aggregatorRegistry.getNameToIncrementalAggregator().get(
      aggregatorName);
  //don't need to build OTF aggregate
  if (incrementalAggregator == null) {
    return;
  }
  int aggregatorID = aggregatorRegistry.getIncrementalAggregatorNameToID().get(aggregatorName);
  mergeAggregatorID(aggIDList, aggregatorID);
  inputMap.put(aggregatorID, inputDescriptor);
  outputMap.put(aggregatorID,
      AggregatorUtils.getOutputFieldsDescriptor(inputDescriptor,
      incrementalAggregator));
}
项目:llamafur    文件:IntMapGraph.java   
public IntMapGraph(Int2ObjectMap<IntSet> map) {
    this.map = map;
    if (map.defaultReturnValue() == null || !map.defaultReturnValue().equals(IntSets.EMPTY_SET)) {
        LOGGER.warn("It is necessary to set default return value of the map as the empty set.");
        map.defaultReturnValue(IntSets.EMPTY_SET);
    }

    int maxNodeIndex = 0, numArcs = 0;
    for (Entry<IntSet> x : map.int2ObjectEntrySet()) {
        if (x.getIntKey() > maxNodeIndex)
            maxNodeIndex = x.getIntKey();
        for (int succ : x.getValue()) {
            if (succ > maxNodeIndex)
                maxNodeIndex = succ;
            numArcs++;
        }
    }

    this.numArcs  = numArcs;
    this.numNodes = maxNodeIndex+1;
}
项目:llamafur    文件:LatentMatrixEstimator.java   
public LatentMatrixEstimator(ImmutableGraph graph, Int2ObjectMap<IntSet> node2cat, String output, Matrix initialMatrix) {

    rnd = RandomSingleton.get();
    pl = new ProgressLogger(LOGGER, "node couples");

    this.graph = graph;
    this.node2cat = node2cat;
    if (graph.numNodes() != node2cat.size()) {
        LOGGER.warn("node2cat file and graph file have a different number of nodes: " +
                "respectively, " + node2cat.size() + " and " + graph.numNodes());
    }

    numNodes = graph.numNodes();

    classifier = new PAClassifier(initialMatrix);
    this.output = output;
    nArcsLearned = 0;

}
项目:llamafur    文件:PooledDatasetChecker.java   
public PooledDatasetChecker(GroundTruth evaluations, ImmutableGraph g, UnexpectednessScorer[] pool, Int2ObjectMap<String> id2name) throws IOException {
    this.graph = g;
    this.pool = pool;
    this.evaluations = evaluations;
    this.id2name = id2name;
    SummaryStatistics[] stats = new SummaryStatistics[pool.length];
    for (int i = 0; i < stats.length; i++)
        stats[i] = new SummaryStatistics();
    retriever2itsFraction = new Object2ObjectOpenHashMap<UnexpectednessScorer, SummaryStatistics>(pool, stats);
    for (int i = 0; i < stats.length; i++)
        stats[i] = new SummaryStatistics();
    retriever2evaluatedTopResults = new Object2ObjectOpenHashMap<UnexpectednessScorer, SummaryStatistics>(pool, stats);
    unmatchStats = new SummaryStatistics();

    System.out.println(evaluations.stats());
}
项目:Diorite    文件:DioriteRandomUtils.java   
@Nullable
public static <T> T getWeightedRandomReversed(Random random, Int2ObjectMap<T> choices)
{
    long i = 0;
    IntSet ints = choices.keySet();
    for (IntIterator iterator = ints.iterator(); iterator.hasNext(); )
    {
        int x = iterator.nextInt();
        i += x;
    }
    i = getRandomLong(random, 0, i);
    for (Int2ObjectMap.Entry<T> entry : choices.int2ObjectEntrySet())
    {
        i -= entry.getIntKey();
        if (i < 0)
        {
            return entry.getValue();
        }
    }
    return null;
}
项目:FastAsyncWorldedit    文件:BlockVectorSet.java   
public Vector get(int index) {
    int count = 0;
    ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> iter = localSets.int2ObjectEntrySet().iterator();
    while (iter.hasNext()) {
        Int2ObjectMap.Entry<LocalBlockVectorSet> entry = iter.next();
        LocalBlockVectorSet set = entry.getValue();
        int size = set.size();
        int newSize = count + size;
        if (newSize > index) {
            int localIndex = index - count;
            Vector pos = set.getIndex(localIndex);
            if (pos != null) {
                int pair = entry.getIntKey();
                int cx = MathMan.unpairX(pair);
                int cz = MathMan.unpairY(pair);
                pos.mutX((cx << 11) + pos.getBlockX());
                pos.mutZ((cz << 11) + pos.getBlockZ());
                return pos;
            }
        }
        count += newSize;
    }
    return null;
}
项目:FastAsyncWorldedit    文件:TextureUtil.java   
protected void calculateLayerArrays() {
    Int2ObjectOpenHashMap<char[]> colorLayerMap = new Int2ObjectOpenHashMap<>();
    for (int i = 0; i < validBlockIds.length; i++) {
        int color = validColors[i];
        int combined = validBlockIds[i];
        if (hasAlpha(color)) {
            for (int j = 0; j < validBlockIds.length; j++) {
                int colorOther = validColors[j];
                if (!hasAlpha(colorOther)) {
                    int combinedOther = validBlockIds[j];
                    int combinedColor = combineTransparency(color, colorOther);
                    colorLayerMap.put(combinedColor, new char[]{(char) combined, (char) combinedOther});
                }
            }
        }
    }
    this.validLayerColors = new int[colorLayerMap.size()];
    this.validLayerBlocks = new char[colorLayerMap.size()][];
    int index = 0;
    for (Int2ObjectMap.Entry<char[]> entry : colorLayerMap.int2ObjectEntrySet()) {
        validLayerColors[index] = entry.getIntKey();
        validLayerBlocks[index++] = entry.getValue();
    }
}
项目:webanno    文件:ConllUReader.java   
private Dependency makeDependency(JCas aJCas, int govId, int depId, String label, String flavor,
        Int2ObjectMap<Token> tokens, String[] word)
{
    Dependency rel = new Dependency(aJCas);
    if (govId == 0) {
        rel.setGovernor(tokens.get(depId));
        rel.setDependent(tokens.get(depId));
    }
    else {
        rel.setGovernor(tokens.get(govId));
        rel.setDependent(tokens.get(depId));
    }

    rel.setDependencyType(label);
    // This is set via FSUtil because we still use the DKPro Core 1.7.0 JCas classes
    FSUtil.setFeature(rel, "flavor", flavor);
    rel.setBegin(rel.getDependent().getBegin());
    rel.setEnd(rel.getDependent().getEnd());
    rel.addToIndexes();

    return rel;
}
项目:s2tbx    文件:Graph.java   
public void removeUselessNodes(Int2ObjectMap<Node> borderNodes, ProcessingTile tile) {
    int nodeCount = this.nodes.size();
    for (int i=0; i<nodeCount; i++) {
        Node node = this.nodes.get(i);
        BoundingBox box = node.getBox();

        if (box.getLeftX() > tile.getImageLeftX() && box.getTopY() > tile.getImageTopY() && box.getRightX() - 1 < tile.getImageRightX() && box.getBottomY() - 1 < tile.getImageBottomY()) {
            continue;
        } else if (!borderNodes.containsKey(node.getId())) {
            removeEdgeToUnstableNode(node);
            node.setExpired(true);
        }
    }

    removeExpiredNodes();
}
项目:s2tbx    文件:GraphTest.java   
@Test
public void testBuildBorderPixelMap() {
    int imageWidth = 10;
    int imageHeight = 10;
    int tileLeftX = 0;
    int tileTopY = 0;
    int tileSizeX = 3;
    int tileSizeY = 3;
    int tileMargin = 1;
    int tileCountX = (imageWidth / tileSizeX);
    int tileCountY = (imageHeight / tileSizeY);

    Graph graph = checkGraph(imageWidth);

    ProcessingTile tile = AbstractTileSegmenter.buildTile(tileLeftX, tileTopY, tileSizeX, tileSizeY, tileMargin, imageWidth, imageHeight);

    Int2ObjectMap<List<Node>> borderPixelMap = graph.buildBorderPixelMap(tile, 0, 0, tileCountX, tileCountY, imageWidth);

    assertNotNull(borderPixelMap);
    assertEquals(2, borderPixelMap.size());
}
项目:s2tbx    文件:GraphTest.java   
@Test
public void testRemoveDuplicatedNodes() {
    int imageWidth = 10;
    int imageHeight = 10;
    int tileLeftX = 0;
    int tileTopY = 0;
    int tileSizeX = 3;
    int tileSizeY = 3;
    int tileMargin = 1;
    int tileCountX = (imageWidth / tileSizeX);
    int tileCountY = (imageHeight / tileSizeY);

    Graph graph = checkGraph(imageWidth);

    ProcessingTile tile = AbstractTileSegmenter.buildTile(tileLeftX, tileTopY, tileSizeX, tileSizeY, tileMargin, imageWidth, imageHeight);

    Int2ObjectMap<List<Node>> borderPixelMap = graph.buildBorderPixelMap(tile, 0, 0, tileCountX, tileCountY, imageWidth);

    assertNotNull(borderPixelMap);
    assertEquals(2, borderPixelMap.size());

    graph.removeDuplicatedNodes(borderPixelMap, imageWidth);

    assertEquals(3, graph.getNodeCount());
}
项目:s2tbx    文件:GraphTest.java   
@Test
public void testRemoveUselessNodes() {
    int imageWidth = 10;
    int imageHeight = 10;
    int tileLeftX = 0;
    int tileTopY = 0;
    int tileSizeX = 3;
    int tileSizeY = 3;
    int tileMargin = 1;

    Graph graph = checkGraph(imageWidth);

    ProcessingTile tile = AbstractTileSegmenter.buildTile(tileLeftX, tileTopY, tileSizeX, tileSizeY, tileMargin, imageWidth, imageHeight);

    Int2ObjectMap<Node> borderNodes = new Int2ObjectLinkedOpenHashMap<Node>(1);
    Node node = graph.getNodeAt(0);
    borderNodes.put(node.getId(), node);
    graph.removeUselessNodes(borderNodes, tile);

    assertEquals(1, graph.getNodeCount());
}
项目:pinot    文件:StarTreeDataTable.java   
/**
 * Group all documents based on a dimension's value.
 *
 * @param startDocId Start document id of the range to be grouped
 * @param endDocId End document id (exclusive) of the range to be grouped
 * @param dimensionId Index of the dimension to group on
 * @return Map from dimension value to a pair of start docId and end docId (exclusive)
 */
public Int2ObjectMap<IntPair> groupOnDimension(int startDocId, int endDocId, int dimensionId) {
  int startDocIdOffset = startDocId - _startDocId;
  int endDocIdOffset = endDocId - _startDocId;
  Int2ObjectMap<IntPair> rangeMap = new Int2ObjectLinkedOpenHashMap<>();
  int dimensionOffset = dimensionId * V1Constants.Numbers.INTEGER_SIZE;
  int currentValue = _dataBuffer.getInt(startDocIdOffset * _docSize + dimensionOffset);
  int groupStartDocId = startDocId;
  for (int i = startDocIdOffset + 1; i < endDocIdOffset; i++) {
    int value = _dataBuffer.getInt(i * _docSize + dimensionOffset);
    if (value != currentValue) {
      int groupEndDocId = i + _startDocId;
      rangeMap.put(currentValue, new IntPair(groupStartDocId, groupEndDocId));
      currentValue = value;
      groupStartDocId = groupEndDocId;
    }
  }
  rangeMap.put(currentValue, new IntPair(groupStartDocId, endDocId));
  return rangeMap;
}
项目:metanome-algorithms    文件:FunctionalDependencyGenerator.java   
public FunctionalDependencyGenerator(FunctionalDependencyResultReceiver fdrr, String relationName,
                                     List<String> columnIdentifer, int numberOfThreads, Int2ObjectMap<List<OpenBitSet>> lhss) {

    super(numberOfThreads, "FunctionalDependencyGen");

    this.fdrr = fdrr;
    this.relationName = relationName;
    this.columns = columnIdentifer;
    this.lhss = lhss;
}
项目:metanome-algorithms    文件:PositionListIndex.java   
public PositionListIndex intersect(int[] otherPLI) {
    Int2ObjectMap<Int2ObjectMap<IntArrayList>> intersectMap = this.buildIntersectMap(otherPLI);

    List<IntArrayList> clusters = new ArrayList<>();
    for (Int2ObjectMap<IntArrayList> cluster1 : intersectMap.values())
        for (IntArrayList cluster2 : cluster1.values())
            if (cluster2.size() > 1)
                clusters.add(cluster2);

    return new PositionListIndex(-1, clusters);
}
项目:metanome-algorithms    文件:PositionListIndex.java   
public PositionListIndex intersect(int[] otherPLI) {
    Int2ObjectMap<Int2ObjectMap<IntArrayList>> intersectMap = this.buildIntersectMap(otherPLI);

    List<IntArrayList> clusters = new ArrayList<>();
    for (Int2ObjectMap<IntArrayList> cluster1 : intersectMap.values())
        for (IntArrayList cluster2 : cluster1.values())
            if (cluster2.size() > 1)
                clusters.add(cluster2);

    return new PositionListIndex(-1, clusters);
}
项目:monarch    文件:DiskInitFile.java   
private void saveCanonicalIds() {
  Int2ObjectOpenHashMap mappings = canonicalIdHolder.getAllMappings();
  for (ObjectIterator<Int2ObjectMap.Entry<?>> i = mappings.int2ObjectEntrySet().fastIterator(); i
      .hasNext();) {
    Int2ObjectMap.Entry<?> entry = i.next();
    writeCanonicalId(entry.getIntKey(), entry.getValue());
  }
}
项目:naisc    文件:WeightedBipartiteMatching.java   
private Collection<Alignment> bipartiteMatch(Int2ObjectMap<Entity> schema1, Int2ObjectMap<Entity> schema2, Mat m) {
    MunkRes munkRes = new MunkRes(m);
    double[] sim = m.sim();
    final Collection<Alignment> alignmentSet = new ArrayList<>();
    for(IntPair ip : munkRes.execute()) {
        if(m.contains(ip._1, ip._2)) {
            final String e1id = schema1.get(ip._1).id;
            final String e2id = schema2.get(ip._2).id;
            final double s = sim[m.ij2index(ip._1, ip._2)];
            alignmentSet.add(new Alignment(e1id, e2id, Math.min(s,1.0)));
        }
    }
    System.err.printf("Produced %d matches from %d x %d\n", alignmentSet.size(), schema1.size(), schema2.size());
    return alignmentSet;
}
项目:incubator-hivemall    文件:ColumnMajorDenseMatrixBuilder.java   
@Override
public ColumnMajorDenseMatrix2d buildMatrix() {
    final double[][] data = new double[maxNumColumns][];

    for (Int2ObjectMap.Entry<SparseDoubleArray> e : Fastutil.fastIterable(col2rows)) {
        int col = e.getIntKey();
        SparseDoubleArray rows = e.getValue();
        data[col] = rows.toArray();
    }

    return new ColumnMajorDenseMatrix2d(data, row, nnz);
}
项目:incubator-hivemall    文件:SlimUDTF.java   
private void train(final int itemI, @Nonnull final Int2FloatMap ri,
        @Nonnull final Int2ObjectMap<Int2FloatMap> kNNi, final int itemJ,
        @Nonnull final Int2FloatMap rj) {
    final FloatMatrix W = _weightMatrix;

    final int N = rj.size();
    if (N == 0) {
        return;
    }

    double gradSum = 0.d;
    double rateSum = 0.d;
    double lossSum = 0.d;

    for (Int2FloatMap.Entry e : Fastutil.fastIterable(rj)) {
        int user = e.getIntKey();
        double ruj = e.getFloatValue();
        double rui = ri.get(user); // ri.getOrDefault(user, 0.f);

        double eui = rui - predict(user, itemI, kNNi, itemJ, W);
        gradSum += ruj * eui;
        rateSum += ruj * ruj;
        lossSum += eui * eui;
    }

    gradSum /= N;
    rateSum /= N;

    double wij = W.get(itemI, itemJ, 0.d);
    double loss = lossSum / N + 0.5d * l2 * wij * wij + l1 * wij;
    _cvState.incrLoss(loss);

    W.set(itemI, itemJ, getUpdateTerm(gradSum, rateSum, l1, l2));
}
项目:incubator-hivemall    文件:SlimUDTF.java   
private void train(final int itemI, @Nonnull final Int2ObjectMap<Int2FloatMap> knnItems,
        final int itemJ) {
    final FloatMatrix A = _dataMatrix;
    final FloatMatrix W = _weightMatrix;

    final int N = A.numColumns(itemJ);
    if (N == 0) {
        return;
    }

    final MutableDouble mutableGradSum = new MutableDouble(0.d);
    final MutableDouble mutableRateSum = new MutableDouble(0.d);
    final MutableDouble mutableLossSum = new MutableDouble(0.d);

    A.eachNonZeroInRow(itemJ, new VectorProcedure() {
        @Override
        public void apply(int user, double ruj) {
            double rui = A.get(itemI, user, 0.d);
            double eui = rui - predict(user, itemI, knnItems, itemJ, W);

            mutableGradSum.addValue(ruj * eui);
            mutableRateSum.addValue(ruj * ruj);
            mutableLossSum.addValue(eui * eui);
        }
    });

    double gradSum = mutableGradSum.getValue() / N;
    double rateSum = mutableRateSum.getValue() / N;

    double wij = W.get(itemI, itemJ, 0.d);
    double loss = mutableLossSum.getValue() / N + 0.5 * l2 * wij * wij + l1 * wij;
    _cvState.incrLoss(loss);

    W.set(itemI, itemJ, getUpdateTerm(gradSum, rateSum, l1, l2));
}
项目:incubator-hivemall    文件:Fastutil.java   
@Nonnull
public static <V> ObjectIterable<Int2ObjectMap.Entry<V>> fastIterable(
        @Nonnull final Int2ObjectMap<V> map) {
    final ObjectSet<Int2ObjectMap.Entry<V>> entries = map.int2ObjectEntrySet();
    return entries instanceof Int2ObjectMap.FastEntrySet ? new ObjectIterable<Int2ObjectMap.Entry<V>>() {
        public ObjectIterator<Int2ObjectMap.Entry<V>> iterator() {
            return ((Int2ObjectMap.FastEntrySet<V>) entries).fastIterator();
        }
    }
            : entries;
}
项目:tablesaw    文件:DictionaryMap.java   
/**
 * Returns a new DictionaryMap that is a deep copy of the original
 */
public DictionaryMap(DictionaryMap original) {
    for (Int2ObjectMap.Entry<String> entry : original.keyToValue.int2ObjectEntrySet()) {
        keyToValue.put(entry.getIntKey(), entry.getValue());
        valueToKey.put(entry.getValue(), entry.getIntKey());
    }
    valueToKey.defaultReturnValue(-1);
}
项目:GraphJet    文件:LeftSegmentRandomEdgeAccessor.java   
LeftSegmentRandomEdgeAccessor(
    MultiSegmentReaderAccessibleInfo<T> readerAccessibleInfo,
    Int2ObjectMap<ReusableInternalIdToLongIterator> segmentInternalIdToLongIteratorMap,
    Int2ObjectMap<ReusableNodeRandomIntIterator> segmentNodeRandomIntIteratorMap) {
  super(readerAccessibleInfo,
        segmentInternalIdToLongIteratorMap,
        segmentNodeRandomIntIteratorMap);
}
项目:GraphJet    文件:LeftIndexedMultiSegmentBipartiteGraph.java   
protected Int2ObjectMap<T> getSegments() {
  // Hopefully branch prediction should make this really cheap as it'll always be false!
  if (crossMemoryBarrier() == -1) {
    return null;
  }
  return multiSegmentReaderAccessibleInfoProvider
      .getMultiSegmentReaderAccessibleInfo().getSegments();
}
项目:GraphJet    文件:SegmentEdgeRandomAccessor.java   
SegmentEdgeRandomAccessor(
    MultiSegmentReaderAccessibleInfo<T> readerAccessibleInfo,
    Int2ObjectMap<ReusableInternalIdToLongIterator> segmentInternalIdToLongIteratorMap,
    Int2ObjectMap<ReusableNodeRandomIntIterator> segmentNodeRandomIntIteratorMap) {
  super(readerAccessibleInfo);
  this.segmentInternalIdToLongIteratorMap = segmentInternalIdToLongIteratorMap;
  this.segmentNodeRandomIntIteratorMap = segmentNodeRandomIntIteratorMap;
}
项目:GraphJet    文件:RightSegmentRandomEdgeAccessor.java   
RightSegmentRandomEdgeAccessor(
    MultiSegmentReaderAccessibleInfo<BipartiteGraphSegment> readerAccessibleInfo,
    Int2ObjectMap<ReusableInternalIdToLongIterator> segmentInternalIdToLongIteratorMap,
    Int2ObjectMap<ReusableNodeRandomIntIterator> segmentNodeRandomIntIteratorMap) {
  super(readerAccessibleInfo,
        segmentInternalIdToLongIteratorMap,
        segmentNodeRandomIntIteratorMap);
}
项目:GraphJet    文件:MultiSegmentReaderAccessibleInfo.java   
/**
 * A new instance is immediately visible to the readers due to publication safety.
 *
 * @param segments               contains all the present segments
 * @param oldestSegmentId        is the id of the oldest segment
 * @param liveSegmentId          is the id of the live segment
 */
public MultiSegmentReaderAccessibleInfo(
    Int2ObjectMap<T> segments,
    int oldestSegmentId,
    int liveSegmentId) {
  this.segments = segments;
  this.oldestSegmentId = oldestSegmentId;
  this.liveSegmentId = liveSegmentId;
}
项目:apex-malhar    文件:CustomTimeBucketRegistry.java   
public CustomTimeBucketRegistry(Int2ObjectMap<CustomTimeBucket> idToTimeBucket, int startingId)
{
  int tempId = initialize(idToTimeBucket);

  Preconditions.checkArgument(tempId < startingId, "The statingId " + startingId
      + " must be larger than the largest ID " + tempId + " in the given idToTimeBucket mapping");

  this.idToTimeBucket = Preconditions.checkNotNull(idToTimeBucket);
  this.currentId = startingId;
}
项目:llamafur    文件:LlamaFurScorer.java   
@SuppressWarnings("unchecked")
public LlamaFurScorer(String graphBasename, String matrixPath, String page2catPath, String name) throws ClassNotFoundException, IOException {
    this(
        ImmutableGraph.load(graphBasename),
        (Matrix) SerializationUtils.read(matrixPath),
        (Int2ObjectMap<IntSet>) SerializationUtils.read(page2catPath),
        name
    );
}
项目:llamafur    文件:TestMatrix.java   
@CommandLine(argNames={"matrix", "graph", "page2cat", "negativeToPositiveRatio", "verbose"})
public TestMatrix(Matrix matrix, ImmutableGraph graph,
        Int2ObjectMap<IntSet> page2cat, double negativeToPositiveRatio, boolean verbose) {
    super();
    this.matrix = matrix;
    this.graph = graph;
    this.page2cat = page2cat;
    this.negativeToPositiveRatio = negativeToPositiveRatio;
    this.verbose = verbose;
    numNodes = graph.numNodes();
    classifier = new PAClassifier(matrix);
}
项目:llamafur    文件:PrecisionRecallPlot.java   
@SuppressWarnings("unchecked")
@CommandLine(argNames = { "poolSpecificationFile", "evaluationDataset", "name2id"})
public PrecisionRecallPlot(String poolSpecificationFile, String datasetPath, Object2IntMap<String> name2id)
            throws Exception {
    super(
            new PoolSpecification(poolSpecificationFile),
            GroundTruth.fromUTF8FilePath(datasetPath, name2id)
    );

    this.checkEveryResultIsAnOutlinkInThisGraph = super.graph;

    groundtruth.checkAgreementWith(super.graph, (Int2ObjectMap<String>) MapUtils.invert(name2id));
}
项目:llamafur    文件:AbstractMeasure.java   
@SuppressWarnings("unchecked")
public static <T extends AbstractMeasure> void main(String[] args, Class<T> concreteMeasure) throws Exception {
    JsapResultsWithObject<T> jsapObj = JsapUtils
            .constructObject(concreteMeasure, args, "Compute " + concreteMeasure.getSimpleName(),
                    new Parameter[] {

                    new FlaggedOption("names",
                            JSAP.STRING_PARSER, JSAP.NO_DEFAULT,
                            JSAP.NOT_REQUIRED, 'n', "names",
                            "if supplied, output will use names for each query instead of query id"),
                    new FlaggedOption( "output", 
                            JSAP.STRING_PARSER, null, JSAP.NOT_REQUIRED, 
                            'o', "output", 
                            "Output file path to save query-specific data." ),

            });

    T measurer = jsapObj.getObject();
    JSAPResult jsap = jsapObj.getJsapResult();
    if (jsap.contains("names"))
        measurer.setQueryNames((Int2ObjectMap<String>) SerializationUtils
                .read(jsap.getString("names")));

    if (jsap.contains("output"))
        measurer.setOutputPathTo(jsap.getString("output"));

    measurer.computeAll();
    measurer.close();

}