public Vec replace(int col, Vec nv) { assert col < _names.length; Vec rv = vecs()[col]; assert rv.group().equals(nv.group()); _vecs[col] = nv; _keys[col] = nv._key; if (DKV.get(nv._key) == null) // If not already in KV, put it there DKV.put(nv._key, nv); return rv; }
/** Appends a named column, keeping the last Vec as the response */ public void add(String name, Vec vec) { assert _vecs.length == 0 || anyVec().group().equals(vec.group()); final int len = _names.length; _names = Arrays.copyOf(_names, len + 1); _vecs = Arrays.copyOf(_vecs, len + 1); _keys = Arrays.copyOf(_keys, len + 1); _names[len] = name; _vecs[len] = vec; _keys[len] = vec._key; }
public Frame(String[] names, Vec[] vecs) { // assert names==null || names.length == vecs.length : "Number of columns does not match to // number of cols' names."; _names = names; _vecs = vecs; _keys = new Key[vecs.length]; for (int i = 0; i < vecs.length; i++) { Key k = _keys[i] = vecs[i]._key; if (DKV.get(k) == null) // If not already in KV, put it there DKV.put(k, vecs[i]); } Vec v0 = anyVec(); if (v0 == null) return; VectorGroup grp = v0.group(); for (int i = 0; i < vecs.length; i++) assert grp.equals(vecs[i].group()); }