westonpace commented on code in PR #13640:
URL: https://github.com/apache/arrow/pull/13640#discussion_r959811087
##########
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:
If it were an internal optimization (e.g. something the user didn't really
have direct control over but we tried to use if available) then I would agree.
However, given that the user is asking for this behavior, I think an error is
correct.
That being said, if it is significantly complicating tests because this
doesn't exist, maybe a warning is a reasonable compromise?
--
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]