|
sparrow 1.3.0
|
#include <array_registry.hpp>
Public Types | |
| using | factory_func = std::function<cloning_ptr<array_wrapper>(arrow_proxy)> |
| Factory function type that creates an array_wrapper from an arrow_proxy. | |
| using | extension_predicate = std::function<bool(const arrow_proxy&)> |
| Extension predicate that checks if a proxy matches an extension type. | |
| template<class F> | |
| using | visit_result_t = std::invoke_result_t<F, null_array> |
| Visitor result type alias. | |
Public Member Functions | |
| array_registry (const array_registry &)=delete | |
| array_registry & | operator= (const array_registry &)=delete |
| array_registry (array_registry &&)=delete | |
| array_registry & | operator= (array_registry &&)=delete |
| SPARROW_API void | register_base_type (data_type dt, factory_func factory) |
| Register a base type factory. | |
| SPARROW_API void | register_extension (data_type base_type, std::string_view extension_name, factory_func factory) |
| Register an extension type factory. | |
| SPARROW_API void | register_extension (data_type base_type, extension_predicate predicate, factory_func factory) |
| Register an extension type with custom predicate. | |
| SPARROW_API cloning_ptr< array_wrapper > | create (arrow_proxy proxy) const |
| Create an array wrapper from an arrow_proxy. | |
| template<class F> | |
| visit_result_t< F > | dispatch (F &&func, const array_wrapper &ar) const |
| template<class F> | |
| auto | dispatch (F &&func, const array_wrapper &ar) const -> visit_result_t< F > |
| template<class F> | |
| auto | dispatch_base_type (F &&func, const array_wrapper &ar, data_type dt) const -> visit_result_t< F > |
Static Public Member Functions | |
| static SPARROW_API array_registry & | instance () |
| Get the singleton registry instance. | |
Definition at line 251 of file array_registry.hpp.
| using sparrow::array_registry::extension_predicate = std::function<bool(const arrow_proxy&)> |
Extension predicate that checks if a proxy matches an extension type.
Definition at line 259 of file array_registry.hpp.
| using sparrow::array_registry::factory_func = std::function<cloning_ptr<array_wrapper>(arrow_proxy)> |
Factory function type that creates an array_wrapper from an arrow_proxy.
Definition at line 256 of file array_registry.hpp.
| using sparrow::array_registry::visit_result_t = std::invoke_result_t<F, null_array> |
Visitor result type alias.
Definition at line 263 of file array_registry.hpp.
|
delete |
|
delete |
|
nodiscard |
Create an array wrapper from an arrow_proxy.
This is the main entry point for array creation. It:
| proxy | The arrow_proxy to wrap |
| std::runtime_error | if no factory is found |
|
nodiscard |
|
inline |
|
inline |
Definition at line 496 of file array_registry.hpp.
|
staticnodiscard |
Get the singleton registry instance.
|
delete |
|
delete |
| SPARROW_API void sparrow::array_registry::register_base_type | ( | data_type | dt, |
| factory_func | factory ) |
Register a base type factory.
Base type factories are used when no extension matches. They handle the standard Arrow data types.
NOTE: This registers the factory for array creation. The dispatch mechanism (visit/dispatch_base_type) uses a compile-time switch statement because C++ requires knowing the concrete type at compile time to unwrap the array_wrapper. While we could theoretically store type-erased dispatch functions, this would add significant runtime overhead and complexity for no practical benefit, since the set of base types is fixed and known at compile time.
| dt | The data_type enum value |
| factory | Factory function to create the array |
| SPARROW_API void sparrow::array_registry::register_extension | ( | data_type | base_type, |
| extension_predicate | predicate, | ||
| factory_func | factory ) |
Register an extension type with custom predicate.
This overload allows for more complex extension detection logic beyond simple metadata name matching.
| base_type | The underlying base data_type |
| predicate | Custom function to check if proxy is this extension |
| factory | Factory function to create the array |
| SPARROW_API void sparrow::array_registry::register_extension | ( | data_type | base_type, |
| std::string_view | extension_name, | ||
| factory_func | factory ) |
Register an extension type factory.
Extension types are checked before base types. An extension is selected when its base_type matches and its predicate returns true for the proxy.
| base_type | The underlying base data_type |
| extension_name | The value of "ARROW:extension:name" metadata |
| factory | Factory function to create the array |