Search in sources :

Example 1 with H2OIllegalValueException

use of water.exceptions.H2OIllegalValueException in project h2o-3 by h2oai.

the class ParseSetupV3 method fillImpl.

@Override
public ParseSetup fillImpl(ParseSetup impl) {
    ParseSetup parseSetup = fillImpl(impl, new String[] { "parse_type" });
    // Transform the field parse_type
    ParserInfo pi = GUESS_INFO;
    if (this.parse_type != null) {
        ParserProvider pp = ParserService.INSTANCE.getByName(this.parse_type);
        if (pp != null) {
            pi = pp.info();
        } else
            throw new H2OIllegalValueException("Cannot find right parser for specified parser type!", this.parse_type);
    }
    parseSetup.setParseType(pi);
    return parseSetup;
}
Also used : ParseSetup(water.parser.ParseSetup) ParserInfo(water.parser.ParserInfo) ParserProvider(water.parser.ParserProvider) H2OIllegalValueException(water.exceptions.H2OIllegalValueException)

Example 2 with H2OIllegalValueException

use of water.exceptions.H2OIllegalValueException in project h2o-3 by h2oai.

the class VecUtils method numericToStringVec.

/**
   * Create a new {@link Vec} of string values from a numeric {@link Vec}.
   *
   * Currently only uses a default pretty printer. Would be better if
   * it accepted a format string PUBDEV-2211
   *
   * @param src a numeric {@link Vec}
   * @return a string {@link Vec}
   */
public static Vec numericToStringVec(Vec src) {
    if (src.isCategorical() || src.isUUID())
        throw new H2OIllegalValueException("Cannot convert a non-numeric column" + " using numericToStringVec() ", src);
    Vec res = new MRTask() {

        @Override
        public void map(Chunk chk, NewChunk newChk) {
            if (chk instanceof C0DChunk) {
                // all NAs
                for (int i = 0; i < chk._len; i++) newChk.addNA();
            } else {
                for (int i = 0; i < chk._len; i++) {
                    if (!chk.isNA(i))
                        newChk.addStr(PrettyPrint.number(chk, chk.atd(i), 4));
                    else
                        newChk.addNA();
                }
            }
        }
    }.doAll(Vec.T_STR, src).outputFrame().anyVec();
    assert res != null;
    return res;
}
Also used : C0DChunk(water.fvec.C0DChunk) Vec(water.fvec.Vec) Chunk(water.fvec.Chunk) NewChunk(water.fvec.NewChunk) C0DChunk(water.fvec.C0DChunk) H2OIllegalValueException(water.exceptions.H2OIllegalValueException) NewChunk(water.fvec.NewChunk)

Aggregations

H2OIllegalValueException (water.exceptions.H2OIllegalValueException)2 C0DChunk (water.fvec.C0DChunk)1 Chunk (water.fvec.Chunk)1 NewChunk (water.fvec.NewChunk)1 Vec (water.fvec.Vec)1 ParseSetup (water.parser.ParseSetup)1 ParserInfo (water.parser.ParserInfo)1 ParserProvider (water.parser.ParserProvider)1