Repository navigation
GH-51816: [GLib] Add filesystem GType registration mechanism - #55464
Conversation
| struct GArrowFileSystemTypeRegistry | ||
| { | ||
| std::mutex mutex; | ||
| std::unordered_map<std::string, GType> types = { | ||
| {"local", GARROW_TYPE_LOCAL_FILE_SYSTEM}, | ||
| {"hdfs", GARROW_TYPE_HDFS_FILE_SYSTEM}, | ||
| {"s3", GARROW_TYPE_S3_FILE_SYSTEM}, | ||
| {"gcs", GARROW_TYPE_GCS_FILE_SYSTEM}, | ||
| {"abfs", GARROW_TYPE_AZURE_FILE_SYSTEM}, | ||
| {"mock", GARROW_TYPE_MOCK_FILE_SYSTEM}, | ||
| }; | ||
| }; |
There was a problem hiding this comment.
How about using GIOExtensionPoint instead?
https://docs.gtk.org/gio/struct.IOExtensionPoint.html
If you aren't familiar with GIOExtensionPoint, I can push some commits to this branch.
|
BTW, we don't need no human reviewed PR. If you use only AI, I'll open a separated PR for the issue. |
@kou the code was fully reviewed and design was implemented by me - just the wording in the PR description and code syntax was by AI - I updated the description apologies for the confusion |
|
OK. Could you explain the following?
|
Thanks for your questions @kou , I looked into GIO's implementation and here's what I found: 1- 2- I used 3- For direct registration through GIO, the current implementation cannot guarantee thread safety when another module calls Please let me know what you think the best approach is whenever you get the chance, thanks! |
|
@kou following up |
kou
left a comment
There was a problem hiding this comment.
"Another approach here could be to require filesystem modules to complete registration during initialization before concurrent lookups begin - this could also be documented and clarified as the intended registration contract" is better but I want to keep garrow_file_system_register_type() for the API that is used by the initialization phase.
| }; | ||
|
|
||
| G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE(GArrowFileSystem, garrow_file_system, G_TYPE_OBJECT) | ||
| G_DEFINE_TYPE_WITH_PRIVATE(GArrowFileSystem, garrow_file_system, G_TYPE_OBJECT) |
There was a problem hiding this comment.
This enables the generic fallback which was requested. When garrow_file_system_new_raw() encounters a fs that is not registered, it falls back to GARROW_TYPE_FILE_SYSTEM. Since GArrowFileSystem was previously abstract, I changed it to a concrete type so g_object_new() can instantiate it.
There was a problem hiding this comment.
Ah, sorry. I wrote "fall back to GArrowFileSystem when none is registered" in #51608. I want to reconsider it. Reporting an error for unknown file system may be better. Could you keep "abstract" for now? We can revisit this later.
@kou I kept I removed the private mutex because direct GIO calls bypassed it. The function-local static still provides one-time initialization of the extension point and built-in registrations. |
|
@kou Could you please rerun the failed Windows MinGW job? The GLib tests passed, but two Ruby Parquet tests errored with |
|
The failure will be fixed by #55703 . |
|
@kou I addressed everything - I think this is good to merge |
|
Thanks. Merged. |
Rationale for this change
Provide filesystem wrapper registration so separately packaged bindings can supply their own GLib types. This prepares for the S3 GLib bindings split in #51608.
Closes #51816.
What changes are included in this PR?
garrow_file_system_register_type()backed by GIO'sarrow-file-systemextension point.Are these changes tested?
Verified locally on macOS arm64:
These are local results for commit
a75348d944. GitHub CI results are reported separately in the PR checks.Are there any user-facing changes?
Adds a filesystem type-registration API. Each wrapper type has one registration name within the extension point.
GArrowFileSystemremains abstract; changes to unknown-filesystem handling are deferred.Registration must finish sequentially during initialization, before concurrent filesystem wrapper lookups begin. This requirement also applies to direct GIO registration and registrations triggered by GIO module loading. Concurrent registration is not supported.
Moving the S3 bindings into a separate library is outside this PR's scope.
Was AI used for this PR?
Codex generated the implementation and tests and helped draft this description.
I personally reviewed the full implementation and tests.