Search in sources :

Example 6 with Futures

use of water.Futures in project h2o-2 by h2oai.

the class SparseTest method setAndClose.

protected Chunk setAndClose(double[] vals, int[] ids, Chunk c) {
    final int cidx = c.cidx();
    final Vec vec = c._vec;
    for (int i = 0; i < vals.length; ++i) c.set0(ids[i], vals[i]);
    Futures fs = new Futures();
    c.close(cidx, fs);
    return vec.chunkForChunkIdx(cidx);
}
Also used : Futures(water.Futures)

Example 7 with Futures

use of water.Futures in project h2o-2 by h2oai.

the class MatrixMultiply method serve.

@Override
protected Response serve() {
    Key jk = Key.make(after + "_job");
    Futures fs = new Futures();
    if (skip_first_col && x.numCols() == (y.numRows() + 1)) {
        // hack to remove columns added during smvlight conversion
        x.remove(0).remove(fs);
        y.remove(0).remove(fs);
    }
    new DMatrix.MatrixMulJob(jk, after, x, y).fork();
    return Response.redirect(this, "/2/Inspector", "src_key", after);
}
Also used : Futures(water.Futures) Key(water.Key) DMatrix(hex.la.DMatrix)

Example 8 with Futures

use of water.Futures in project h2o-2 by h2oai.

the class FrameUtils method frame.

/**
   * Create a new frame based on given row data.
   * @param names  names of frame columns
   * @param rows  data given in the form of rows
   * @return new frame which contains columns named according given names and including given data
   */
public static Frame frame(String[] names, double[]... rows) {
    assert names == null || names.length == rows[0].length;
    Futures fs = new Futures();
    Vec[] vecs = new Vec[rows[0].length];
    Key[] keys = Vec.VectorGroup.VG_LEN1.addVecs(vecs.length);
    for (int c = 0; c < vecs.length; c++) {
        AppendableVec vec = new AppendableVec(keys[c]);
        NewChunk chunk = new NewChunk(vec, 0);
        for (int r = 0; r < rows.length; r++) chunk.addNum(rows[r][c]);
        chunk.close(0, fs);
        vecs[c] = vec.close(fs);
    }
    fs.blockForPending();
    return new Frame(names, vecs);
}
Also used : Futures(water.Futures) Key(water.Key)

Example 9 with Futures

use of water.Futures in project h2o-3 by h2oai.

the class Session method end.

/**
   * Normal session exit.  Returned Frames are fully deep-copied, and are responsibility of the caller to delete.
   * Returned Frames have their refcnts currently up by 1 (for the returned value itself).
   */
public Val end(Val returning) {
    sanity_check_refs(returning);
    // Remove all temp frames
    Futures fs = new Futures();
    for (Frame fr : FRAMES.values()) {
        // Remove internal Vecs one by one
        fs = downRefCnt(fr, fs);
        // Shallow remove, internal Vecs removed 1-by-1
        DKV.remove(fr._key, fs);
    }
    fs.blockForPending();
    // No more temp frames
    FRAMES.clear();
    // (disappearing) session.
    if (returning != null && returning.isFrame()) {
        Frame fr = returning.getFrame();
        Vec[] vecs = fr.vecs();
        for (int i = 0; i < vecs.length; i++) {
            // Returning frame has refcnt +1, lower it now; should go to zero internal refcnts.
            _addRefCnt(vecs[i], -1);
            if (// Copy if shared with globals
            GLOBALS.contains(vecs[i]))
                fr.replace(i, vecs[i].makeCopy());
        }
    }
    // No longer tracking globals
    GLOBALS.clear();
    sanity_check_refs(null);
    REFCNTS.clear();
    return returning;
}
Also used : Frame(water.fvec.Frame) Futures(water.Futures) Vec(water.fvec.Vec)

Example 10 with Futures

use of water.Futures in project h2o-3 by h2oai.

the class AstLs method apply.

@Override
public ValFrame apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
    ArrayList<String> domain = new ArrayList<>();
    Futures fs = new Futures();
    AppendableVec av = new AppendableVec(Vec.VectorGroup.VG_LEN1.addVec(), Vec.T_CAT);
    NewChunk keys = new NewChunk(av, 0);
    int r = 0;
    for (Key key : KeySnapshot.globalSnapshot().keys()) {
        keys.addCategorical(r++);
        domain.add(key.toString());
    }
    String[] key_domain = domain.toArray(new String[domain.size()]);
    av.setDomain(key_domain);
    keys.close(fs);
    // c0 is the row index vec
    Vec c0 = av.layout_and_close(fs);
    fs.blockForPending();
    return new ValFrame(new Frame(Key.<Frame>make("h2o_ls"), new String[] { "key" }, new Vec[] { c0 }));
}
Also used : ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Futures(water.Futures) Vec(water.fvec.Vec) AppendableVec(water.fvec.AppendableVec) ArrayList(java.util.ArrayList) AppendableVec(water.fvec.AppendableVec) Key(water.Key) NewChunk(water.fvec.NewChunk)

Aggregations

Futures (water.Futures)34 Vec (water.fvec.Vec)11 Key (water.Key)10 Frame (water.fvec.Frame)7 AppendableVec (water.fvec.AppendableVec)4 NewChunk (water.fvec.NewChunk)4 ValFrame (water.rapids.vals.ValFrame)4 ArrayList (java.util.ArrayList)2 Random (java.util.Random)2 Test (org.junit.Test)2 MRTask (water.MRTask)2 DataInfo (hex.FrameTask.DataInfo)1 DMatrix (hex.la.DMatrix)1 File (java.io.File)1 IOException (java.io.IOException)1 Job (water.Job)1 FrameKeyV3 (water.api.schemas3.KeyV3.FrameKeyV3)1 ByteVec (water.fvec.ByteVec)1 NFSFileVec (water.fvec.NFSFileVec)1 BufferedString (water.parser.BufferedString)1