Module: Kumi::FunctionRegistry

Defined in:
lib/kumi/function_registry.rb,
lib/kumi/function_registry/loader.rb

Overview

The function registry: the single source of truth for the functions a schema may call and the per-target kernels that implement them. Loaded once from the ‘data/functions` and `data/kernels` YAML and queried by the analyzer (overload resolution, dimensional analysis) and the codegen/binder (kernel lookup).

Public surface:

FunctionRegistry.load                       -> Instance
FunctionRegistry::SELECT_ID                  -> the synthetic select function id
FunctionRegistry::Function / ::Kernel        -> the loaded record structs

Instance API (see Instance):

function(id) / function?(id)                 -> look up / test a function
resolve(id, arg_types)                       -> overload resolution by arg types
resolve_id(id)                               -> alias/id -> canonical function id
select?(id) / reduce?(id)                     -> kind predicates
kernel_for / kernel_id_for / kernel_identity_for / impl_for
registry_ref                                 -> stable content hash

Defined Under Namespace

Modules: Loader Classes: Function, Instance, Kernel

Constant Summary collapse

DEFAULT_FUNCTIONS_DIR =
File.expand_path("../../data/functions", __dir__)
DEFAULT_KERNELS_DIR =
File.expand_path("../../data/kernels", __dir__)
SELECT_ID =
"__select__"

Class Method Summary collapse

Class Method Details

.load(functions_dir: DEFAULT_FUNCTIONS_DIR, kernels_root: DEFAULT_KERNELS_DIR) ⇒ Object



144
145
146
147
148
# File 'lib/kumi/function_registry.rb', line 144

def load(functions_dir: DEFAULT_FUNCTIONS_DIR, kernels_root: DEFAULT_KERNELS_DIR)
  fn_map = Loader.load_functions(functions_dir, Function)
  kn_map = Loader.load_kernels(kernels_root, Kernel)
  Instance.new(fn_map, kn_map)
end