sparrow 1.3.0
Loading...
Searching...
No Matches
sparrow::array_registry Class Reference

#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_registryoperator= (const array_registry &)=delete
 
 array_registry (array_registry &&)=delete
 
array_registryoperator= (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_wrappercreate (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_registryinstance ()
 Get the singleton registry instance.
 

Detailed Description

Definition at line 251 of file array_registry.hpp.

Member Typedef Documentation

◆ extension_predicate

using sparrow::array_registry::extension_predicate = std::function<bool(const arrow_proxy&)>

Extension predicate that checks if a proxy matches an extension type.

Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.

Definition at line 259 of file array_registry.hpp.

◆ factory_func

◆ visit_result_t

template<class F>
using sparrow::array_registry::visit_result_t = std::invoke_result_t<F, null_array>

Visitor result type alias.

Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.

Definition at line 263 of file array_registry.hpp.

Constructor & Destructor Documentation

◆ array_registry() [1/2]

sparrow::array_registry::array_registry ( const array_registry & )
delete
Here is the call graph for this function:
Here is the caller graph for this function:

◆ array_registry() [2/2]

sparrow::array_registry::array_registry ( array_registry && )
delete
Here is the call graph for this function:

Member Function Documentation

◆ create()

SPARROW_API cloning_ptr< array_wrapper > sparrow::array_registry::create ( arrow_proxy proxy) const
nodiscard

Create an array wrapper from an arrow_proxy.

This is the main entry point for array creation. It:

  1. Checks for dictionary encoding
  2. Checks registered extensions for the data type
  3. Falls back to base type factory
Parameters
proxyThe arrow_proxy to wrap
Returns
A cloning_ptr to the created array_wrapper
Exceptions
std::runtime_errorif no factory is found
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.

◆ dispatch() [1/2]

template<class F>
visit_result_t< F > sparrow::array_registry::dispatch ( F && func,
const array_wrapper & ar ) const
nodiscard
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dispatch() [2/2]

template<class F>
auto sparrow::array_registry::dispatch ( F && func,
const array_wrapper & ar ) const -> visit_result_t<F>
inline

Definition at line 463 of file array_registry.hpp.

Here is the call graph for this function:

◆ dispatch_base_type()

template<class F>
auto sparrow::array_registry::dispatch_base_type ( F && func,
const array_wrapper & ar,
data_type dt ) const -> visit_result_t<F>
inline

Definition at line 496 of file array_registry.hpp.

◆ instance()

static SPARROW_API array_registry & sparrow::array_registry::instance ( )
staticnodiscard

Get the singleton registry instance.

Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

array_registry & sparrow::array_registry::operator= ( array_registry && )
delete
Here is the call graph for this function:

◆ operator=() [2/2]

array_registry & sparrow::array_registry::operator= ( const array_registry & )
delete
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.
Here is the call graph for this function:

◆ register_base_type()

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.

Parameters
dtThe data_type enum value
factoryFactory function to create the array
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.

◆ register_extension() [1/2]

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.

Parameters
base_typeThe underlying base data_type
predicateCustom function to check if proxy is this extension
factoryFactory function to create the array

◆ register_extension() [2/2]

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.

Parameters
base_typeThe underlying base data_type
extension_nameThe value of "ARROW:extension:name" metadata
factoryFactory function to create the array
Examples
/home/runner/work/sparrow/sparrow/include/sparrow/layout/array_registry.hpp.

The documentation for this class was generated from the following file: