當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。