aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/lib/io/py_record_writer.cc
diff options
context:
space:
mode:
authorGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
committerGravatar Manjunath Kudlur <keveman@gmail.com>2015-11-06 16:27:58 -0800
commitf41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch)
treeef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/python/lib/io/py_record_writer.cc
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation using data flow graphs. Base CL: 107276108
Diffstat (limited to 'tensorflow/python/lib/io/py_record_writer.cc')
-rw-r--r--tensorflow/python/lib/io/py_record_writer.cc44
1 files changed, 44 insertions, 0 deletions
diff --git a/tensorflow/python/lib/io/py_record_writer.cc b/tensorflow/python/lib/io/py_record_writer.cc
new file mode 100644
index 0000000000..e557756cbc
--- /dev/null
+++ b/tensorflow/python/lib/io/py_record_writer.cc
@@ -0,0 +1,44 @@
+#include "tensorflow/python/lib/io/py_record_writer.h"
+
+#include "tensorflow/core/lib/core/stringpiece.h"
+#include "tensorflow/core/platform/port.h"
+#include "tensorflow/core/lib/io/record_writer.h"
+#include "tensorflow/core/public/env.h"
+
+namespace tensorflow {
+namespace io {
+
+PyRecordWriter::PyRecordWriter() {}
+
+PyRecordWriter* PyRecordWriter::New(const string& filename) {
+ WritableFile* file;
+ Status s = Env::Default()->NewWritableFile(filename, &file);
+ if (!s.ok()) {
+ return nullptr;
+ }
+ PyRecordWriter* writer = new PyRecordWriter;
+ writer->file_ = file;
+ writer->writer_ = new RecordWriter(writer->file_);
+ return writer;
+}
+
+PyRecordWriter::~PyRecordWriter() {
+ delete writer_;
+ delete file_;
+}
+
+bool PyRecordWriter::WriteRecord(::tensorflow::StringPiece record) {
+ if (writer_ == nullptr) return false;
+ Status s = writer_->WriteRecord(record);
+ return s.ok();
+}
+
+void PyRecordWriter::Close() {
+ delete writer_;
+ delete file_;
+ writer_ = nullptr;
+ file_ = nullptr;
+}
+
+} // namespace io
+} // namespace tensorflow