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


Java Int2IntOpenHashMap类代码示例

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


Int2IntOpenHashMap类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了Int2IntOpenHashMap类的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: loadToIntMaps

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 * Load dense double model to int->int maps
 *
 * @param modelDir model save directory path
 * @return model data
 */
public static Int2IntOpenHashMap[] loadToIntMaps(String modelDir, Configuration conf)
    throws IOException {
  // Load model meta
  ModelFilesMeta meta = getMeta(modelDir, conf);

  // Check row type
  if (meta.getRowType() != SPARSE_INT) {
    throw new IOException("model row type is not sparse int, you should check it");
  }

  // Load model
  SparseIntModel model = new SparseIntModel(meta.getRow(), meta.getCol());
  loadModel(modelDir, model, meta, conf);

  return model.getModel();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:ModelLoader.java

示例3: convertSparseIntModel

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
private static void convertSparseIntModel(Configuration conf, FSDataOutputStream output,
  String modelInputDir, ModelLineConvert lineConvert) throws IOException {
  Int2IntOpenHashMap[] data = ModelLoader.loadToIntMaps(modelInputDir, conf);
  for(int i = 0; i < data.length; i++) {
    Int2IntOpenHashMap row = data[i];
    data[i] = null;
    if(row == null) {
      continue;
    }

    lineConvert.convertRowIndex(output, i);
    int [] indexes = row.keySet().toIntArray();
    int [] values = row.values().toIntArray();
    row = null;
    Sort.quickSort(indexes, values, 0, indexes.length - 1);
    for(int j = 0; j < indexes.length; j++) {
      lineConvert.convertFloat(output, indexes[j], values[j]);
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:21,代码来源:ModelMergeAndConvert.java

示例4: toString

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
private String toString(Int2IntOpenHashMap clocVec) {
  if(clocVec == null) {
    return "NULL";
  }

  StringBuilder sb = new StringBuilder();
  ObjectIterator<Int2IntMap.Entry> iter = clocVec.int2IntEntrySet().fastIterator();
  Int2IntMap.Entry item ;
  while(iter.hasNext()) {
    item = iter.next();
    sb.append(item.getIntKey());
    sb.append(":");
    sb.append(item.getIntValue());
    sb.append(";");
  }
  return sb.toString();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:RecoverPartRequest.java

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

示例6: setClockVec

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 * Set clock vector
 * @param clockVec clock vector
 */
public void setClockVec(Int2IntOpenHashMap clockVec) {
  try {
    lock.writeLock().lock();
    ObjectIterator<Int2IntMap.Entry> iter = clockVec.int2IntEntrySet().fastIterator();
    Int2IntMap.Entry item;
    while(iter.hasNext()) {
      item = iter.next();
      if(!taskIndexToClockMap.containsKey(item.getIntKey())
        || (taskIndexToClockMap.containsKey(item.getIntKey())
        && taskIndexToClockMap.get(item.getIntKey()) < item.getIntValue())) {
        taskIndexToClockMap.put(item.getIntKey(), item.getIntValue());
      }
    }
    refreshMinClock();
  } finally {
    lock.writeLock().unlock();
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:PartClockVector.java

示例7: adjustClocks

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 * 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());
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:25,代码来源:ClockVectorManager.java

示例8: getTaskMatrixClocks

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 * get clock of all matrices for all task
 * @param controller rpc controller of protobuf
 * @param request contains task id
 * @throws ServiceException
 */
@Override
public GetTaskMatrixClockResponse getTaskMatrixClocks(RpcController controller,
    GetTaskMatrixClockRequest request) throws ServiceException {
  AMTaskManager taskManager = context.getTaskManager();
  Collection<AMTask> tasks = taskManager.getTasks();
  GetTaskMatrixClockResponse.Builder builder = GetTaskMatrixClockResponse.newBuilder();
  TaskMatrixClock.Builder taskBuilder = TaskMatrixClock.newBuilder();
  MatrixClock.Builder matrixClockBuilder = MatrixClock.newBuilder();

  Int2IntOpenHashMap matrixClocks = null;
  for(AMTask task:tasks){
    taskBuilder.setTaskId(ProtobufUtil.convertToIdProto(task.getTaskId()));
    matrixClocks = task.getMatrixClocks();
    for(it.unimi.dsi.fastutil.ints.Int2IntMap.Entry entry:matrixClocks.int2IntEntrySet()) {
      taskBuilder.addMatrixClocks(matrixClockBuilder.setMatrixId(entry.getIntKey()).setClock(entry.getIntValue()).build());
    }
    builder.addTaskMatrixClocks(taskBuilder.build());
    taskBuilder.clear();
  }

  return builder.build();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:29,代码来源:MasterService.java

示例9: AMTask

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
public AMTask(TaskId id, AMTask amTask) {
  state = AMTaskState.NEW;
  taskId = id;
  metrics = new HashMap<String, String>();
  startTime = -1;
  finishTime = -1;

  matrixIdToClockMap = new Int2IntOpenHashMap();
  // if amTask is not null, we should clone task state from it
  if (amTask == null) {
    iteration = 0;
    progress = 0.0f;
  } else {
    iteration = amTask.getIteration();
    progress = amTask.getProgress();
    matrixIdToClockMap.putAll(amTask.matrixIdToClockMap);
  }

  ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
  readLock = readWriteLock.readLock();
  writeLock = readWriteLock.writeLock();
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:AMTask.java

示例10: testUpdateIntSparseToIntSparse

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
@Test
public void testUpdateIntSparseToIntSparse() throws Exception {
  ServerSparseIntRow serverSparseIntRow = new ServerSparseIntRow(rowId, startCol, endCol);
  ByteBuf buf = Unpooled.buffer(16);
  buf.writeInt(0);
  buf.writeInt(0);
  buf.writeInt(1);
  buf.writeInt(1);
  buf.writeInt(2);
  buf.writeInt(2);
  rowUpdater.updateIntSparseToIntSparse(3, buf, serverSparseIntRow);
  Int2IntOpenHashMap hashMap = new Int2IntOpenHashMap();
  hashMap.addTo(0, 0);
  hashMap.addTo(1, 1);
  hashMap.addTo(2, 2);
  assertEquals(serverSparseIntRow.getData(), hashMap);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:DefaultRowUpdaterTest.java

示例11: fillSeenPositions

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
private void fillSeenPositions(Collection<DexMethod> invokes) {
  for (DexMethod method : invokes) {
    DexType[] parameters = method.proto.parameters.values;
    int arity = parameters.length;
    int positions = computePositionsFor(method.proto, target, targetProtoCache, substituions);
    if (positions != 0) {
      Int2IntMap positionsMap =
          seenPositions.computeIfAbsent(method.name, k -> {
            Int2IntMap result = new Int2IntOpenHashMap();
            result.defaultReturnValue(NOT_FOUND);
            return result;
          });
      int value = 0;
      int previous = positionsMap.get(arity);
      if (previous != NOT_FOUND) {
        value = previous;
      }
      value |= positions;
      positionsMap.put(arity, value);
    }
  }

}
 
开发者ID:inferjay,项目名称:r8,代码行数:24,代码来源:SimpleClassMerger.java

示例12: countByCategory

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 */
public Table countByCategory() {
    Table t = new Table("Column: " + name());
    CategoryColumn categories = new CategoryColumn("Category");
    IntColumn counts = new IntColumn("Count");

    Int2IntMap valueToCount = new Int2IntOpenHashMap();
    for (int next : values) {
        if (valueToCount.containsKey(next)) {
            valueToCount.put(next, valueToCount.get(next) + 1);
        } else {
            valueToCount.put(next, 1);
        }
    }

    for (Map.Entry<Integer, Integer> entry : valueToCount.int2IntEntrySet()) {
        categories.add(lookupTable.get(entry.getKey()));
        counts.append(entry.getValue());
    }
    t.addColumn(categories);
    t.addColumn(counts);
    return t;
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:25,代码来源:CategoryColumn.java

示例13: LeftIndexedMultiSegmentBipartiteGraph

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
/**
 * This starts the graph off with a single segment, and additional ones are allocated as needed.
 *
 * @param maxNumSegments                 is the maximum number of segments we'll add to the graph.
 *                                       At that point, the oldest segments will start getting
 *                                       dropped
 * @param maxNumEdgesPerSegment          determines when the implementation decides to fork off a
 *                                       new segment
 * @param bipartiteGraphSegmentProvider  is used to generate new segments that are added to the
 *                                       graph
 * @param statsReceiver                  tracks the internal stats
 */
public LeftIndexedMultiSegmentBipartiteGraph(
    int maxNumSegments,
    int maxNumEdgesPerSegment,
    BipartiteGraphSegmentProvider<T> bipartiteGraphSegmentProvider,
    MultiSegmentReaderAccessibleInfoProvider<T> multiSegmentReaderAccessibleInfoProvider,
    StatsReceiver statsReceiver) {
  this.maxNumSegments = maxNumSegments;
  this.maxNumEdgesPerSegment = maxNumEdgesPerSegment;
  this.bipartiteGraphSegmentProvider = bipartiteGraphSegmentProvider;
  this.statsReceiver = statsReceiver.scope("LeftIndexedMultiSegmentBipartiteGraph");
  this.numEdgesSeenInAllHistoryCounter = this.statsReceiver.counter("numEdgesSeenInAllHistory");
  this.multiSegmentReaderAccessibleInfoProvider = multiSegmentReaderAccessibleInfoProvider;
  this.numEdgesInNonLiveSegmentsMap = new Int2IntOpenHashMap(maxNumSegments);
  addNewSegment();
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:28,代码来源:LeftIndexedMultiSegmentBipartiteGraph.java

示例14: getFasterIntersectionMap

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
private Int2IntMap getFasterIntersectionMap(int uidx) {
    Int2IntOpenHashMap intersectionMap = new Int2IntOpenHashMap();
    intersectionMap.defaultReturnValue(0);

    IntIterator iidxs = data.getUidxIidxs(uidx);
    while (iidxs.hasNext()) {
        IntIterator vidxs = data.getIidxUidxs(iidxs.nextInt());
        while (vidxs.hasNext()) {
            intersectionMap.addTo(vidxs.nextInt(), 1);
        }
    }

    intersectionMap.remove(uidx);

    return intersectionMap;
}
 
开发者ID:RankSys,项目名称:RankSys,代码行数:17,代码来源:SetSimilarity.java

示例15: addCounts

import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap; //导入依赖的package包/类
private void addCounts(Int2IntOpenHashMap phraseToClusterMap, Int2IntOpenHashMap phraseContextCounts, Map<Integer, Int2IntOpenHashMap> prevClusterCounts, Map<Integer, Int2IntOpenHashMap> nextClusterCounts, int phrase, boolean includeIdentityCounts, int newCluster) {
    Int2IntOpenHashMap phrasePrevClusterCounts = prevClusterCounts.get(newCluster);
    if (phrasePrevClusterCounts == null) {
        phrasePrevClusterCounts = ContextCountsUtils.createNewInt2IntMap();
        prevClusterCounts.put(newCluster, phrasePrevClusterCounts);
    }
    for (Int2IntOpenHashMap.Entry otherPhraseEntry : phraseContextCounts.int2IntEntrySet()) {
        int otherPhrase = otherPhraseEntry.getIntKey();
        if (phrase != otherPhrase || includeIdentityCounts) {
            int clusterOtherPhrase = otherPhrase == phrase ? newCluster : phraseToClusterMap.get(otherPhrase);
            phrasePrevClusterCounts.addTo(clusterOtherPhrase, otherPhraseEntry.getIntValue());
            Int2IntOpenHashMap otherPhraseNextCounts = nextClusterCounts.get(clusterOtherPhrase);
            if (otherPhraseNextCounts == null) {
                otherPhraseNextCounts = ContextCountsUtils.createNewInt2IntMap();
                nextClusterCounts.put(clusterOtherPhrase, otherPhraseNextCounts);
            }
            otherPhraseNextCounts.addTo(newCluster, otherPhraseEntry.getValue());
        }
    }
}
 
开发者ID:koendeschacht,项目名称:brown-cluster,代码行数:21,代码来源:BrownClustering.java


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