You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2017/01/31 13:00:57 UTC

arrow git commit: ARROW-410: [C++] Add virtual Writeable::Flush

Repository: arrow
Updated Branches:
  refs/heads/master 7ac320bde -> be5d73f2c


ARROW-410: [C++] Add virtual Writeable::Flush

Author: Wes McKinney <we...@twosigma.com>

Closes #310 from wesm/ARROW-410 and squashes the following commits:

7352f0a [Wes McKinney] Add virtual Writeable::Flush, and move HDFS flush there


Project: http://git-wip-us.apache.org/repos/asf/arrow/repo
Commit: http://git-wip-us.apache.org/repos/asf/arrow/commit/be5d73f2
Tree: http://git-wip-us.apache.org/repos/asf/arrow/tree/be5d73f2
Diff: http://git-wip-us.apache.org/repos/asf/arrow/diff/be5d73f2

Branch: refs/heads/master
Commit: be5d73f2cbcbd4c3f4e0a8ba41f69222ecedfc05
Parents: 7ac320b
Author: Wes McKinney <we...@twosigma.com>
Authored: Tue Jan 31 08:00:49 2017 -0500
Committer: Wes McKinney <we...@twosigma.com>
Committed: Tue Jan 31 08:00:49 2017 -0500

----------------------------------------------------------------------
 cpp/src/arrow/io/hdfs.cc       | 15 ++++++++++++---
 cpp/src/arrow/io/hdfs.h        |  2 ++
 cpp/src/arrow/io/interfaces.cc |  4 ++++
 cpp/src/arrow/io/interfaces.h  |  3 +++
 4 files changed, 21 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/arrow/blob/be5d73f2/cpp/src/arrow/io/hdfs.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.cc b/cpp/src/arrow/io/hdfs.cc
index 44e503f..2845b0d 100644
--- a/cpp/src/arrow/io/hdfs.cc
+++ b/cpp/src/arrow/io/hdfs.cc
@@ -238,15 +238,20 @@ class HdfsOutputStream::HdfsOutputStreamImpl : public HdfsAnyFileImpl {
 
   Status Close() {
     if (is_open_) {
-      int ret = driver_->Flush(fs_, file_);
-      CHECK_FAILURE(ret, "Flush");
-      ret = driver_->CloseFile(fs_, file_);
+      RETURN_NOT_OK(Flush());
+      int ret = driver_->CloseFile(fs_, file_);
       CHECK_FAILURE(ret, "CloseFile");
       is_open_ = false;
     }
     return Status::OK();
   }
 
+  Status Flush() {
+    int ret = driver_->Flush(fs_, file_);
+    CHECK_FAILURE(ret, "Flush");
+    return Status::OK();
+  }
+
   Status Write(const uint8_t* buffer, int64_t nbytes, int64_t* bytes_written) {
     tSize ret = driver_->Write(fs_, file_, reinterpret_cast<const void*>(buffer), nbytes);
     CHECK_FAILURE(ret, "Write");
@@ -277,6 +282,10 @@ Status HdfsOutputStream::Write(const uint8_t* buffer, int64_t nbytes) {
   return Write(buffer, nbytes, &bytes_written_dummy);
 }
 
+Status HdfsOutputStream::Flush() {
+  return impl_->Flush();
+}
+
 Status HdfsOutputStream::Tell(int64_t* position) {
   return impl_->Tell(position);
 }

http://git-wip-us.apache.org/repos/asf/arrow/blob/be5d73f2/cpp/src/arrow/io/hdfs.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/hdfs.h b/cpp/src/arrow/io/hdfs.h
index 5cc783e..fbf1d75 100644
--- a/cpp/src/arrow/io/hdfs.h
+++ b/cpp/src/arrow/io/hdfs.h
@@ -208,6 +208,8 @@ class ARROW_EXPORT HdfsOutputStream : public OutputStream {
 
   Status Write(const uint8_t* buffer, int64_t nbytes, int64_t* bytes_written);
 
+  Status Flush() override;
+
   Status Tell(int64_t* position) override;
 
  private:

http://git-wip-us.apache.org/repos/asf/arrow/blob/be5d73f2/cpp/src/arrow/io/interfaces.cc
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/interfaces.cc b/cpp/src/arrow/io/interfaces.cc
index 7e78caa..51ed069 100644
--- a/cpp/src/arrow/io/interfaces.cc
+++ b/cpp/src/arrow/io/interfaces.cc
@@ -52,5 +52,9 @@ Status Writeable::Write(const std::string& data) {
       reinterpret_cast<const uint8_t*>(data.c_str()), static_cast<int64_t>(data.size()));
 }
 
+Status Writeable::Flush() {
+  return Status::OK();
+}
+
 }  // namespace io
 }  // namespace arrow

http://git-wip-us.apache.org/repos/asf/arrow/blob/be5d73f2/cpp/src/arrow/io/interfaces.h
----------------------------------------------------------------------
diff --git a/cpp/src/arrow/io/interfaces.h b/cpp/src/arrow/io/interfaces.h
index e9f07f0..9862a67 100644
--- a/cpp/src/arrow/io/interfaces.h
+++ b/cpp/src/arrow/io/interfaces.h
@@ -73,6 +73,9 @@ class ARROW_EXPORT Writeable {
  public:
   virtual Status Write(const uint8_t* data, int64_t nbytes) = 0;
 
+  // Default implementation is a no-op
+  virtual Status Flush();
+
   Status Write(const std::string& data);
 };