MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / BundleWriter

Method BundleWriter

tensorflow/core/util/tensor_bundle/tensor_bundle.cc:401–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

399} // namespace
400
401BundleWriter::BundleWriter(Env* env, StringPiece prefix, const Options& options)
402 : env_(env),
403 options_(options),
404 prefix_(prefix),
405 tmp_metadata_path_(strings::StrCat(MetaFilename(prefix_), ".tempstate",
406 random::New64())),
407 tmp_data_path_(strings::StrCat(DataFilename(prefix_, 0, 1), ".tempstate",
408 random::New64())),
409 out_(nullptr),
410 size_(0) {
411 status_ = env_->CreateDir(string(io::Dirname(prefix_)));
412 if (!status_.ok() && !errors::IsAlreadyExists(status_)) {
413 return;
414 }
415 const string filename = DataFilename(prefix_, 0, 1);
416 std::unique_ptr<WritableFile> wrapper;
417 status_ = env_->NewWritableFile(tmp_data_path_, &wrapper);
418 if (!status_.ok()) return;
419 out_ = std::unique_ptr<FileOutputBuffer>(
420 new FileOutputBuffer(wrapper.release(), 8 << 20 /* 8MB write buffer */));
421
422 VLOG(1) << "Writing to file " << tmp_data_path_;
423}
424
425Status BundleWriter::Add(StringPiece key, const Tensor& val) {
426 if (!status_.ok()) return status_;

Callers

nothing calls this directly

Calls 9

MetaFilenameFunction · 0.85
New64Function · 0.85
DataFilenameFunction · 0.85
DirnameFunction · 0.85
StrCatFunction · 0.50
CreateDirMethod · 0.45
okMethod · 0.45
NewWritableFileMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected