use of water.exceptions.H2OCategoricalLevelNotFoundArgumentException in project h2o-3 by h2oai.
the class FindHandler method find.
// called through reflection by RequestServer
@SuppressWarnings("unused")
public FindV3 find(int version, FindV3 find) {
Frame frame = find.key._fr;
// Peel out an optional column; restrict to this column
if (find.column != null) {
Vec vec = frame.vec(find.column);
if (vec == null)
throw new H2OColumnNotFoundArgumentException("column", frame, find.column);
find.key = new FrameV3(new Frame(new String[] { find.column }, new Vec[] { vec }));
}
// Convert the search string into a column-specific flavor
Vec[] vecs = frame.vecs();
double[] ds = new double[vecs.length];
for (int i = 0; i < vecs.length; i++) {
if (vecs[i].isCategorical()) {
int idx = ArrayUtils.find(vecs[i].domain(), find.match);
if (idx == -1 && vecs.length == 1)
throw new H2OCategoricalLevelNotFoundArgumentException("match", find.match, frame._key.toString(), frame.name(i));
ds[i] = idx;
} else if (vecs[i].isUUID()) {
throw H2O.unimpl();
} else if (vecs[i].isString()) {
throw H2O.unimpl();
} else if (vecs[i].isTime()) {
throw H2O.unimpl();
} else {
try {
ds[i] = find.match == null ? Double.NaN : Double.parseDouble(find.match);
} catch (NumberFormatException e) {
if (vecs.length == 1) {
// There's only one Vec and it's a numeric Vec and our search string isn't a number
IcedHashMapGeneric.IcedHashMapStringObject values = new IcedHashMapGeneric.IcedHashMapStringObject();
String msg = "Frame: " + frame._key.toString() + " as only one column, it is numeric, and the find pattern is not numeric: " + find.match;
values.put("frame_name", frame._key.toString());
values.put("column_name", frame.name(i));
values.put("pattern", find.match);
throw new H2OIllegalArgumentException(msg, msg, values);
}
// Do not match
ds[i] = Double.longBitsToDouble(0xcafebabe);
}
}
}
Find f = new Find(find.row, ds).doAll(frame);
find.prev = f._prev;
find.next = f._next == Long.MAX_VALUE ? -1 : f._next;
return find;
}
Aggregations