Package water.fvec

Examples of water.fvec.Vec$Writer


    // chks.length == A.numCols()
    new MRTask() {
      public void map(Chunk chks[]) {
        int chunkSize = chks[0].len();
        long start = chks[0].start();
        Vec A_vecs[] = A.vecs();
        long A_rows = A.numRows();

        for (int c = 0; c < chks.length; c++) {
          for (int r = 0; r < chunkSize; r++) {
            double v = 0;
View Full Code Here


   * @return new DRM constructed from mapped blocks of drmA through bmf.
   */
  public static <K,R> H2ODrm exec(H2ODrm drmA, int ncol, Object bmf, final boolean isRstr,
                                  final ClassTag<K> k, final ClassTag<R> r) {
    Frame A = drmA.frame;
    Vec keys = drmA.keys;

    /**
     * MRTask to execute bmf on partitions. Partitions are
     * made accessible to bmf in the form of H2OBlockMatrix.
     */
    class MRTaskBMF extends MRTask<MRTaskBMF> {
      Serializable bmf;
      Vec labels;
      MRTaskBMF(Object _bmf, Vec _labels) {
        // BlockMapFun does not implement Serializable,
        // but Scala closures are _always_ Serializable.
        //
        // So receive the object as a plain Object (else
        // compilation fails) and typcast it with conviction,
        // that Scala always tags the actually generated
        // closure functions with Serializable.
        bmf = (Serializable)_bmf;
        labels = _labels;
      }

      /** Create H2OBlockMatrix from the partition */
      private Matrix blockify(Chunk chks[]) {
        return new H2OBlockMatrix(chks);
      }

      /** Ingest the output of bmf into the output partition */
      private void deblockify(Matrix out, NewChunk ncs[]) {
        // assert (out.colSize() == ncs.length)
        for (int c = 0; c < out.columnSize(); c++) {
          for (int r = 0; r < out.rowSize(); r++) {
            ncs[c].addNum(out.getQuick(r, c));
          }
        }
      }

      // Input:
      // chks.length == A.numCols()
      //
      // Output:
      // ncs.length == (A.numCols() + 1) if String keyed
      //             (A.numCols() + 0) if Int or Long keyed
      //
      // First A.numCols() ncs[] elements are fed back the output
      // of bmf() output's _2 in deblockify()
      //
      // If String keyed, then MapBlockHelper.exec() would have
      // filled in the Strings into ncs[ncol] already
      //
      public void map(Chunk chks[], NewChunk ncs[]) {
        long start = chks[0].start();
        NewChunk nclabel = isRstr ? ncs[ncs.length - 1] : null;
        deblockify(MapBlockHelper.exec(bmf, blockify(chks), start, labels, nclabel, k, r), ncs);
        // assert chks[i]._len == ncs[j]._len
      }
    }

    int ncolRes = ncol + (isRstr ? 1 : 0);
    Frame fmap = new MRTaskBMF(bmf, keys).doAll(ncolRes, A).outputFrame(null, null);
    Vec vmap = null;
    if (isRstr) {
      // If output was String keyed, then the last Vec in fmap is the String vec.
      // If so, peel it out into a separate Vec (vmap) and set fmap to be the
      // Frame with just the first ncol Vecs
      vmap = fmap.vecs()[ncol];
View Full Code Here

   * @return Time in nanoseconds that it took
   */
  private static double send_recv_collective(int msg_size, int repeats) {
    byte[] payload = new byte[msg_size];
    new Random().nextBytes(payload);
    Vec v = Vec.makeConSeq(0., 1); //trivial Vec: 1 element with value 0.

    Timer t = new Timer();
    for (int l = 0; l < repeats; ++l) {
      new CollectiveTask(payload).doAll(v); //same payload for all nodes
    }
    v.remove(new Futures()).blockForPending();
    return (double) t.nanos() / repeats;
  }
View Full Code Here

TOP

Related Classes of water.fvec.Vec$Writer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.