pitrou commented on code in PR #13640:
URL: https://github.com/apache/arrow/pull/13640#discussion_r959812591
##########
cpp/src/arrow/filesystem/localfs.cc:
##########
@@ -448,17 +448,40 @@ Result<std::shared_ptr<io::OutputStream>>
OpenOutputStreamGeneric(const std::str
return maybe_stream;
}
+Result<std::shared_ptr<io::OutputStream>> OpenDirectIOOutputStreamGeneric(
+ const std::string& path) {
+ RETURN_NOT_OK(ValidatePath(path));
+ ARROW_ASSIGN_OR_RAISE(auto fn, PlatformFilename::FromString(path));
+ const bool write_only = true;
+ ARROW_ASSIGN_OR_RAISE(
+ auto fd, ::arrow::internal::FileOpenWritable(fn, write_only, true,
false, true));
+ int raw_fd = fd.Detach();
+ auto maybe_stream = io::DirectFileOutputStream::Open(raw_fd);
+ if (!maybe_stream.ok()) {
+ ARROW_UNUSED(::arrow::internal::FileClose(raw_fd));
+ }
+ return maybe_stream;
+}
+
} // namespace
Result<std::shared_ptr<io::OutputStream>> LocalFileSystem::OpenOutputStream(
const std::string& path, const std::shared_ptr<const KeyValueMetadata>&
metadata) {
bool truncate = true;
bool append = false;
- return OpenOutputStreamGeneric(path, truncate, append);
+ if (options_.use_directio) {
+ return OpenDirectIOOutputStreamGeneric(path);
+ } else {
+ return OpenOutputStreamGeneric(path, truncate, append);
+ }
}
Result<std::shared_ptr<io::OutputStream>> LocalFileSystem::OpenAppendStream(
const std::string& path, const std::shared_ptr<const KeyValueMetadata>&
metadata) {
+ if (options_.use_directio) {
+ return Status::NotImplemented("DirectIO append stream not implemented
yet.");
+ }
Review Comment:
Ok, let's keep it an error then.
It should be easy to skip the tests by the way, just override
`allow_append_to_file`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]