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


Java FSDataInputStream.readDouble方法代码示例

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


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

示例1: loadDenseDoublePartition

import org.apache.hadoop.fs.FSDataInputStream; //导入方法依赖的package包/类
private static void loadDenseDoublePartition(DenseDoubleModel model, FSDataInputStream input,
    ModelPartitionMeta partMeta) throws IOException {
  int rowNum = input.readInt();
  int startCol = (int) partMeta.getStartCol();
  int endCol = (int) partMeta.getEndCol();
  int rowId = 0;
  double[] row = null;
  for (int i = 0; i < rowNum; i++) {
    rowId = input.readInt();
    row = model.getRow(rowId);
    for (int j = startCol; j < endCol; j++) {
      row[j] = input.readDouble();
    }
  }
}
 
开发者ID:Tencent,项目名称:angel,代码行数:16,代码来源:ModelLoader.java

示例2: loadDenseDoubleRowFromPartition

import org.apache.hadoop.fs.FSDataInputStream; //导入方法依赖的package包/类
public static double[] loadDenseDoubleRowFromPartition(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 = (int) (partMeta.getEndCol() - partMeta.getStartCol());
  double[] row = new double[num];
  for (int i = 0; i < num; i++) {
    row[i] = input.readDouble();
  }
  return row;
}
 
开发者ID:Tencent,项目名称:angel,代码行数:14,代码来源:ModelLoader.java

示例3: reduce

import org.apache.hadoop.fs.FSDataInputStream; //导入方法依赖的package包/类
@Override
protected void reduce(LongWritable key, Iterable<Text> values, Context context) throws IOException, InterruptedException {

    int k = context.getConfiguration().getInt("k", -1);

    String fpath = context.getConfiguration().get("mpath");
    String datLoc = context.getConfiguration().get("datLoc", "od");
    String wd = context.getConfiguration().get(datLoc);
    Path file = new Path(wd, fpath);

    FileSystem fs = file.getFileSystem(new Configuration());
    FSDataInputStream ds = fs.open(file);
    long start = (key.get() - 1) * 8 * (k + 1);
    ds.seek(start + 8);

    double[] wi = new double[k];
    for (int counter = 0; counter < k; counter++) {
        wi[counter] = ds.readDouble();
    }

    ds.close();

    for (Text value : values) {
        String[] keyVal = value.toString().split("\\t");
        long j = Long.parseLong(keyVal[0]);
        double aij = Double.parseDouble(keyVal[1]);

        StringBuilder result = new StringBuilder();
        for (int cou = 0; cou < k; cou++) {
            result.append(aij * wi[cou]);
            if (cou < k) {
                result.append(",");
            }
        }
        context.write(new LongWritable(j), new Text(result.toString()));
    }
}
 
开发者ID:Romm17,项目名称:MRNMF,代码行数:38,代码来源:MM2.java


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