All Downloads are FREE. Search and download functionalities are using the official Maven repository.

water.fvec.TransformWrappedVec Maven / Gradle / Ivy

There is a newer version: 3.8.2.9
Show newest version
package water.fvec;

import water.DKV;
import water.H2O;
import water.Key;
import water.rapids.AST;
import water.rapids.Env;

import static water.rapids.ASTParameter.makeNum;

/**
 * This wrapper pushes a transform down into each chunk so that
 * transformations will happen on-the-fly. When wrapped and there
 * are Op instances to be applied, the atd call will supersede the
 * usual chunk-at retrieval with a "special" atd call.
 *
 * Overhead added per element fetch per chunk is another virtual call
 * per Op per element (per Chunk). As has been noted (see e.g. RollupStats),
 * virtual calls are expensive, but the memory savings are substantial.
 *
 * AutoML can freely transform columns without ramification.
 *
 * Each wrapped Vec will track its own transformations, which makes it easy
 * when generating a POJO.
 *
 * A TransformWrappedVec is actually a function of one or more Vec instances.
 *
 * This class exists here so that Chunk and NewChunk don't need to become fully public
 * (since java has no friends). Other packages (not just core H2O) depend on this class!
 *
 *
 * @author spencer
 */
public class TransformWrappedVec extends WrappedVec {

  private final Key[] _masterVecKeys;
  private transient Vec[] _masterVecs;
  private final AST _fun;

  public TransformWrappedVec(Key key, int rowLayout, AST fun, Key... masterVecKeys) {
    super(key, rowLayout, null);
    _fun=fun;
    _masterVecKeys = masterVecKeys;
    DKV.put(this);
  }

  public TransformWrappedVec(Vec v, AST fun) {
    this(v.group().addVec(), v._rowLayout, fun, v._key);
  }



  @Override public Chunk chunkForChunkIdx(int cidx) {
    Chunk[] cs = new Chunk[_masterVecKeys.length];
    if( _masterVecs==null )
      _masterVecs = new Vec[_masterVecKeys.length];
    for(int i=0; i




© 2015 - 2025 Weber Informatics LLC | Privacy Policy