Package water.fvec

Examples of water.fvec.Frame$CSVStream


   * @param drmA DRM representing matrix A
   * @param drmB DRM representing matrix B
   * @return new DRM containing AB'
   */
  public static H2ODrm exec(H2ODrm drmA, H2ODrm drmB) {
    Frame A = drmA.frame;
    Vec keys = drmA.keys;
    final Frame B = drmB.frame;
    int ABt_cols = (int)B.numRows();

    // ABt is written into ncs[] with an MRTask on A, and therefore will
    // be similarly partitioned as A.
    //
    // chks.length == A.numCols() (== B.numCols())
    // ncs.length == ABt_cols (B.numRows())
    Frame ABt = new MRTask() {
        public void map(Chunk chks[], NewChunk ncs[]) {
          int chunkSize = chks[0].len();
          Vec B_vecs[] = B.vecs();

          for (int c = 0; c < ncs.length; c++) {
View Full Code Here


   * @param drmA DRM representing matrix A.
   * @param drmB DRM representing matrix B.
   * @return new DRM containing A'B.
   */
  public static H2ODrm exec(H2ODrm drmA, H2ODrm drmB) {
    final Frame A = drmA.frame;
    final Frame B = drmB.frame;

    // First create an empty frame of the required dimensions
    Frame AtB = H2OHelper.emptyFrame(A.numCols(), B.numCols(), -1, -1);

    // Execute MRTask on the new Frame, and fill each cell (initially 0) by
    // computing appropriate values from A and B.
    //
    // chks.length == B.numCols()
View Full Code Here

   *
   * @param drmA DRM representing matrix A.
   * @return new DRM containing A'A.
   */
public static H2ODrm exec(H2ODrm drmA) {
    final Frame A = drmA.frame;
    // First create an empty Frame of the required dimensions
    Frame AtA = H2OHelper.emptyFrame(A.numCols(), A.numCols(), -1, -1);

    // Execute MRTask on the new Frame, and fill each cell (initially 0) by
    // computing appropriate values from A.
    //
    // chks.length == A.numCols()
View Full Code Here

   * @param r ClassTag of output DRM key type.
   * @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];
      fmap = new Frame(Arrays.copyOfRange(fmap.vecs(), 0, ncol));
    }
    return new H2ODrm(fmap, vmap);
  }
View Full Code Here

    try {
      env = water.cascade.Exec.exec(cascade._ast);
      StringBuilder sb = env._sb;
      if( sb.length()!=0 ) sb.append("\n");
      if (env.isAry()) {
        Frame fr = env.popAry();
        cascade._key = fr._key;
        cascade._num_rows = fr.numRows();
        cascade._num_cols = fr.numCols();
        cascade._col_names = fr.names();
        cascade._string = null;
        //TODO: colSummary  cols = new Inspect2.ColSummary[num_cols];
      } else if (env.isNum()) {
        cascade._scalar = env.popDbl();
        sb.append(Double.toString(cascade._scalar));
View Full Code Here

TOP

Related Classes of water.fvec.Frame$CSVStream

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.