use of water.rapids.vals.ValStr in project h2o-3 by h2oai.
the class AstFlatten method apply.
@Override
public Val apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
// did not flatten
if (fr.numCols() != 1 || fr.numRows() != 1)
return new ValFrame(fr);
Vec vec = fr.anyVec();
switch(vec.get_type()) {
case Vec.T_BAD:
case Vec.T_NUM:
return new ValNum(vec.at(0));
case Vec.T_TIME:
// check for missing values
return vec.isNA(0) ? new ValNum(Double.NaN) : new ValNum(vec.at8(0));
case Vec.T_STR:
return new ValStr(vec.atStr(new BufferedString(), 0).toString());
case // check for missing values
Vec.T_CAT:
return vec.isNA(0) ? new ValStr("NA") : new ValStr(vec.factor(vec.at8(0)));
default:
throw H2O.unimpl("The type of vector: " + vec.get_type_str() + " is not supported by " + str());
}
}