• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Long2DoubleOpenHashMap类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row1, ServerSparseDoubleLongKeyRow row2) {
  Long2DoubleOpenHashMap data1 = row1.getIndex2ValueMap();
  Long2DoubleOpenHashMap data2 = row2.getIndex2ValueMap();

  if (data1.defaultReturnValue() != data2.defaultReturnValue()) {
    return 0.0;
  }
  LongSet keys = data1.keySet();
  keys.addAll(data2.keySet());

  if (keys.size() != data1.keySet().size() || keys.size() != data2.keySet().size()) {
    return 0.0;
  }

  for (long key: keys) {
    if (Math.abs(data1.get(key) - data2.get(key)) > 1e-10) {
      return 0.0;
    }
  }
  return 1.0;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:23,代码来源:Equal.java


示例2: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row1, ServerSparseDoubleLongKeyRow row2) {
  long entireSize = row1.getEndCol() - row2.getStartCol();

  Long2DoubleOpenHashMap data1 = row1.getIndex2ValueMap();
  Long2DoubleOpenHashMap data2 = row2.getIndex2ValueMap();
  LongSet keys = data1.keySet();
  keys.addAll(data2.keySet());

  double sum = 0.0;
  for (long key: keys) {
    sum += data1.get(key) * data2.get(key);
  }
  sum += (entireSize - keys.size()) * data1.defaultReturnValue() * data2.defaultReturnValue();

  return sum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:Dot.java


示例3: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
  Zip2MapWithIndexFunc mapper = (Zip2MapWithIndexFunc) func;
  Long2DoubleOpenHashMap from1 = rows[0].getData();
  Long2DoubleOpenHashMap from2 = rows[1].getData();
  Long2DoubleOpenHashMap to = from1.clone();

  // TODO: a better way is needed to deal with defaultValue
  assert (from1.defaultReturnValue() == 0.0 && from2.defaultReturnValue() == 0.0);
  LongSet keySet = from1.keySet();
  keySet.addAll(from2.keySet());
  for (long key: keySet) {
    to.put(key, mapper.call((int)key, from1.get(key), from2.get(key)));
  }

  rows[2].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:Zip2MapWithIndex.java


示例4: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
  Zip2MapFunc mapper = (Zip2MapFunc) func;
  Long2DoubleOpenHashMap from1 = rows[0].getData();
  Long2DoubleOpenHashMap from2 = rows[1].getData();
  Long2DoubleOpenHashMap to = from1.clone();
  to.defaultReturnValue(mapper.call(from1.defaultReturnValue(), from2.defaultReturnValue()));

  LongSet keySet = from1.keySet();
  keySet.addAll(from2.keySet());

  for (long key: keySet) {
    to.put(key, mapper.call(from1.get(key), from2.get(key)));
  }

  rows[2].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:18,代码来源:Zip2Map.java


示例5: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
  Zip3MapWithIndexFunc mapper = (Zip3MapWithIndexFunc) func;
  Long2DoubleOpenHashMap from1 = rows[0].getData();
  Long2DoubleOpenHashMap from2 = rows[1].getData();
  Long2DoubleOpenHashMap from3 = rows[2].getData();
  Long2DoubleOpenHashMap to = from1.clone();

  // TODO: a better way is needed to deal with defaultValue
  assert (from1.defaultReturnValue() == 0.0 && from2.defaultReturnValue() == 0.0);
  LongSet keySet = from1.keySet();
  keySet.addAll(from2.keySet());
  for (long key: keySet) {
    to.put(key, mapper.call((int)key, from1.get(key), from2.get(key), from3.get(key)));
  }

  rows[2].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:Zip3MapWithIndex.java


示例6: doUpdate

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected void doUpdate(ServerSparseDoubleLongKeyRow[] rows, Serialize func) {
  Zip3MapFunc mapper = (Zip3MapFunc) func;
  Long2DoubleOpenHashMap from1 = rows[0].getData();
  Long2DoubleOpenHashMap from2 = rows[1].getData();
  Long2DoubleOpenHashMap from3 = rows[2].getData();
  Long2DoubleOpenHashMap to = from1.clone();
  to.defaultReturnValue(mapper
      .call(from1.defaultReturnValue(), from2.defaultReturnValue(), from3.defaultReturnValue()));

  LongSet keySet = from1.keySet();
  keySet.addAll(from2.keySet());

  for (long key: keySet) {
    to.put(key, mapper.call(from1.get(key), from2.get(key), from3.get(key)));
  }

  rows[2].setIndex2ValueMap(to);
}
 
开发者ID:Tencent,项目名称:angel,代码行数:20,代码来源:Zip3Map.java


示例7: loadSparseDoubleLongKeyPartition

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
private static void loadSparseDoubleLongKeyPartition(SparseDoubleLongKeyModel model,
    FSDataInputStream input, ModelPartitionMeta partMeta) throws IOException {
  int rowNum = input.readInt();
  int rowId = 0;
  int nnz = 0;
  int totalNNZ = 0;
  Long2DoubleOpenHashMap 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.readLong(), input.readDouble());
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:19,代码来源:ModelLoader.java


示例8: loadToDoubleLongKeyMaps

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

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

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

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


示例9: convertSparseDoubleLongKeyModel

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

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


示例10: verifyCandidates

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
  Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
  for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
    final long candidateID = e.getLongKey();
    if (Double.compare(e.getDoubleValue() + ps.get(candidateID), theta) < 0) // A[y] = dot(x, y'')
      continue; // l2 pruning
    Vector residual = residuals.get(candidateID);
    assert (residual != null);
    final double ds1 = e.getDoubleValue()
        + Math.min(v.maxValue() * residual.sumValues(), residual.maxValue() * v.sumValues());
    if (Double.compare(ds1, theta) < 0)
      continue; // dpscore, eq. (5)
    final double sz2 = e.getDoubleValue() + Math.min(v.maxValue() * residual.size(), residual.maxValue() * v.size());
    if (Double.compare(sz2, theta) < 0)
      continue; // dpscore, eq. (9)

    final long deltaT = v.timestamp() - candidateID;
    double score = e.getDoubleValue() + Vector.similarity(v, residual); // dot(x, y) = A[y] + dot(x, y')
    score *= forgettingFactor(lambda, deltaT); // apply forgetting factor
    numSimilarities++;
    if (Double.compare(score, theta) >= 0) // final check
      matches.put(candidateID, score);
  }
  numMatches += matches.size();
  return matches;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:27,代码来源:L2Index.java


示例11: verifyCandidates

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
private final Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
  Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
  for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
    final long candidateID = e.getLongKey();
    if (Double.compare(e.getDoubleValue() + ps.get(candidateID), theta) < 0) // A[y] = dot(x, y'')
      continue; // l2 pruning
    final Vector residual = residuals.get(candidateID);
    assert (residual != null);
    final double ds1 = e.getDoubleValue()
        + Math.min(v.maxValue() * residual.sumValues(), residual.maxValue() * v.sumValues());
    if (Double.compare(ds1, theta) < 0)
      continue; // dpscore, eq. (5)
    final double sz2 = e.getDoubleValue() + Math.min(v.maxValue() * residual.size(), residual.maxValue() * v.size());
    if (Double.compare(sz2, theta) < 0)
      continue; // dpscore, eq. (9)

    final long deltaT = v.timestamp() - candidateID;
    double score = e.getDoubleValue() + Vector.similarity(v, residual); // dot(x, y) = A[y] + dot(x, y')
    score *= forgettingFactor(lambda, deltaT); // apply forgetting factor
    numSimilarities++;
    if (Double.compare(score, theta) >= 0) // final check
      matches.put(candidateID, score);
  }
  numMatches += matches.size();
  return matches;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:27,代码来源:L2APIndex.java


示例12: verifyCandidates

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
private Long2DoubleOpenHashMap verifyCandidates(final Vector v, Long2DoubleOpenHashMap accumulator) {
  Long2DoubleOpenHashMap matches = new Long2DoubleOpenHashMap();
  for (Long2DoubleMap.Entry e : accumulator.long2DoubleEntrySet()) {
    long candidateID = e.getLongKey();
    Vector candidateResidual = residuals.get(candidateID);
    assert (candidateResidual != null);
    double score = e.getDoubleValue() + Vector.similarity(v, candidateResidual); // A[y] + dot(y',x)
    long deltaT = v.timestamp() - candidateID;
    score *= Commons.forgettingFactor(lambda, deltaT); // apply forgetting factor
    numSimilarities++;
    if (Double.compare(score, theta) >= 0) // final check
      matches.put(candidateID, score);
  }
  numMatches += matches.size();
  return matches;
}
 
开发者ID:gdfm,项目名称:sssj,代码行数:17,代码来源:APIndex.java


示例13: LongDoubleMessageStore

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
/**
 * Constructor
 *
 * @param service Service worker
 * @param combiner Message combiner
 */
public LongDoubleMessageStore(
    CentralizedServiceWorker<LongWritable, ?, ?> service,
    Combiner<LongWritable, DoubleWritable> combiner) {
  this.service = service;
  this.combiner = combiner;

  map = new Int2ObjectOpenHashMap<Long2DoubleOpenHashMap>();
  for (int partitionId : service.getPartitionStore().getPartitionIds()) {
    Partition<LongWritable, ?, ?> partition =
        service.getPartitionStore().getPartition(partitionId);
    Long2DoubleOpenHashMap partitionMap =
        new Long2DoubleOpenHashMap((int) partition.getVertexCount());
    map.put(partitionId, partitionMap);
  }
}
 
开发者ID:renato2099,项目名称:giraph-gora,代码行数:22,代码来源:LongDoubleMessageStore.java


示例14: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  long entireSize = row.getEndCol() - row.getStartCol();

  double qSum = 0.0;
  Long2DoubleOpenHashMap data = row.getIndex2ValueMap();
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    qSum += Math.pow(entry.getValue(), 2);
  }
  qSum += Math.pow(data.defaultReturnValue(), 2) * (entireSize - data.size());
  return qSum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:Nrm2.java


示例15: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  long entireSize = row.getEndCol() - row.getStartCol();

  Long2DoubleOpenHashMap data = row.getData();
  double asum = 0.0;
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    asum += entry.getValue();
  }
  asum += data.defaultReturnValue() * (entireSize - data.size());
  return asum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:Sum.java


示例16: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  Long2DoubleOpenHashMap data = row.getIndex2ValueMap();

  double amin = data.defaultReturnValue();
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    amin = Math.min(amin, entry.getValue());
  }
  return amin;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Min.java


示例17: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  Long2DoubleOpenHashMap data = row.getIndex2ValueMap();

  double amin = Math.abs(data.defaultReturnValue());
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    amin = Math.min(amin, Math.abs(entry.getValue()));
  }
  return amin;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Amin.java


示例18: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  Long2DoubleOpenHashMap data = row.getIndex2ValueMap();

  double amax = Math.abs(data.defaultReturnValue());
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    amax = Math.max(amax, Math.abs(entry.getValue()));
  }
  return amax;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Amax.java


示例19: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  Long2DoubleOpenHashMap data = row.getIndex2ValueMap();

  double amax = data.defaultReturnValue();
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    amax = Math.max(amax, entry.getValue());
  }
  return amax;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:11,代码来源:Max.java


示例20: doProcessRow

import it.unimi.dsi.fastutil.longs.Long2DoubleOpenHashMap; //导入依赖的package包/类
@Override
protected double doProcessRow(ServerSparseDoubleLongKeyRow row) {
  long entireSize = row.getEndCol() - row.getStartCol();

  Long2DoubleOpenHashMap data = row.getData();
  double asum = 0.0;
  for (Map.Entry<Long, Double> entry: data.long2DoubleEntrySet()) {
    asum += Math.abs(entry.getValue());
  }
  asum += Math.abs(data.defaultReturnValue()) * (entireSize - data.size());
  return asum;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:13,代码来源:Asum.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java StackImpl类代码示例发布时间:2022-05-22
下一篇:
Java ModelWitch类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap