Search in sources :

Example 76 with Val

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));
}
Also used : Val(water.rapids.Val) ValFrame(water.rapids.vals.ValFrame) ValFrame(water.rapids.vals.ValFrame) Frame(water.fvec.Frame) Value(water.Value)

Aggregations

Val (water.rapids.Val)76 Frame (water.fvec.Frame)65 Test (org.junit.Test)56 ValFrame (water.rapids.vals.ValFrame)52 Vec (water.fvec.Vec)14 ValRow (water.rapids.vals.ValRow)8 MRTask (water.MRTask)5 Session (water.rapids.Session)5 Chunk (water.fvec.Chunk)4 TestFrameBuilder (water.fvec.TestFrameBuilder)4 ValNum (water.rapids.vals.ValNum)4 NewChunk (water.fvec.NewChunk)2 AstParameter (water.rapids.ast.AstParameter)2 AstNumList (water.rapids.ast.params.AstNumList)2 CreateFrame (hex.CreateFrame)1 GLRMParameters (hex.glrm.GLRMModel.GLRMParameters)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1