Skip to content

Commit be5d73f

Browse files
committed
ARROW-410: [C++] Add virtual Writeable::Flush
Author: Wes McKinney <wes.mckinney@twosigma.com> Closes apache#310 from wesm/ARROW-410 and squashes the following commits: 7352f0a [Wes McKinney] Add virtual Writeable::Flush, and move HDFS flush there
1 parent 7ac320b commit be5d73f

4 files changed

Lines changed: 21 additions & 3 deletions

File tree

cpp/src/arrow/io/hdfs.cc

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,15 +238,20 @@ class HdfsOutputStream::HdfsOutputStreamImpl : public HdfsAnyFileImpl {
238238

239239
Status Close() {
240240
if (is_open_) {
241-
int ret = driver_->Flush(fs_, file_);
242-
CHECK_FAILURE(ret, "Flush");
243-
ret = driver_->CloseFile(fs_, file_);
241+
RETURN_NOT_OK(Flush());
242+
int ret = driver_->CloseFile(fs_, file_);
244243
CHECK_FAILURE(ret, "CloseFile");
245244
is_open_ = false;
246245
}
247246
return Status::OK();
248247
}
249248

249+
Status Flush() {
250+
int ret = driver_->Flush(fs_, file_);
251+
CHECK_FAILURE(ret, "Flush");
252+
return Status::OK();
253+
}
254+
250255
Status Write(const uint8_t* buffer, int64_t nbytes, int64_t* bytes_written) {
251256
tSize ret = driver_->Write(fs_, file_, reinterpret_cast<const void*>(buffer), nbytes);
252257
CHECK_FAILURE(ret, "Write");
@@ -277,6 +282,10 @@ Status HdfsOutputStream::Write(const uint8_t* buffer, int64_t nbytes) {
277282
return Write(buffer, nbytes, &bytes_written_dummy);
278283
}
279284

285+
Status HdfsOutputStream::Flush() {
286+
return impl_->Flush();
287+
}
288+
280289
Status HdfsOutputStream::Tell(int64_t* position) {
281290
return impl_->Tell(position);
282291
}

cpp/src/arrow/io/hdfs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ class ARROW_EXPORT HdfsOutputStream : public OutputStream {
208208

209209
Status Write(const uint8_t* buffer, int64_t nbytes, int64_t* bytes_written);
210210

211+
Status Flush() override;
212+
211213
Status Tell(int64_t* position) override;
212214

213215
private:

cpp/src/arrow/io/interfaces.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,9 @@ Status Writeable::Write(const std::string& data) {
5252
reinterpret_cast<const uint8_t*>(data.c_str()), static_cast<int64_t>(data.size()));
5353
}
5454

55+
Status Writeable::Flush() {
56+
return Status::OK();
57+
}
58+
5559
} // namespace io
5660
} // namespace arrow

cpp/src/arrow/io/interfaces.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ class ARROW_EXPORT Writeable {
7373
public:
7474
virtual Status Write(const uint8_t* data, int64_t nbytes) = 0;
7575

76+
// Default implementation is a no-op
77+
virtual Status Flush();
78+
7679
Status Write(const std::string& data);
7780
};
7881

0 commit comments

Comments
 (0)