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);
}
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);
}
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);
}
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;
}
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 }));
}
Aggregations