use of water.rapids.Val in project h2o-3 by h2oai.
the class AstTmpAssign method apply.
@Override
public ValFrame apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
// Note: non-standard evaluation of the first argument! Instead of being
// executed, it is stringified. This, for example, allows us to write an
// expression as
// (tmp= newid (* frame 3))
// instead of
// (tmp= "newid" (* frame 3))
// On the other hand, this makes us unable to create dynamic identifiers
// in Rapids, for example this is invalid:
// (tmp= (+ "id" 3) (* frame 3))
// Right now there is no need for dynamically generated identifiers, since
// we don't even have proper variables or loops or control structures yet.
//
Key<Frame> id = Key.make(env.expand(asts[1].str()));
Val srcVal = stk.track(asts[2].exec(env));
Frame srcFrame = srcVal.getFrame();
Value v = DKV.get(id);
if (v != null) {
if (v.get().equals(srcFrame))
return (ValFrame) srcVal;
else
throw new IllegalArgumentException("Temp ID " + id + " already exists");
}
Frame dst = new Frame(id, srcFrame._names, srcFrame.vecs());
// Track new session-wide ID
return new ValFrame(env._ses.track_tmp(dst));
}
Aggregations