NAME
hyle/registry.h - Source registry and the CRUD / view operations behind it.
SYNOPSIS
#include <stddef.h>
#include <stdint.h>
#include 'ctx.h'
#include 'field.h'
#include 'query.h'
Data Structures
Flat row representation for FFI (Rust bridge) consumers.
Macros
Auto-create the corm record type from the field metadata.
Typedefs
Load callback for ordered sources.
Save callback for ordered sources.
Provider signature for derived field values.
Functions
Register a source with row and field value maps.
Add or update a row in a registered source.
Put a tokenized field into the registry for (source_id, row_id, field).
Get a field value as a string for (row_id, field_name).
Delete a row and all of its field values from a source.
Run the filter, sort and paginate pipeline over a source.
Free the row map handle held by a row set.
Look up the row map handle of a registered source.
Look up the fields map handle of a registered source.
Retrieve the opaque user pointer stored for a source.
Replace the opaque user pointer stored for a source.
Number of currently registered sources.
Get the id of the source at a registry index.
Get the field count of a registered source.
Get the name of the field at an index of a source.
Get the type of the field at an index of a source.
Convert a row set into a flat array of FFI rows.
Free an FFI row array returned by hyle_row_set_to_rows().
Register an ordered, partitioned positional-array source.
Count the items in an ordered partition.
Get the storage key of the item at a partition position.
Append an item to the end of a partition and trigger save.
Insert an item at a partition position, shifting later items up.
Remove the item at a partition position and trigger save.
Remove every item in a partition and trigger save.
Explicitly trigger the save callback for a partition.
Register a derive provider under a derive key.
Look up and invoke the provider for a derive key.
Detailed Description
Source registry and the CRUD / view operations behind it.
Registers sources (plain or ordered), writes rows into their corms, and runs filter โ sort โ paginate queries against them; also the derive-function registry used during index rebuild.
Typedef Documentation
typedef const char *(* hyle_derive_fn_t) (const void *def, const char *row_id, const char *field_name, void *user)
Provider signature for derived field values.
Parameters
def Opaque source definition (user pointer).
row_id Row identifier.
field_name Name of the derived field being queried.
user Opaque user data (unused).
Returns
Pointer to a static/thread-local value buffer (caller must not free), or NULL when there is no value.
typedef int(* hyle_persist_load_fn) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)
Load callback for ordered sources.
Parameters
source_id Registered source id.
partition_val Partition whose items must be loaded.
fields_hd Fields map handle to populate.
user Opaque pointer passed at registration.
Returns
0 on success, non-zero on failure.
typedef int(* hyle_persist_save_fn) (const char *source_id, const char *partition_val, unsigned fields_hd, void *user)
Save callback for ordered sources.
Parameters
source_id Registered source id.
partition_val Partition whose items must be persisted.
fields_hd Fields map handle holding the items.
user Opaque pointer passed at registration.
Returns
0 on success, non-zero on failure.
Function Documentation
const char * hyle_derive_call (const void * def, const char * derive_key, const char * row_id, const char * field_name, void * user)
Look up and invoke the provider for a derive key.
Parameters
def Opaque source definition passed to the provider.
derive_key Key registering the provider to call.
row_id Row identifier.
field_name Name of the derived field being queried.
user Opaque user data (unused).
Returns
The provider's value, or NULL when no provider is registered.
int hyle_derive_register (const char * derive_key, hyle_derive_fn_t fn, void * user)
Register a derive provider under a derive key.
Parameters
derive_key Key matching hyle_field_t.derive_key.
fn Provider function.
user Opaque user data passed to fn.
Returns
0 on success, or -1 when the provider table is full.
const char * hyle_field_get_str (const char * source_id, const char * row_id, const char * field)
Get a field value as a string for (row_id, field_name). If the field was stored as a tokenized stream, decodes it on-demand into a thread-local buffer without heap allocation.
Parameters
source_id Dataset ID.
row_id Row ID.
field Field name.
Returns
String pointer (caller does not free), or NULL if not found.
int hyle_ordered_append (const char * source_id, const char * partition_val, const char ** names, const char ** values, size_t count)
Append an item to the end of a partition and trigger save.
Parameters
source_id Registered ordered source id.
partition_val Partition to append to.
names Field names.
values Parallel field values.
count Number of name/value pairs.
Returns
0 on success, or -1 when the partition cannot be loaded.
void hyle_ordered_clear (const char * source_id, const char * partition_val)
Remove every item in a partition and trigger save.
Parameters
source_id Registered ordered source id.
partition_val Partition to clear.
int hyle_ordered_count (const char * source_id, const char * partition_val)
Count the items in an ordered partition.
Parameters
source_id Registered ordered source id.
partition_val Partition to count.
Returns
The item count (zero when the partition is unloaded or absent).
int hyle_ordered_insert_at (const char * source_id, const char * partition_val, int pos, const char ** names, const char ** values, size_t count)
Insert an item at a partition position, shifting later items up.
Parameters
source_id Registered ordered source id.
partition_val Partition holding the item.
pos Zero-based insertion position.
names Field names.
values Parallel field values.
count Number of name/value pairs.
Returns
0 on success, or -1 when the position is out of range.
const char * hyle_ordered_key_at (const char * source_id, const char * partition_val, int pos)
Get the storage key of the item at a partition position.
Parameters
source_id Registered ordered source id.
partition_val Partition holding the item.
pos Zero-based item position.
Returns
The "{partition_val}__{NNNN}" key in a static buffer (valid until the next call), or NULL when the item does not exist.
unsigned hyle_ordered_register (const char * source_id, const hyle_field_t * fields, size_t field_count, const char * partition_field, uint32_t record_id, unsigned flags, hyle_persist_load_fn load_fn, hyle_persist_save_fn save_fn, void * persist_user)
Register an ordered, partitioned positional-array source. Items within a partition are addressed by zero-based position and stored under "{partition_val}__{NNNN}" keys. When HYLE_REGISTRY_AUTO_RECORD is set and record_id is 0, the record type is derived from the field metadata.
Parameters
source_id Unique id identifying the source.
fields Array of field descriptors.
field_count Number of entries in fields.
partition_field Field scoping items to a partition.
record_id Corm record type id, or 0 for plain maps.
flags Extra flags (e.g. HYLE_REGISTRY_AUTO_RECORD).
load_fn Load callback, or NULL.
save_fn Save callback, or NULL.
persist_user Opaque pointer passed to the callbacks.
Returns
The fields map handle on success, or 0 on error.
void hyle_ordered_remove_at (const char * source_id, const char * partition_val, int pos)
Remove the item at a partition position and trigger save.
Parameters
source_id Registered ordered source id.
partition_val Partition holding the item.
pos Zero-based item position to remove.
void hyle_ordered_save (const char * source_id, const char * partition_val)
Explicitly trigger the save callback for a partition.
Parameters
source_id Registered ordered source id.
partition_val Partition to persist.
size_t hyle_registry_count (void )
Number of currently registered sources.
Returns
The registry size.
void hyle_registry_del (const char * source_id, const char * row_id)
Delete a row and all of its field values from a source.
Parameters
source_id Registered source id.
row_id Row identifier to remove.
size_t hyle_registry_get_field_count (const char * source_id)
Get the field count of a registered source.
Parameters
source_id Registered source id.
Returns
The field count, or 0 when the source is unknown.
const char * hyle_registry_get_field_name (const char * source_id, size_t idx)
Get the name of the field at an index of a source.
Parameters
source_id Registered source id.
idx Field index.
Returns
The field name, or NULL when the source or index is invalid.
hyle_field_type_t hyle_registry_get_field_type (const char * source_id, size_t idx)
Get the type of the field at an index of a source.
Parameters
source_id Registered source id.
idx Field index.
Returns
The field type, or 0 when the source or index is invalid.
unsigned hyle_registry_get_fields_hd (const char * source_id)
Look up the fields map handle of a registered source.
Parameters
source_id Registered source id.
Returns
The fields map handle, or 0 when the source is unknown.
unsigned hyle_registry_get_row_hd (const char * source_id)
Look up the row map handle of a registered source.
Parameters
source_id Registered source id.
Returns
The row map handle, or 0 when the source is unknown.
void * hyle_registry_get_user (const char * source_id)
Retrieve the opaque user pointer stored for a source.
Parameters
source_id Registered source id.
Returns
The stored pointer, or NULL when the source is unknown.
const char * hyle_registry_id_at (size_t i)
Get the id of the source at a registry index.
Parameters
i Registry index.
Returns
The source id, or NULL when i is out of range.
int hyle_registry_put (const char * source_id, const char * row_id, const char ** names, const char ** values, size_t count)
Add or update a row in a registered source. Writes the row id into the row map and each name/value pair into the fields map, marking any full-text index dirty.
Parameters
source_id Registered source id.
row_id Row identifier.
names Field names.
values Parallel field values.
count Number of name/value pairs.
Returns
0 on success, or -1 when the source or row id is invalid.
int hyle_registry_put_tokens (const char * source_id, const char * row_id, const char * field, const uint16_t * tokens, size_t n_tokens)
Put a tokenized field into the registry for (source_id, row_id, field). Encodes the token stream with compact prefix \x1bT and stores it in fields_hd.
Parameters
source_id Dataset ID.
row_id Row ID.
field Field name.
tokens Array of token IDs.
n_tokens Token count.
Returns
0 on success, -1 on error.
int hyle_registry_query (const char * source_id, const hyle_query_t * query, hyle_row_set_t * out, size_t * total_out)
Run the filter, sort and paginate pipeline over a source. Performs full-text, multi-reference and reference pre-filtering for typed-record sources before delegating to hyle_apply_view(). The caller must call hyle_row_set_free() on *out when done.
Parameters
source_id Registered source id.
query Parsed view state to apply.
out Receives the resulting row set.
total_out Receives the total matching row count, or NULL.
Returns
0 on success, or -1 when the source is unknown or allocation fails.
unsigned hyle_registry_register (const char * source_id, const hyle_field_t * fields, size_t field_count, uint32_t record_id, unsigned flags, void * user)
Register a source with row and field value maps. Creates the row map (row_hd) and the fields map (fields_hd) for the source, optionally as a typed record corm when record_id is non-zero, and stores the field schema and opaque user pointer for later queries.
Parameters
source_id Unique id identifying the source.
fields Array of field descriptors.
field_count Number of entries in fields.
record_id Corm record type id, or 0 for plain maps.
flags Extra corm flags for the row map.
user Opaque pointer stored by the registry.
Returns
The fields map handle on success, or 0 on error.
void hyle_registry_set_user (const char * source_id, void * user)
Replace the opaque user pointer stored for a source.
Parameters
source_id Registered source id.
user New pointer to store.
void hyle_row_set_free (hyle_row_set_t * rs)
Free the row map handle held by a row set.
Parameters
rs Row set to release, or NULL.
int hyle_row_set_to_rows (const hyle_row_set_t * rs, hyle_ffi_row_t ** rows_out, size_t * count_out)
Convert a row set into a flat array of FFI rows.
Parameters
rs Row set to convert.
rows_out Receives the row array (call hyle_rows_free()).
count_out Receives the number of rows.
Returns
0 on success, or -1 on invalid arguments or allocation failure.
void hyle_rows_free (hyle_ffi_row_t * rows, size_t count)
Free an FFI row array returned by hyle_row_set_to_rows().
Parameters
rows Array of rows, or NULL.
count Number of entries in rows.
Author
Generated automatically by Doxygen for libhyle from the source code.