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


Java Int2IntOpenHashMap.put方法代码示例

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


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

示例1: loadSparseIntPartition

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private static void loadSparseIntPartition(SparseIntModel model, FSDataInputStream input,
    ModelPartitionMeta partMeta) throws IOException {
  int rowNum = input.readInt();
  int rowId = 0;
  int nnz = 0;
  int totalNNZ = 0;
  Int2IntOpenHashMap row = null;

  for (int i = 0; i < rowNum; i++) {
    rowId = input.readInt();
    nnz = input.readInt();
    totalNNZ = (int) (nnz * (model.col) / (partMeta.getEndCol() - partMeta.getStartCol()));
    row = model.getRow(rowId, partMeta.getPartId(), totalNNZ);
    for (int j = 0; j < nnz; j++) {
      row.put(input.readInt(), input.readInt());
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ModelLoader.java

示例2: getTaskMatrixClocks

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * Get task clocks for all matrices from Master
 * @return task clocks for all matrices from Master
 * @throws ServiceException
 */
public Int2ObjectOpenHashMap<Int2IntOpenHashMap> getTaskMatrixClocks() throws ServiceException {
  GetTaskMatrixClockResponse response = masterProxy.getTaskMatrixClocks(null,
    GetTaskMatrixClockRequest.newBuilder().build());
  Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskIdToMatrixClocksMap = new Int2ObjectOpenHashMap<>(response.getTaskMatrixClocksCount());

  List<TaskMatrixClock> taskMatrixClocks = response.getTaskMatrixClocksList();
  int size = taskMatrixClocks.size();
  int matrixNum;
  for(int i = 0; i < size; i++) {
    Int2IntOpenHashMap matrixIdToClockMap = new Int2IntOpenHashMap(taskMatrixClocks.get(i).getMatrixClocksCount());
    taskIdToMatrixClocksMap.put(taskMatrixClocks.get(i).getTaskId().getTaskIndex(), matrixIdToClockMap);
    List<MatrixClock> matrixClocks = taskMatrixClocks.get(i).getMatrixClocksList();
    matrixNum = matrixClocks.size();
    for(int j = 0; j < matrixNum; j++) {
      matrixIdToClockMap.put(matrixClocks.get(j).getMatrixId(), matrixClocks.get(j).getClock());
    }
  }

  return taskIdToMatrixClocksMap;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:26,代码来源:MasterClient.java

示例3: loadSparseIntRowFromPartition

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
public static Int2IntOpenHashMap loadSparseIntRowFromPartition(FSDataInputStream input,
    ModelPartitionMeta partMeta, int rowId) throws IOException {
  RowOffset rowOffset = partMeta.getRowMetas().get(rowId);
  input.seek(rowOffset.getOffset());
  Preconditions.checkState (input.readInt() == rowId);
  int num = input.readInt();
  Int2IntOpenHashMap row = new Int2IntOpenHashMap();
  for (int i = 0; i < num; i++) {
    row.put(input.readInt(), input.readInt());
  }
  return row;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:ModelLoader.java

示例4: deserialize

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
@Override
public void deserialize(ByteBuf buf) {
  super.deserialize(buf);
  part = new ServerPartition();
  part.deserialize(buf);
  int clockVecSize = buf.readInt();
  if(clockVecSize > 0) {
    taskIndexToClockMap = new Int2IntOpenHashMap(clockVecSize);
    for(int i = 0; i < clockVecSize; i++) {
      taskIndexToClockMap.put(buf.readInt(), buf.readInt());
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:RecoverPartRequest.java

示例5: getPartClocks

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * Get partition id to partition clock map
 * @return partition id to partition clock map
 */
public Int2IntOpenHashMap getPartClocks() {
  Int2IntOpenHashMap partClocks = new Int2IntOpenHashMap(partIdToClockVecMap.size());
  for(Map.Entry<Integer, PartClockVector> entry : partIdToClockVecMap.entrySet()) {
    partClocks.put(entry.getKey().intValue(), entry.getValue().getMinClock());
  }
  return partClocks;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:12,代码来源:MatrixClockVector.java

示例6: PartClockVector

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * Create a PartClockVector
 * @param taskNum total task number
 */
public PartClockVector(int taskNum) {
  this.taskNum = taskNum;
  minClock = 0;
  taskIndexToClockMap = new Int2IntOpenHashMap(taskNum);
  for(int i = 0; i < taskNum; i++) {
    taskIndexToClockMap.put(i, 0);
  }
  lock = new ReentrantReadWriteLock();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:PartClockVector.java

示例7: setUp

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
@Setup
@Override
public void setUp() {
	super.setUp();

	map = new Int2IntOpenHashMap();
	for (int i = 0; i < size; ++i) {
		map.put(i, i);
	}
}
 
开发者ID:gpanther,项目名称:itdays-2016-cpu-workshop,代码行数:11,代码来源:_03_b_LookupHash.java

示例8: asHashMap

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * Returns the position list index in a map representation. Every row index
 * maps to a value reconstruction. As the original values are unknown they
 * are represented by a counter. The position list index ((0, 1), (2, 4),
 * (3, 5)) would be represented by {0=0, 1=0, 2=1, 3=2, 4=1, 5=2}.
 *
 * @return the pli as hash map
 */
public Int2IntOpenHashMap asHashMap() {
    Int2IntOpenHashMap hashedPLI = new Int2IntOpenHashMap(clusters.size());
    int uniqueValueCount = 0;
    for (IntArrayList sameValues : clusters) {
        for (int rowIndex : sameValues) {
            hashedPLI.put(rowIndex, uniqueValueCount);
        }
        uniqueValueCount++;
    }
    return hashedPLI;
}
 
开发者ID:mpoiitis,项目名称:DUCCspark,代码行数:20,代码来源:PositionListIndex.java

示例9: test

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
@Override
public int test() {
    final Int2IntOpenHashMap m_map = new Int2IntOpenHashMap( m_keys.length, m_fillFactor );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ],m_keys[ i ] );
    for ( int i = 0; i < m_keys.length; ++i )
        m_map.put( m_keys[ i ],m_keys[ i ] );
    return m_map.size();
}
 
开发者ID:mikvor,项目名称:hashmapTest,代码行数:10,代码来源:FastUtilMapTest.java

示例10: mergeInfrequentPhrasesWithFrequentPhraseClusters

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * see paragraph "We know of ..." on page 472 of [Brown et al.].
 */

private void mergeInfrequentPhrasesWithFrequentPhraseClusters(int startPhrase, int endPhrase, Int2IntOpenHashMap phraseToClusterMap, ContextCountsImpl clusterContextCounts) {
    for (int infrequentPhrase = startPhrase; infrequentPhrase < endPhrase; infrequentPhrase++) {
        int cluster = findBestClusterToMerge(infrequentPhrase, 0, maxNumberOfClusters, clusterContextCounts).getFirst();
        UI.write("Will merge phrase " + infrequentPhrase + " with " + cluster);
        clusterContextCounts.mergeClusters(infrequentPhrase, cluster);
        phraseToClusterMap.put(infrequentPhrase, cluster);
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:13,代码来源:BrownClustering.java

示例11: swapPhrases

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * see paragraph "We know of ..." on page 472 of [Brown et al.].
 */

private void swapPhrases(int phraseStart, int phraseEnd, Int2IntOpenHashMap phraseToClusterMap, ContextCountsImpl clusterContextCounts, ContextCountsImpl phraseContextCounts) {
    int numOfPhrases = phraseEnd - phraseStart;
    int numOfPhrasesChangedInLastIteration = numOfPhrases;
    int iteration = 0;
    //continue swapping phrases until less then 1% of the phrases has changed in the last iteration
    while (numOfPhrasesChangedInLastIteration * 100 > numOfPhrases) {
        numOfPhrasesChangedInLastIteration = 0;
        for (int phrase = phraseStart; phrase < phraseEnd; phrase++) {
            int currCluster = phraseToClusterMap.get(phrase);
            ContextCountsImpl contextCountsForPhrase = mapPhraseCountsToClusterCounts(phrase, phraseToClusterMap, phraseContextCounts, SwapWordContextCounts.DUMMY_CLUSTER);
            SwapWordContextCounts swapWordContextCounts = new SwapWordContextCounts(clusterContextCounts, contextCountsForPhrase, currCluster);
            Pair<Integer, Double> bestClusterScore = findBestClusterToMerge(SwapWordContextCounts.DUMMY_CLUSTER, 0, maxNumberOfClusters, swapWordContextCounts);
            double oldScore = computeMergeScore(SwapWordContextCounts.DUMMY_CLUSTER, 0.0, currCluster, swapWordContextCounts);
            if (bestClusterScore.getFirst() != currCluster && bestClusterScore.getSecond() > oldScore + 1e-10) {
                int newCluster = bestClusterScore.getFirst();
                UI.write("Iteration " + iteration + " assigning phrase " + phrase + " to cluster " + newCluster + " (was cluster " + currCluster + ")");
                phraseToClusterMap.put(phrase, newCluster);
                clusterContextCounts.removeCounts(contextCountsForPhrase.mapCluster(SwapWordContextCounts.DUMMY_CLUSTER, currCluster));
                clusterContextCounts.addCounts(contextCountsForPhrase.mapCluster(SwapWordContextCounts.DUMMY_CLUSTER, newCluster));
                if (DO_TESTS) {
                    ContextCountsUtils.checkCounts(clusterContextCounts, phraseToClusterMap, phraseContextCounts);
                    checkSwapScores(phraseToClusterMap, clusterContextCounts, phraseContextCounts, phrase, currCluster, bestClusterScore, oldScore, newCluster);
                }
                numOfPhrasesChangedInLastIteration++;
            }
        }
        iteration++;
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:34,代码来源:BrownClustering.java

示例12: readPhrases

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private Pair<Map<Integer, String>, Int2IntOpenHashMap> readPhrases() throws IOException {
    Map<String, Integer> rawPraseCounts = countPhrases();
    Map<Integer, String> phraseToIndexMap = assignWordsToIndexBasedOnFrequency(rawPraseCounts);
    Int2IntOpenHashMap phraseFrequencies = new Int2IntOpenHashMap(phraseToIndexMap.size());
    for (Map.Entry<Integer, String> entry : phraseToIndexMap.entrySet()) {
        phraseFrequencies.put(entry.getKey(), rawPraseCounts.get(entry.getValue()));
    }
    return new Pair<>(phraseToIndexMap, phraseFrequencies);
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:10,代码来源:BrownClustering.java

示例13: initializeClusters

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
private Int2IntOpenHashMap initializeClusters(int numberOfPhrases) {
    Int2IntOpenHashMap phraseToCluster = ContextCountsUtils.createNewInt2IntMap(numberOfPhrases);
    for (int i = 0; i < numberOfPhrases; i++) {
        phraseToCluster.put(i, i); //assign every word to its own cluster
    }
    return phraseToCluster;
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:8,代码来源:BrownClustering.java

示例14: computeMapTotals

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
public static Int2IntOpenHashMap computeMapTotals(Map<Integer, Int2IntOpenHashMap> countMaps) {
    Int2IntOpenHashMap totals = createNewInt2IntMap(countMaps.size());
    for (Map.Entry<Integer, Int2IntOpenHashMap> entry : countMaps.entrySet()) {
        int total = entry.getValue().values().stream().collect(Collectors.summingInt(i -> i));
        totals.put(entry.getKey().intValue(), total);
    }
    return totals;
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:9,代码来源:ContextCountsUtils.java

示例15: OnHeapIntDictionary

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入方法依赖的package包/类
/**
 * Constructor for the class.
 * Populates the value <-> mappings.
 *
 * @param dataBuffer Pinot data buffer
 * @param length Length of the dictionary
 */
public OnHeapIntDictionary(PinotDataBuffer dataBuffer, int length) {
  super(dataBuffer, length, V1Constants.Numbers.INTEGER_SIZE, (byte) 0);

  _valToDictId = new Int2IntOpenHashMap(length);
  _valToDictId.defaultReturnValue(-1);
  _dictIdToVal = new int[length];

  for (int dictId = 0; dictId < length; dictId++) {
    int value = getInt(dictId);
    _dictIdToVal[dictId] = value;
    _valToDictId.put(value, dictId);
  }
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:21,代码来源:OnHeapIntDictionary.java


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