当前位置: 首页>>代码示例>>Java>>正文


Java NewChunk.close方法代码示例

本文整理汇总了Java中water.fvec.NewChunk.close方法的典型用法代码示例。如果您正苦于以下问题:Java NewChunk.close方法的具体用法?Java NewChunk.close怎么用?Java NewChunk.close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在water.fvec.NewChunk的用法示例。


在下文中一共展示了NewChunk.close方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: apply

import water.fvec.NewChunk; //导入方法依赖的package包/类
@Override Val apply( Env env, Env.StackHelp stk, AST asts[] ) {
  ArrayList<String> domain = new ArrayList<>();
  Futures fs = new Futures();
  AppendableVec av = new AppendableVec(Vec.VectorGroup.VG_LEN1.addVec(),Vec.T_CAT);
  NewChunk keys = new NewChunk(av,0);
  int r = 0;
  for( Key key : KeySnapshot.globalSnapshot().keys()) {
    keys.addCategorical(r++);
    domain.add(key.toString());
  }
  String[] key_domain = domain.toArray(new String[domain.size()]);
  av.setDomain(key_domain);
  keys.close(fs);
  Vec c0 = av.layout_and_close(fs);   // c0 is the row index vec
  fs.blockForPending();
  return new ValFrame(new Frame(Key.make("h2o_ls"), new String[]{"key"}, new Vec[]{c0}));
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:18,代码来源:ASTLs.java

示例2: apply

import water.fvec.NewChunk; //导入方法依赖的package包/类
@Override
public ValFrame apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
  double from = asts[1].exec(env).getNum();
  double to = asts[2].exec(env).getNum();
  double by = asts[3].exec(env).getNum();
  double delta = to - from;
  if (delta == 0 && to == 0)
    throw new IllegalArgumentException("Expected `to` and `from` to have nonzero difference.");
  else {
    double n = delta / by;
    if (n < 0) throw new IllegalArgumentException("wrong sign in 'by' argument");
    else if (n > Double.MAX_VALUE) throw new IllegalArgumentException("'by' argument is much too small");
    Futures fs = new Futures();
    AppendableVec av = new AppendableVec(Vec.newKey(), Vec.T_NUM);
    NewChunk nc = new NewChunk(av, 0);
    int len = (int) n + 1;
    for (int r = 0; r < len; r++) nc.addNum(from + r * by);
    // May need to adjust values = by > 0 ? min(values, to) : max(values, to)
    nc.close(0, fs);
    Vec vec = av.layout_and_close(fs);
    fs.blockForPending();
    return new ValFrame(new Frame(vec));
  }
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:25,代码来源:AstSeq.java

示例3: apply

import water.fvec.NewChunk; //导入方法依赖的package包/类
@Override
public ValFrame apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
  ArrayList<String> domain = new ArrayList<>();
  Futures fs = new Futures();
  AppendableVec av = new AppendableVec(Vec.VectorGroup.VG_LEN1.addVec(), Vec.T_CAT);
  NewChunk keys = new NewChunk(av, 0);
  int r = 0;
  for (Key key : KeySnapshot.globalSnapshot().keys()) {
    keys.addCategorical(r++);
    domain.add(key.toString());
  }
  String[] key_domain = domain.toArray(new String[domain.size()]);
  av.setDomain(key_domain);
  keys.close(fs);
  Vec c0 = av.layout_and_close(fs);   // c0 is the row index vec
  fs.blockForPending();
  return new ValFrame(new Frame(Key.<Frame>make("h2o_ls"), new String[]{"key"}, new Vec[]{c0}));
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:19,代码来源:AstLs.java

示例4: buildFrame

import water.fvec.NewChunk; //导入方法依赖的package包/类
private void buildFrame() {
  Futures fs = new Futures();
  Vec[] vecs = new Vec[2];
  Key keys[] = Vec.VectorGroup.VG_LEN1.addVecs(2);

  //allocate
  AppendableVec wordAV = new AppendableVec((keys[0]), Vec.T_STR);
  AppendableVec  cntAV = new AppendableVec((keys[1]), Vec.T_NUM);
  NewChunk wordNC = new NewChunk(wordAV, 0);
  NewChunk cntNC = new NewChunk(cntAV, 0);

  //fill in values
  for (BufferedStringCount str : _vocabArray) {
    wordNC.addStr(str);
    cntNC.addNum(str._cnt, 0);
  }

  //finalize vectors
  wordNC.close(0, fs);
  cntNC.close(0, fs);
  vecs[0] = wordAV.layout_and_close(fs);
  vecs[1] = cntAV.layout_and_close(fs);
  fs.blockForPending();

  if(_fr != null && _fr._key != null) _wordCountKey = Key.make("wca_"+_fr._key.toString());
  else _wordCountKey = Key.make("wca");
  String[] names = {"Word", "Count"};
  DKV.put(_wordCountKey, new Frame(_wordCountKey, names, vecs));
}
 
开发者ID:kyoren,项目名称:https-github.com-h2oai-h2o-3,代码行数:30,代码来源:WordCountTask.java

示例5: apply

import water.fvec.NewChunk; //导入方法依赖的package包/类
@Override
public ValFrame apply(Env env, Env.StackHelp stk, AstRoot asts[]) {
  Frame f = stk.track(asts[1].exec(env)).getFrame();
  Futures fs = new Futures();
  Key[] keys = Vec.VectorGroup.VG_LEN1.addVecs(f.numCols());
  Vec[] vecs = new Vec[keys.length];

  // compute the longest vec... that's the one with the most domain levels
  int max = 0;
  for (int i = 0; i < f.numCols(); ++i)
    if (f.vec(i).isCategorical())
      if (max < f.vec(i).domain().length) max = f.vec(i).domain().length;

  final int rowLayout = Vec.ESPC.rowLayout(keys[0], new long[]{0, max});
  for (int i = 0; i < f.numCols(); ++i) {
    AppendableVec v = new AppendableVec(keys[i], Vec.T_NUM);
    NewChunk nc = new NewChunk(v, 0);
    String[] dom = f.vec(i).domain();
    int numToPad = dom == null ? max : max - dom.length;
    if (dom != null)
      for (int j = 0; j < dom.length; ++j) nc.addNum(j);
    for (int j = 0; j < numToPad; ++j) nc.addNA();
    nc.close(0, fs);
    vecs[i] = v.close(rowLayout, fs);
    vecs[i].setDomain(dom);
  }
  fs.blockForPending();
  Frame fr2 = new Frame(vecs);
  return new ValFrame(fr2);
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:31,代码来源:AstLevels.java

示例6: seqStrVec

import water.fvec.NewChunk; //导入方法依赖的package包/类
static Vec seqStrVec(int... runs) {
  Key k = Vec.VectorGroup.VG_LEN1.addVec();
  Futures fs = new Futures();
  AppendableVec avec = new AppendableVec(k, Vec.T_STR);
  NewChunk chunk = new NewChunk(avec, 0);
  int seq = 0;
  for (int r : runs) {
    if (seq > 0) chunk.addStr(null);
    for (int i = 0; i < r; i++) chunk.addStr(String.valueOf(seq++));
  }
  chunk.close(0, fs);
  Vec vec = avec.layout_and_close(fs);
  fs.blockForPending();
  return vec;
}
 
开发者ID:h2oai,项目名称:h2o-3,代码行数:16,代码来源:AstRecAssignTestUtils.java


注:本文中的water.fvec.NewChunk.close方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。