NAME
ttypt/cormr.h - Corm Recall Kernel: uniform candidate sets + a generic ranking loop.
SYNOPSIS
#include <stdint.h>
#include <stddef.h>
#include <string.h>
Data Structures
struct cormr_axis
struct cormr_axis_score
struct cormr_query_axis
struct cormr_query
struct cormr_axis_cli_option
Macros
#define CORMR_QUERY_MAX_AXES 8
Typedefs
typedef int(* cormr_score_fn) (void *ud, cormr_ref_t r, float *score)
typedef int(* cormr_fill_fn) (void *ctx, void *params, cormr_set_t *out)
typedef int(* cormr_rank_fn) (void *ctx, void *params, cormr_ref_t ref, float *score)
typedef struct cormr_axis cormr_axis_t
typedef struct cormr_axis_score cormr_axis_score_t
typedef int(* cormr_consumer_score_fn) (void *ud, cormr_ref_t ref, const cormr_axis_score_t *as, int n_as, float *out_score)
typedef struct cormr_query_axis cormr_query_axis_t
typedef struct cormr_query cormr_query_t
Enumerations
enum cormr_set_exactness { CORMR_SET_EXACT = 0, CORMR_SET_APPROX = 1 }
enum cormr_join_t { CORMR_JOIN_AND = 0, CORMR_JOIN_OR = 1, CORMR_JOIN_NOT = 2 }
Functions
cormr_set_t * cormr_set_new (void)
void cormr_set_push (cormr_set_t *s, cormr_ref_t r)
void cormr_set_seal (cormr_set_t *s)
int cormr_set_drain (cormr_set_t *s, uint32_t hd)
int cormr_set_intersect (cormr_set_t *dst, const cormr_set_t *a, const cormr_set_t *b)
int cormr_set_subtract (cormr_set_t *dst, const cormr_set_t *a, const cormr_set_t *b)
int cormr_set_union (cormr_set_t *dst, const cormr_set_t *a, const cormr_set_t *b)
size_t cormr_set_count (const cormr_set_t *s)
const cormr_ref_t * cormr_set_at (const cormr_set_t *s)
void cormr_set_free (cormr_set_t *s)
int cormr_set_approx (cormr_set_t *s, int approx, float recall_bound)
int cormr_set_is_approx (const cormr_set_t *s)
float cormr_set_bound (const cormr_set_t *s)
cormr_rank_t * cormr_rank_new (size_t top_k, float min_score)
void cormr_rank_push (cormr_rank_t *rk, cormr_ref_t r, float score)
size_t cormr_rank_sorted (const cormr_rank_t *rk, cormr_ref_t *refs, float *scores)
void cormr_rank_free (cormr_rank_t *rk)
int cormr_axis_register (const cormr_axis_t *axis)
const cormr_axis_t * cormr_axis_get (int slot)
void * cormr_axis_decode (int slot, const char *s)
int cormr_axis_set_ctx (int slot, void *ctx)
int cormr_axis_count (void)
int cormr_query_run (const cormr_query_t *q, cormr_ref_t *refs, float *scores)
int cormr_spec_scan (const char **cur, const char **key, size_t *klen, const char **val, size_t *vlen, int *quoted)
int cormr_cli_str_set (char **dst, const char *value)
int cormr_cli_int (const char *v, int *out)
int cormr_cli_int_b (const char *v, const char *v_end, int *out)
int cormr_cli_str_dup (const char *v, size_t n, int quoted, char **out)
Detailed Description
Corm Recall Kernel: uniform candidate sets + a generic ranking loop.
Pure C, no domain math. Candidate sets are sorted, deduplicated lists of 32-bit refs (merge-join, no hashing). A ref IS a corm record reference (e.g. the id returned by corm_put() under CM_AINDEX) โ the same primary-key space every corm-backed store shares, never an axis's own internal key. An axis may index by whatever it needs internally (e.g. libislet's 64-bit morton keys); those internal keys are not refs and never leave the axis. The ranking loop is a bounded, streaming min-heap: an axis streams refs + scores straight into cormr_rank_push; a set is materialized only when a second axis needs to join. Weighted composition across axes lives in the consumer's score function.
Kernel is optional and additive: raw corm / domain entry points in the axis libraries are untouched. Ref mapping is the consumer's job โ the kernel never interprets a ref.
Adapter contract: an axis exposes ONE filler int cormr_axis_fill_*(<domain query args>, cormr_set_t *out); that streams the refs matching its filter into the set and seals it (0 ok / -1 error). Fill-only queries stay streaming (the axis pushes straight into cormr_rank_push); a set is materialized only when a second axis or ranker joins. Approximate fills (e.g. ANN neighbors) must declare themselves, since intersecting with an approximate set bounds final recall by it. Full design: docs/RECALL-KERNEL.md.
See also
Author
Generated automatically by Doxygen for corm from the source code.