本文整理了Java中water.fvec.Frame.delete_and_lock()
方法的一些代码示例,展示了Frame.delete_and_lock()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.delete_and_lock()
方法的具体详情如下:
包路径:water.fvec.Frame
类名称:Frame
方法名:delete_and_lock
暂无
代码示例来源:origin: h2oai/h2o-2
public static Key make(FileStatus f, Futures fs) {
long size = f.getLen();
String fname = f.getPath().toString();
Key k = Key.make(fname);
Key k2 = Vec.newKey(k);
new Frame(k).delete_and_lock(null);
// Insert the top-level FileVec key into the store
Vec v = new HdfsFileVec(k2,size);
DKV.put(k2, v, fs);
Frame fr = new Frame(k,new String[]{fname},new Vec[]{v});
fr.update(null);
fr.unlock(null);
return k;
}
private HdfsFileVec(Key key, long len) {super(key,len,Value.HDFS);}
代码示例来源:origin: h2oai/h2o-2
@Override
protected final void execImpl() {
if (dl_model == null) throw new IllegalArgumentException("Deep Learning Model must be specified.");
DeepLearningModel dlm = UKV.get(dl_model);
if (dlm == null) throw new IllegalArgumentException("Deep Learning Model not found.");
StringBuilder sb = new StringBuilder();
if (layer < -1 || layer > dlm.get_params().hidden.length-1) throw new IllegalArgumentException("Layer must be either -1 or between 0 and " + (dlm.get_params().hidden.length-1));
if (layer == -1) layer = dlm.get_params().hidden.length-1;
int features = dlm.get_params().hidden[layer];
sb.append("\nTransforming frame '" + source._key.toString() + "' with " + source.numCols() + " into " + features + " features with model '" + dl_model + "'\n");
Frame df = dlm.scoreDeepFeatures(source, layer);
sb.append("Storing the new features under: " + dest() + ".\n");
Frame output = new Frame(dest(), df.names(), df.vecs());
output.delete_and_lock(null);
output.unlock(null);
}
代码示例来源:origin: h2oai/h2o-2
@Override protected void execImpl() {
Frame fr = source;
new Frame(destination_key,fr._names.clone(),fr.vecs().clone()).delete_and_lock(null).unlock(null);
}
代码示例来源:origin: h2oai/h2o-2
sb.append("Storing the reconstruction error (MSE) for all rows under: " + dest() + ".\n");
Frame output = new Frame(dest(), new String[]{"Reconstruction.MSE"}, new Vec[]{mse.vecs()[0]});
output.delete_and_lock(null);
output.unlock(null);
final Vec mse_test = mse.anyVec();
代码示例来源:origin: h2oai/h2o-2
if( keys != null ) keys .add(k.toString());
if(DKV.get(k) != null)dels.add(k.toString());
new Frame(k).delete_and_lock(null);
NFSFileVec nfs = DKV.get(NFSFileVec.make(f, fs)).get();
Frame fr = new Frame(k,new String[] { "0" }, new Vec[] { nfs });
代码示例来源:origin: h2oai/h2o-2
@Override protected Response serve() {
Frame fr = null;
try {
if( model == null )
throw new IllegalArgumentException("Model is required to perform validation!");
// Create a new random key
if ( prediction == null )
prediction = Key.make("__Prediction_" + Key.make());
fr = new Frame(prediction,new String[0],new Vec[0]).delete_and_lock(null);
fr = model.score(data);
fr = new Frame(prediction,fr._names,fr.vecs()); // Jam in the frame key
return Inspect2.redirect(this, prediction.toString());
} catch( Throwable t ) {
return Response.error(t);
} finally {
if( fr != null ) fr.unlock(null);
}
}
}
代码示例来源:origin: h2oai/h2o-2
@Override protected void execImpl() {
// Note: Source data MUST contain all features (matched by name) used to build PCA model!
// If additional columns exist in source, they are automatically ignored in scoring
new Frame(destination_key, new String[0], new Vec[0]).delete_and_lock(self());
Frame fr = model.adapt(source, true)[0];
int nfeat = model._names.length;
DataInfo dinfo = new DataInfo(fr, 0, false, false, model.normSub, model.normMul, DataInfo.TransformType.STANDARDIZE, null, null);
PCAScoreTask tsk = new PCAScoreTask(this, dinfo, nfeat, num_pc, model.eigVec);
tsk.doAll(num_pc, dinfo._adaptedFrame);
String[] names = new String[num_pc];
String[][] domains = new String[num_pc][];
for(int i = 0; i < num_pc; i++) {
names[i] = "PC" + i;
domains[i] = null;
}
tsk.outputFrame(destination_key, names, domains).unlock(self());
}
代码示例来源:origin: h2oai/h2o-2
public static Key make(String serverUri, ClientFileInfo tf, Futures fs) {
String fname = tf.getPath(); // Always return absolute path /dir/filename
long size = tf.getLength();
Key k = Key.make(PersistTachyon.PREFIX + serverUri + fname);
Key k2 = Vec.newKey(k);
new Frame(k).delete_and_lock(null);
// Insert the top-level FileVec key into the store
Vec v = new TachyonFileVec(k2,size);
DKV.put(k2, v, fs);
Frame fr = new Frame(k,new String[] {fname}, new Vec[] {v});
fr.update(null);
fr.unlock(null);
return k;
}
private TachyonFileVec(Key key, long len) {super(key,len,Value.TACHYON);}
代码示例来源:origin: h2oai/h2o-2
@Override protected void execImpl() {
Frame frame = source;
if (shuffle) {
// FIXME: switch to global shuffle
frame = MRUtils.shuffleFramePerChunk(Utils.generateShuffledKey(frame._key), frame, seed);
frame.delete_and_lock(null).unlock(null); // save frame to DKV
// delete frame on the end
gtrash(frame);
}
FrameSplitter fs = new FrameSplitter(frame, ratios);
H2O.submitTask(fs);
Frame[] splits = fs.getResult();
split_keys = new Key [splits.length];
split_rows = new long[splits.length];
float rsum = Utils.sum(ratios);
split_ratios = Arrays.copyOf(ratios, splits.length);
split_ratios[splits.length-1] = 1f-rsum;
long sum = 0;
for(int i=0; i<splits.length; i++) {
sum += splits[i].numRows();
split_keys[i] = splits[i]._key;
split_rows[i] = splits[i].numRows();
}
assert sum == source.numRows() : "Frame split produced wrong number of rows: nrows(source) != sum(nrows(splits))";
}
代码示例来源:origin: h2oai/h2o-2
@Override protected Response serve() {
try {
if( model == null )
throw new IllegalArgumentException("Model is required to perform validation!");
final Key predictionKey = ( prediction == null )?Key.make("__Prediction_" + Key.make()):prediction;
GLMModel m = new GLMModel.GetScoringModelTask(null, model,lambda).invokeTask()._res;
// Create a new random key
if ( prediction == null )
prediction = Key.make("__Prediction_" + Key.make());
Frame fr = new Frame(prediction,new String[0],new Vec[0]).delete_and_lock(null);
fr = m.score(data);
fr = new Frame(prediction,fr._names,fr.vecs()); // Jam in the frame key
fr.unlock(null);
return Inspect2.redirect(this, prediction.toString());
} catch( Throwable t ) {
return Response.error(t);
}
}
}
代码示例来源:origin: h2oai/h2o-2
@Override public void compute2() {
int totcols = _createFrame.cols + (_createFrame.has_response ? 1 : 0);
Vec[] vecs = Vec.makeNewCons(_createFrame.rows, totcols, _createFrame.value, _domain);
String[] names = new String[vecs.length];
if(_createFrame.has_response) {
names[0] = "response";
for (int i = 1; i < vecs.length; i++) names[i] = "C" + i;
} else {
for (int i = 0; i < vecs.length; i++) names[i] = "C" + (i+1);
}
_out = new Frame(Key.make(_createFrame.key), names, vecs);
assert _out.numRows() == _createFrame.rows;
assert _out.numCols() == totcols;
_out.delete_and_lock(_job);
// fill with random values
new FrameRandomizer(_createFrame, _cat_cols, _int_cols, _real_cols, _bin_cols).doAll(_out);
//overwrite a fraction with N/A
new MissingInserter(this, _createFrame.seed, _createFrame.missing_fraction).asyncExec(_out);
}
代码示例来源:origin: h2oai/h2o-2
@Override protected Response serve() {
try {
Frame fr = new Frame(destination_key,source._names.clone(),source.vecs().clone()).delete_and_lock(null);
fr.remove(ignored_cols);
Frame oneHotFrame = hex.OneHot.expandDataset(fr,destination_key);
for (int i : ignored_cols) oneHotFrame.add(source._names[i], source.vecs()[i]);
oneHotFrame.unlock(null);
} catch( Throwable t ) {
return Response.error(t);
}
return Inspect2.redirect(this, destination_key.toString());
}
}
代码示例来源:origin: h2oai/h2o-2
@Override
public void compute2() {
final Vec [] srcVecs = _in.vecs();
_out = new Frame(_okey,_in.names(), new Vec(_vg.addVec(),_espc).makeZeros(srcVecs.length,_in.domains(),_in.uuids(),_in.times()));
_out.delete_and_lock(_jobKey);
new RebalanceTask(this,srcVecs).asyncExec(_out);
}
代码示例来源:origin: h2oai/h2o-2
public static Key make(S3ObjectSummary obj, Futures fs) {
String fname = obj.getKey();
Key k = Key.make("s3://" + obj.getBucketName() + "/" + fname);
long size = obj.getSize();
Key k2 = Vec.newKey(k);
new Frame(k).delete_and_lock(null);
// Insert the top-level FileVec key into the store
Vec v = new S3FileVec(k2,size);
DKV.put(k2, v, fs);
Frame fr = new Frame(k,new String[]{fname},new Vec[]{v});
fr.update(null);
fr.unlock(null);
return k;
}
private S3FileVec(Key key, long len) {super(key,len,Value.S3);}
代码示例来源:origin: h2oai/h2o-2
new Frame(job.dest(),new String[0],new Vec[0]).delete_and_lock(job.self()); // Lock BEFORE returning
for( Key k : keys ) Lockable.read_lock(k,job.self()); // Lock BEFORE returning
ParserFJTask fjt = new ParserFJTask(job, keys, setup, delete_on_done); // Fire off background parse
代码示例来源:origin: h2oai/h2o-2
for (int s=0; s<nsplits; s++) {
Frame split = new Frame(destKeys[s], dataset.names(), templates[s] );
split.delete_and_lock(jobKey);
splits[s] = split;
代码示例来源:origin: h2oai/h2o-2
else { fr2.delete_and_lock(null); _locked.add(fr2._key); } // Clear prior & set new data
fr2.unlock(null);
代码示例来源:origin: h2oai/h2o-2
for (int s=0; s<nsplits; s++) {
Frame split = new Frame(destKeys[s], dataset.names(), templates[s] );
split.delete_and_lock(jobKey);
splits[s] = split;
代码示例来源:origin: h2oai/h2o-2
@Test
public void run(){
// Put chunks into KV store
String dataset = "smalldata/logreg/syn_2659x1049.csv";
Key file = NFSFileVec.make(find_test_file(dataset));
Frame f = ParseDataset2.parse(Key.make(), new Key[]{file});
// Create two lockable frames in KV store
Frame fr1 = new Frame(Key.make(), f.names(), f.vecs());
Frame fr2 = new Frame(Key.make(), f.names(), f.vecs());
// Lock the frames against writes
fr1.delete_and_lock(null);
fr2.delete_and_lock(null);
int i = 0;
try {
// try to delete the write-locked frames -> will throw an exception
fr1.delete();
fr2.delete(); // won't be reached
} catch(Throwable t) {
Log.info("Correctly unable to delete (was locked): " + t.getClass()); //either AssertionError if local or DistributedException if remote
i++;
} finally {
// second attempt: will unlock and delete properly
new UnlockKeys().serve(); // without this line, there will be a leak (and assertion won't be shown)
fr1.delete();
fr2.delete();
f.delete();
Log.info("Able to delete after unlocking.");
}
Assert.assertTrue(i == 1);
}
代码示例来源:origin: h2oai/h2o-3
levelOneFrame.delete_and_lock(_job);
levelOneFrame.unlock(_job);
Log.info("Finished creating \"level one\" frame for stacking: " + levelOneFrame.toString());
内容来源于网络,如有侵权,请联系作者删除!