[ 
https://issues.apache.org/jira/browse/ARROW-2203?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16378290#comment-16378290
 ] 

ASF GitHub Bot commented on ARROW-2203:
---------------------------------------

xhochy closed pull request #1657: ARROW-2203: [C++] StderrStream class
URL: https://github.com/apache/arrow/pull/1657
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/cpp/src/arrow/util/io-util.h b/cpp/src/arrow/util/io-util.h
index 864e1bde7..2a01be104 100644
--- a/cpp/src/arrow/util/io-util.h
+++ b/cpp/src/arrow/util/io-util.h
@@ -51,6 +51,29 @@ class StdoutStream : public OutputStream {
   int64_t pos_;
 };
 
+// Output stream that just writes to stderr.
+class StderrStream : public OutputStream {
+ public:
+  StderrStream() : pos_(0) { set_mode(FileMode::WRITE); }
+  ~StderrStream() override {}
+
+  Status Close() override { return Status::OK(); }
+
+  Status Tell(int64_t* position) const override {
+    *position = pos_;
+    return Status::OK();
+  }
+
+  Status Write(const void* data, int64_t nbytes) override {
+    pos_ += nbytes;
+    std::cerr.write(reinterpret_cast<const char*>(data), nbytes);
+    return Status::OK();
+  }
+
+ private:
+  int64_t pos_;
+};
+
 // Input stream that just reads from stdin.
 class StdinStream : public InputStream {
  public:


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> [C++] StderrStream class
> ------------------------
>
>                 Key: ARROW-2203
>                 URL: https://issues.apache.org/jira/browse/ARROW-2203
>             Project: Apache Arrow
>          Issue Type: Improvement
>    Affects Versions: 0.8.0
>            Reporter: Rares Vernica
>            Assignee: Rares Vernica
>            Priority: Trivial
>              Labels: pull-request-available
>             Fix For: 0.9.0
>
>
> The C++ API has support for reading and writing data from and to STDIN and 
> STDOUT. The classes are arrow::io::StdinStream and arrow::io::StdoutStream. 
> It some scenarios it might be useful to write data to STDERR. Adding a 
> StderrStream class should be a trivial addition given the StdoutStream class.
> If you think a StderrStream class is a good idea, I am more than happy to 
> submit a PR.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to