Skip to content

refactor(io): make FileIO resolution registry-driven - #889

Open
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:file_io_resolver
Open

refactor(io): make FileIO resolution registry-driven#889
wgtmac wants to merge 1 commit into
apache:mainfrom
wgtmac:file_io_resolver

Conversation

@wgtmac

@wgtmac wgtmac commented Aug 16, 2026

Copy link
Copy Markdown
Member

Problem

The existing FileIO design embeds scheme ownership in ResolvingFileIO and
registers the resolver itself as a special implementation. This duplicates
backend-specific scheme knowledge, prevents custom FileIOs from declaring the
schemes they support, and couples automatic routing to a special registry
entry.

Cached delegates are also returned as raw pointers while credential refresh
can invalidate the cache. In addition, treating oss:// as an S3 alias is not
safe without provider-specific endpoint and compatibility validation.

Changes

  • Make FileIORegistry::Factory contain a required create callback and an
    optional accepts callback.
  • Resolve normalized schemes from registered factories, with later
    registrations overriding earlier ones.
  • Construct the default ResolvingFileIO directly while preserving explicit
    io-impl precedence.
  • Use Java-compatible first-colon scheme parsing and remove hard-coded scheme
    mapping from the resolver.
  • Keep cached delegates alive with shared_ptr across credential refreshes.
  • Forward complete credential lists to delegates that support them and rebuild
    delegates after refresh.
  • Limit Arrow S3 routing and credential prefix handling to s3, s3a, and
    s3n; defer OSS/COS support to a separate change.
  • Add focused registry, resolver, REST, and S3 coverage.
  • Document built-in and custom FileIO usage.

Add scheme-aware FileIO factories with deterministic registration precedence,
route ResolvingFileIO by location scheme, and forward vended storage
credentials through registered delegates.
Copilot AI lite review requested due to automatic review settings August 16, 2026 15:59

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors FileIO resolution so ResolvingFileIO routes locations via FileIORegistry factories (registry-driven scheme ownership), improves delegate caching across credential refreshes, narrows S3 routing to s3/s3a/s3n, and adds/updates targeted coverage plus end-user documentation.

Changes:

  • Introduces FileIORegistry::Factory{create, accepts} and scheme-based FileIORegistry::Resolve() with “latest registration wins” semantics.
  • Updates ResolvingFileIO to resolve schemes via the registry (Java-style first-colon parsing) and to cache delegates using shared_ptr with refreshed-credential rebuild behavior.
  • Updates tests, build files, and docs to reflect the new registry-driven routing model and supported S3 schemes.

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/iceberg/util/location_util.h Adds LocationUtil::ParseScheme declaration used for scheme routing.
src/iceberg/util/location_util.cc Implements ParseScheme for Java-style first-colon scheme parsing.
src/iceberg/file_io_registry.h Refactors registry API to struct-based factories and adds Resolve(scheme).
src/iceberg/file_io_registry.cc Implements ordered registrations, explicit load, and scheme resolution.
src/iceberg/resolving_file_io.h Switches caching to shared_ptr and updates locking to shared_mutex.
src/iceberg/resolving_file_io.cc Routes per-location via FileIORegistry::Resolve, caches delegates, rebuilds on credential refresh, and groups bulk deletes by delegate.
src/iceberg/catalog/rest/rest_file_io.cc Defaults REST catalog FileIO to directly constructed ResolvingFileIO when io-impl is absent.
src/iceberg/arrow/arrow_register.cc Registers built-in local/S3 FileIOs with create + accepts callbacks.
src/iceberg/arrow/s3/s3_properties.h Centralizes S3 scheme list and helpers for scheme acceptance.
src/iceberg/arrow/s3/arrow_s3_file_io.cc Removes OSS alias handling from S3 credential prefix logic and scheme canonicalization.
src/iceberg/util/location_util.cc (Also) relocates scheme parsing logic into a shared util.
src/iceberg/test/rest_file_io_test.cc Adjusts default REST FileIO expectation; adds a registry-delegation test; updates registry registration callsites.
src/iceberg/test/rest_catalog_integration_test.cc Updates registry registration to new factory struct form.
src/iceberg/test/resolving_file_io_test.cc Updates routing assumptions (no OSS alias), adds batch delete grouping tests, and validates no fallback after selected factory failure.
src/iceberg/test/location_util_test.cc Adds unit test coverage for ParseScheme.
src/iceberg/test/arrow_s3_file_io_test.cc Removes OSS from S3-compatible credential prefixes; updates endpoint scheme test data away from OSS-specific values.
src/iceberg/test/arrow_io_test.cc Adds a registration smoke test ensuring built-in registry routing works via ResolvingFileIO.
src/iceberg/test/rest_arrow_file_io_test.cc Removes an integration test that depended on the prior OSS/S3 routing behavior and bundle linkage.
src/iceberg/test/CMakeLists.txt Removes bundle-only REST Arrow FileIO test wiring and USE_BUNDLE option.
src/iceberg/CMakeLists.txt Adds util/location_util.cc to the CMake build.
src/iceberg/meson.build Adds util/location_util.cc to the Meson build.
mkdocs/mkdocs.yml Adds FileIO docs page to the documentation nav.
mkdocs/docs/file-io.md Documents built-in/custom FileIO registration and selection, plus credential forwarding behavior.
Suppressed comments (1)

src/iceberg/util/location_util.cc:28

  • ParseScheme currently treats any text before the first ':' as a scheme, even for local paths that may contain ':' (e.g. Windows C:\\... or a POSIX path segment with ':'). That makes ResolvingFileIO attempt registry resolution for what should be a local path and can yield kNotSupported.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +74 to 78
std::erase_if(state.registrations, [&name](const RegistryState::Entry& entry) {
return entry.name == name;
});
state.registrations.emplace_back(std::move(name), std::move(factory));
}
Comment on lines +25 to 28
#include <algorithm>
#include <array>
#include <string_view>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants