Skip to content

Commit

Permalink
GH-32206: [C++] GcsFileSystem::Make should return Result (#44503)
Browse files Browse the repository at this point in the history
### What changes are included in this PR?

GcsFileSystem::Make now returns Result, with corresponding header & test changes.

### Are these changes tested?

Yes, `arrow-gcsfs-test` passed.

### Are there any user-facing changes?

Yes.

**This PR includes breaking changes to public APIs.**

* GitHub Issue: #32206

Lead-authored-by: Gabriel Stone <Gabe.Stone@ibm.com>
Co-authored-by: Gabriel P Stone <Gabe.Stone@ibm.com>
Co-authored-by: Gabriel P Stone <gpstone@acm.org>
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
Signed-off-by: Sutou Kouhei <kou@clear-code.com>
  • Loading branch information
3 people authored and pull[bot] committed Jan 5, 2025
1 parent c8f2229 commit d7140ef
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 64 deletions.
7 changes: 4 additions & 3 deletions cpp/src/arrow/filesystem/gcsfs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -962,10 +962,11 @@ Result<std::shared_ptr<io::OutputStream>> GcsFileSystem::OpenAppendStream(
return Status::NotImplemented("Append is not supported in GCS");
}

std::shared_ptr<GcsFileSystem> GcsFileSystem::Make(const GcsOptions& options,
const io::IOContext& context) {
Result<std::shared_ptr<GcsFileSystem>> GcsFileSystem::Make(
const GcsOptions& options, const io::IOContext& io_context) {
// Cannot use `std::make_shared<>` as the constructor is private.
return std::shared_ptr<GcsFileSystem>(new GcsFileSystem(options, context));
std::shared_ptr<GcsFileSystem> ptr(new GcsFileSystem(options, io_context));
return ptr;
}

GcsFileSystem::GcsFileSystem(const GcsOptions& options, const io::IOContext& context)
Expand Down
3 changes: 1 addition & 2 deletions cpp/src/arrow/filesystem/gcsfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ class ARROW_EXPORT GcsFileSystem : public FileSystem {
const std::shared_ptr<const KeyValueMetadata>& metadata) override;

/// Create a GcsFileSystem instance from the given options.
// TODO(ARROW-16884): make this return Result for consistency
static std::shared_ptr<GcsFileSystem> Make(
static Result<std::shared_ptr<GcsFileSystem>> Make(
const GcsOptions& options, const io::IOContext& = io::default_io_context());

private:
Expand Down
Loading

0 comments on commit d7140ef

Please sign in to comment.