C API

Event windows

Retain the last events or groups of facts, update their solved snapshot and expire timed input explicitly.

Keep the last N accepted events and query the facts they produce. Use the Event windows guide to choose single-fact or multi-fact events, add explicit expiration, and manage the caller-owned storage.

Handle: window_t

C · handleSince v0.8.0
window_t

#include <maelys/datalog_window.h>

typedef struct maelys_datalog_window maelys_datalog_window_t;
Retains the last accepted single-fact events and their current solved snapshot.

Creation

window_storage_requirements()

C · functionSince v0.8.0
window_storage_requirements()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_storage_requirements(
size_t event_capacity,
size_t text_capacity,
size_t *out_bytes,
size_t *out_alignment
);
Measure the caller-owned storage for a single-fact event window.
Arguments
event_capacitysize_tin
Maximum number of accepted single-fact events retained in arrival order.
text_capacitysize_tin
Interned text capacity per input bank, in bytes, including terminating NUL bytes.
Outputs

Written on success.

out_bytessize_t *out
Receives the required caller-owned arena size; measure it at run time rather than hard-coding a size.
out_alignmentsize_t *out
Receives the required arena alignment; measure it at run time rather than hard-coding an alignment.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the required size and alignment. Invalid capacities or arguments are rejected; outputs remain unchanged on failure.

Example
size_t bytes = 0, alignment = 0;
maelys_datalog_status_t status = maelys_datalog_window_storage_requirements(event_capacity, text_capacity, &bytes, &alignment);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("storage required: %s\n", bytes > 0 ? "yes" : "no");
printf("alignment is a power of two: %s\n",
    alignment > 0 && (alignment & (alignment - 1)) == 0 ? "yes" : "no");
status: ok
storage required: yes
alignment is a power of two: yes

window_init()

C · functionSince v0.8.0
window_init()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_init(
void *storage,
size_t storage_bytes,
size_t event_capacity,
size_t text_capacity,
uint32_t first_occurrence,
maelys_datalog_session_t *session_a,
maelys_datalog_session_t *session_b,
maelys_datalog_window_t **out_window,
maelys_datalog_diagnostic_t *out_diagnostic
);
Initialize a single-fact window in caller-owned storage and borrow two idle sessions.
Arguments
storagevoid *in/out
Aligned caller-owned arena, kept exclusive, alive and immovable until the window is released.
storage_bytessize_tin
Number of bytes available in the caller-owned arena.
event_capacitysize_tin
Maximum number of accepted single-fact events retained in arrival order.
text_capacitysize_tin
Interned text capacity per input bank, in bytes, including terminating NUL bytes.
first_occurrenceuint32_tin
First generated occurrence ID, from zero through INT32_MAX.
session_amaelys_datalog_session_t *in
First idle session, borrowed exclusively by the window until release.
session_bmaelys_datalog_session_t *in
Second distinct idle session, with the same execution fingerprint as the first, borrowed until release.
Outputs

Written on success.

out_windowmaelys_datalog_window_t **out
Receives the initialized maelys_datalog_window_t handle. Receives NULL if initialization fails.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK with an initialized window and its empty-input result. Initialization can fail while solving empty input; no window is created on failure.

Example
size_t bytes = 0, alignment = 0;
check_status(maelys_datalog_window_storage_requirements(event_capacity, text_capacity, &bytes, &alignment));
window_storage = allocate_storage(bytes, alignment);
maelys_datalog_status_t status = maelys_datalog_window_init(window_storage, bytes, event_capacity, text_capacity, 0,
    sessions[0], sessions[1], &window, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("window initialized: %s\n", window != NULL ? "yes" : "no");
status: ok
window initialized: yes

window_storage_requirements_configured()

C · functionSince v0.13.0
window_storage_requirements_configured()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_storage_requirements_configured(
size_t event_capacity,
size_t text_capacity,
const maelys_datalog_window_options_t *options,
size_t *out_bytes,
size_t *out_alignment
);
Measure the caller-owned storage for a single-fact event window with static input or expiration options.
Arguments
event_capacitysize_tin
Maximum number of accepted single-fact events retained in arrival order.
text_capacitysize_tin
Interned text capacity per input bank, in bytes, including terminating NUL bytes.
optionsconst maelys_datalog_window_options_t *in
Optional configuration of static fact capacity and expiration metadata. Initialize every member, including struct_size.
Outputs

Written on success.

out_bytessize_t *out
Receives the required caller-owned arena size; measure it at run time rather than hard-coding a size.
out_alignmentsize_t *out
Receives the required arena alignment; measure it at run time rather than hard-coding an alignment.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the required size and alignment. Invalid capacities or arguments are rejected; outputs remain unchanged on failure.

Example
size_t bytes = 0, alignment = 0;
maelys_datalog_status_t status = maelys_datalog_window_storage_requirements_configured(event_capacity, text_capacity, &options, &bytes, &alignment);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("storage required: %s\n", bytes > 0 ? "yes" : "no");
printf("alignment is a power of two: %s\n",
    alignment > 0 && (alignment & (alignment - 1)) == 0 ? "yes" : "no");
status: ok
storage required: yes
alignment is a power of two: yes

window_init_configured()

C · functionSince v0.13.0
window_init_configured()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_init_configured(
void *storage,
size_t storage_bytes,
size_t event_capacity,
size_t text_capacity,
const maelys_datalog_window_options_t *options,
uint32_t first_occurrence,
maelys_datalog_session_t *session_a,
maelys_datalog_session_t *session_b,
maelys_datalog_window_t **out_window,
maelys_datalog_diagnostic_t *out_diagnostic
);
Initialize a single-fact window in caller-owned storage and borrow two idle sessions with the selected options.
Arguments
storagevoid *in/out
Aligned caller-owned arena, kept exclusive, alive and immovable until the window is released.
storage_bytessize_tin
Number of bytes available in the caller-owned arena.
event_capacitysize_tin
Maximum number of accepted single-fact events retained in arrival order.
text_capacitysize_tin
Interned text capacity per input bank, in bytes, including terminating NUL bytes.
optionsconst maelys_datalog_window_options_t *in
Optional configuration of static fact capacity and expiration metadata. Initialize every member, including struct_size.
first_occurrenceuint32_tin
First generated occurrence ID, from zero through INT32_MAX.
session_amaelys_datalog_session_t *in
First idle session, borrowed exclusively by the window until release.
session_bmaelys_datalog_session_t *in
Second distinct idle session, with the same execution fingerprint as the first, borrowed until release.
Outputs

Written on success.

out_windowmaelys_datalog_window_t **out
Receives the initialized maelys_datalog_window_t handle. Receives NULL if initialization fails.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK with an initialized window and its empty-input result. Initialization can fail while solving empty input; no window is created on failure.

Example
size_t bytes = 0, alignment = 0;
check_status(maelys_datalog_window_storage_requirements_configured(event_capacity, text_capacity, &options, &bytes, &alignment));
window_storage = allocate_storage(bytes, alignment);
maelys_datalog_status_t status = maelys_datalog_window_init_configured(window_storage, bytes, event_capacity, text_capacity, &options, 0,
    sessions[0], sessions[1], &window, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("window initialized: %s\n", window != NULL ? "yes" : "no");
status: ok
window initialized: yes

Functions

window_push()

C · functionSince v0.8.0
window_push()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_push(
maelys_datalog_window_t *window,
const char *predicate,
const maelys_datalog_value_t *terms,
size_t value_count,
uint32_t *out_occurrence,
maelys_datalog_diagnostic_t *out_diagnostic
);
Append an event with a generated occurrence ID, expiring the oldest entry when the window is full.
Arguments
windowmaelys_datalog_window_t *handlemodified
Single-fact event window (maelys_datalog_window_t) to modify by appending the new event with its generated occurrence ID.
predicateconst char *in
Predicate name; an occurrence ID is prepended to the supplied terms.
termsconst maelys_datalog_value_t *in
Remaining event terms, excluding the generated occurrence ID.
value_countsize_tin
Number of supplied terms, from zero through three.
Outputs

Written on success.

out_occurrenceuint32_t *out
Optional destination for the generated occurrence ID; unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_window();
uint32_t id = 0;
maelys_datalog_status_t status = maelys_datalog_window_push(window, "access", terms, 2, &id, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("occurrence id: %" PRIu32 "\n", id);
status: ok
occurrence id: 0

window_push_until()

C · functionSince v0.13.0
window_push_until()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_push_until(
maelys_datalog_window_t *window,
const char *predicate,
const maelys_datalog_value_t *terms,
size_t value_count,
uint64_t expires_at,
uint32_t *out_occurrence,
maelys_datalog_diagnostic_t *out_diagnostic
);
Append an event with a generated occurrence ID and an explicit expiration deadline.
Arguments
windowmaelys_datalog_window_t *handlemodified
Single-fact event window (maelys_datalog_window_t) to modify by appending the new event with its generated occurrence ID.
predicateconst char *in
Predicate name; an occurrence ID is prepended to the supplied terms.
termsconst maelys_datalog_value_t *in
Remaining event terms, excluding the generated occurrence ID.
value_countsize_tin
Number of supplied terms, from zero through three.
expires_atuint64_tin
Absolute deadline in caller-defined units. Insertion does not advance time. It does not expire other entries.
Outputs

Written on success.

out_occurrenceuint32_t *out
Optional destination for the generated occurrence ID; unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_window();
uint32_t id = 0;
maelys_datalog_status_t status = maelys_datalog_window_push_until(window, "access", terms, 2, 10, &id, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("occurrence id: %" PRIu32 "\n", id);
status: ok
occurrence id: 0

window_expire()

C · functionSince v0.13.0
window_expire()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_expire(
maelys_datalog_window_t *window,
uint64_t now,
size_t *out_expired,
maelys_datalog_diagnostic_t *out_diagnostic
);
Expire all entries whose deadlines are at or before the caller-supplied time.
Arguments
windowmaelys_datalog_window_t *handlemodified
Single-fact event window (maelys_datalog_window_t) to modify by removing timed events and committing the supplied watermark.
nowuint64_tin
Caller-supplied expiration watermark. It may stay equal to, but not precede, the last committed watermark.
Outputs

Written on success.

out_expiredsize_t *out
Optional destination for the number of expired events. Unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK after committing the watermark and any required recomputation. Failure preserves the committed watermark, facts, result and cursor. Returns UNSUPPORTED when expiration metadata was not enabled.

Example
populate_window();
size_t expired = 0;
maelys_datalog_status_t status = maelys_datalog_window_expire(window, 10, &expired, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("events expired: %zu\n", expired);
status: ok
events expired: 1

window_replace_static()

C · functionSince v0.13.0
window_replace_static()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_replace_static(
maelys_datalog_window_t *window,
const maelys_datalog_fact_t *facts,
size_t fact_count,
maelys_datalog_diagnostic_t *out_diagnostic
);
Replace all static facts and recompute the result without consuming an event ID.
Arguments
windowmaelys_datalog_window_t *handlemodified
Single-fact event window (maelys_datalog_window_t) whose complete static input is replaced and recomputed.
factsconst maelys_datalog_fact_t *in
Complete facts copied before a successful return; NULL is valid when fact_count is zero.
fact_countsize_tin
Number of complete input facts, counting raw contributions before deduplication.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_window();
maelys_datalog_status_t status = maelys_datalog_window_replace_static(window, static_facts,
    sizeof(static_facts) / sizeof(static_facts[0]), &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
check_status(maelys_datalog_window_static_facts(window, &stored, &count));
printf("static facts: %zu\n", count);
status: ok
static facts: 1

window_result()

C · functionSince v0.8.0
window_result()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_result(
const maelys_datalog_window_t *window,
maelys_datalog_result_t **out_result
);
Borrow the latest result; the window retains ownership of its lease.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_resultmaelys_datalog_result_t **out
Receives the latest borrowed result owned by the single-fact event window. Do not call result_free() on this lease. Its lifetime follows the invalidation rules in the return description.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_window();
maelys_datalog_result_t *result = NULL;
maelys_datalog_status_t status = maelys_datalog_window_result(window, &result);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("distinct observed pairs: %zu\n", observed_count(result));
status: ok
distinct observed pairs: 1

window_events()

C · functionSince v0.8.0
window_events()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_events(
const maelys_datalog_window_t *window,
const maelys_datalog_fact_t **out_facts,
size_t *out_count
);
Borrow retained events in arrival order, including their generated occurrence IDs.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_factsconst maelys_datalog_fact_t **out
Receives a borrowed array of ordered retained events, including generated occurrence IDs. Its lifetime follows the invalidation rules in the return description.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_window();
const maelys_datalog_fact_t *events = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_window_events(window, &events, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("events: %zu\n", count);
printf("first event predicate: %s\n", events[0].predicate);
status: ok
events: 2
first event predicate: access

window_state()

C · functionSince v0.8.0
window_state()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_state(
const maelys_datalog_window_t *window,
size_t *out_count,
uint64_t *out_next_occurrence
);
Read the retained event count and the next occurrence ID.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_countsize_t *out
Receives the number of entries in the returned view.
out_next_occurrenceuint64_t *out
Receives the next occurrence ID. Receives INT32_MAX + 1 after exhaustion.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_window();
size_t count = 0;
uint64_t next = 0;
maelys_datalog_status_t status = maelys_datalog_window_state(window, &count, &next);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("events: %zu\n", count);
printf("next occurrence id: %" PRIu64 "\n", next);
status: ok
events: 2
next occurrence id: 2

window_text_usage()

C · functionSince v0.8.0
window_text_usage()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_text_usage(
const maelys_datalog_window_t *window,
size_t *out_used,
size_t *out_capacity
);
Read the interned text used by committed input and its per-bank capacity.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_usedsize_t *out
Receives interned predicate and symbol bytes in committed input, including terminating NUL bytes.
out_capacitysize_t *out
Receives the text capacity of one input bank.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_window();
size_t used = 0, capacity = 0;
maelys_datalog_status_t status = maelys_datalog_window_text_usage(window, &used, &capacity);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("committed text bytes: %zu\n", used);
printf("text capacity: %zu\n", capacity);
status: ok
committed text bytes: 25
text capacity: 512

window_static_facts()

C · functionSince v0.13.0
window_static_facts()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_static_facts(
const maelys_datalog_window_t *window,
const maelys_datalog_fact_t **out_facts,
size_t *out_count
);
Borrow the committed static facts without changing the window.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_factsconst maelys_datalog_fact_t **out
Receives a borrowed array of ordered raw static facts, including duplicates. Its lifetime follows the invalidation rules in the return description.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
create_window();
check_status(maelys_datalog_window_replace_static(window, static_facts, 1, &diagnostic));
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_window_static_facts(window, &stored, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("static facts: %zu\n", count);
status: ok
static facts: 1

window_expiry_watermark()

C · functionSince v0.13.0
window_expiry_watermark()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_expiry_watermark(
const maelys_datalog_window_t *window,
uint64_t *out_now,
int *out_has_now
);
Read the last time committed by an explicit expiration call.
Arguments
windowconst maelys_datalog_window_t *handleread
Single-fact event window (maelys_datalog_window_t) to read without changing its committed input.
Outputs

Written on success.

out_nowuint64_t *out
Receives the last committed expiration watermark. Receives zero before the first explicit expiration.
out_has_nowint *out
Receives whether an expiration watermark has been committed.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed watermark state. Returns UNSUPPORTED when expiration metadata was not enabled; outputs remain unchanged on failure.

Example
populate_window();
check_status(maelys_datalog_window_expire(window, 10, NULL, &diagnostic));
uint64_t now = 0;
int has_now = 0;
maelys_datalog_status_t status = maelys_datalog_window_expiry_watermark(window, &now, &has_now);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("watermark set: %s\n", has_now ? "yes" : "no");
printf("watermark: %" PRIu64 "\n", now);
status: ok
watermark set: yes
watermark: 10

Release

window_free()

C · functionSince v0.8.0
window_free()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_window_free(
maelys_datalog_window_t *window
);
Release the current result and return the borrowed sessions without freeing caller storage.
Arguments
windowmaelys_datalog_window_t *handlereleased
Single-fact event window (maelys_datalog_window_t) to release, returning its borrowed sessions to the caller. Its arena must remain alive and unmodified during release.
Return status

maelys_datalog_status_t — OK on success.

Returns OK after releasing the current result and returning both sessions. A live prepared explanation or result-release failure leaves the window usable; a closed handle returns INVALID_STATE while its arena remains intact.

Example
create_window();
maelys_datalog_status_t status = maelys_datalog_window_free(window);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
window = NULL;

Handle: group_window_t

C · handleSince v0.9.0
group_window_t

#include <maelys/datalog_window.h>

typedef struct maelys_datalog_group_window maelys_datalog_group_window_t;
Retains the last accepted groups of complete facts and their current solved snapshot.

Creation

group_window_storage_requirements()

C · functionSince v0.9.0
group_window_storage_requirements()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_storage_requirements(
const maelys_datalog_group_window_capacities_t *capacities,
size_t *out_bytes,
size_t *out_alignment
);
Measure the caller-owned storage for a multi-fact event window.
Arguments
capacitiesconst maelys_datalog_group_window_capacities_t *in
Requested group, raw-contribution, unique-fact and per-bank text bounds; copied during initialization.
Outputs

Written on success.

out_bytessize_t *out
Receives the required caller-owned arena size; measure it at run time rather than hard-coding a size.
out_alignmentsize_t *out
Receives the required arena alignment; measure it at run time rather than hard-coding an alignment.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the required size and alignment. Invalid capacities or arguments are rejected; outputs remain unchanged on failure.

Example
size_t bytes = 0, alignment = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_storage_requirements(&capacities, &bytes, &alignment);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("storage required: %s\n", bytes > 0 ? "yes" : "no");
printf("alignment is a power of two: %s\n",
    alignment > 0 && (alignment & (alignment - 1)) == 0 ? "yes" : "no");
status: ok
storage required: yes
alignment is a power of two: yes

group_window_init()

C · functionSince v0.9.0
group_window_init()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_init(
void *storage,
size_t storage_bytes,
const maelys_datalog_group_window_capacities_t *capacities,
uint32_t first_group,
maelys_datalog_session_t *session_a,
maelys_datalog_session_t *session_b,
maelys_datalog_group_window_t **out_window,
maelys_datalog_diagnostic_t *out_diagnostic
);
Initialize a multi-fact window in caller-owned storage and borrow two idle sessions.
Arguments
storagevoid *in/out
Aligned caller-owned arena, kept exclusive, alive and immovable until the window is released.
storage_bytessize_tin
Number of bytes available in the caller-owned arena.
capacitiesconst maelys_datalog_group_window_capacities_t *in
Requested group, raw-contribution, unique-fact and per-bank text bounds; copied during initialization.
first_groupuint32_tin
First generated group ID, from zero through INT32_MAX.
session_amaelys_datalog_session_t *in
First idle session, borrowed exclusively by the window until release.
session_bmaelys_datalog_session_t *in
Second distinct idle session, with the same execution fingerprint as the first, borrowed until release.
Outputs

Written on success.

out_windowmaelys_datalog_group_window_t **out
Receives the initialized maelys_datalog_group_window_t handle. Receives NULL if initialization fails.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK with an initialized window and its empty-input result. Initialization can fail while solving empty input; no window is created on failure.

Example
size_t bytes = 0, alignment = 0;
check_status(maelys_datalog_group_window_storage_requirements(&capacities, &bytes, &alignment));
group_storage = allocate_storage(bytes, alignment);
maelys_datalog_status_t status = maelys_datalog_group_window_init(group_storage, bytes, &capacities, 0,
    sessions[2], sessions[3], &group_window, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("window initialized: %s\n", group_window != NULL ? "yes" : "no");
status: ok
window initialized: yes

group_window_storage_requirements_configured()

C · functionSince v0.13.0
group_window_storage_requirements_configured()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_storage_requirements_configured(
const maelys_datalog_group_window_capacities_t *capacities,
const maelys_datalog_window_options_t *options,
size_t *out_bytes,
size_t *out_alignment
);
Measure the caller-owned storage for a multi-fact event window with static input or expiration options.
Arguments
capacitiesconst maelys_datalog_group_window_capacities_t *in
Requested group, raw-contribution, unique-fact and per-bank text bounds; copied during initialization.
optionsconst maelys_datalog_window_options_t *in
Optional configuration of static fact capacity and expiration metadata. Initialize every member, including struct_size.
Outputs

Written on success.

out_bytessize_t *out
Receives the required caller-owned arena size; measure it at run time rather than hard-coding a size.
out_alignmentsize_t *out
Receives the required arena alignment; measure it at run time rather than hard-coding an alignment.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the required size and alignment. Invalid capacities or arguments are rejected; outputs remain unchanged on failure.

Example
size_t bytes = 0, alignment = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_storage_requirements_configured(&capacities, &options, &bytes, &alignment);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("storage required: %s\n", bytes > 0 ? "yes" : "no");
printf("alignment is a power of two: %s\n",
    alignment > 0 && (alignment & (alignment - 1)) == 0 ? "yes" : "no");
status: ok
storage required: yes
alignment is a power of two: yes

group_window_init_configured()

C · functionSince v0.13.0
group_window_init_configured()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_init_configured(
void *storage,
size_t storage_bytes,
const maelys_datalog_group_window_capacities_t *capacities,
const maelys_datalog_window_options_t *options,
uint32_t first_group,
maelys_datalog_session_t *session_a,
maelys_datalog_session_t *session_b,
maelys_datalog_group_window_t **out_window,
maelys_datalog_diagnostic_t *out_diagnostic
);
Initialize a multi-fact window in caller-owned storage and borrow two idle sessions with the selected options.
Arguments
storagevoid *in/out
Aligned caller-owned arena, kept exclusive, alive and immovable until the window is released.
storage_bytessize_tin
Number of bytes available in the caller-owned arena.
capacitiesconst maelys_datalog_group_window_capacities_t *in
Requested group, raw-contribution, unique-fact and per-bank text bounds; copied during initialization.
optionsconst maelys_datalog_window_options_t *in
Optional configuration of static fact capacity and expiration metadata. Initialize every member, including struct_size.
first_groupuint32_tin
First generated group ID, from zero through INT32_MAX.
session_amaelys_datalog_session_t *in
First idle session, borrowed exclusively by the window until release.
session_bmaelys_datalog_session_t *in
Second distinct idle session, with the same execution fingerprint as the first, borrowed until release.
Outputs

Written on success.

out_windowmaelys_datalog_group_window_t **out
Receives the initialized maelys_datalog_group_window_t handle. Receives NULL if initialization fails.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK with an initialized window and its empty-input result. Initialization can fail while solving empty input; no window is created on failure.

Example
size_t bytes = 0, alignment = 0;
check_status(maelys_datalog_group_window_storage_requirements_configured(&capacities, &options, &bytes, &alignment));
group_storage = allocate_storage(bytes, alignment);
maelys_datalog_status_t status = maelys_datalog_group_window_init_configured(group_storage, bytes, &capacities, &options, 0,
    sessions[2], sessions[3], &group_window, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("window initialized: %s\n", group_window != NULL ? "yes" : "no");
status: ok
window initialized: yes

Functions

group_window_push()

C · functionSince v0.9.0
group_window_push()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_push(
maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t *facts,
size_t fact_count,
uint32_t *out_group_id,
maelys_datalog_diagnostic_t *out_diagnostic
);
Append a complete group of facts, expiring the oldest entry when the window is full.
Arguments
windowmaelys_datalog_group_window_t *handlemodified
Multi-fact group window (maelys_datalog_group_window_t) to modify by appending the new group of complete facts.
factsconst maelys_datalog_fact_t *in
Complete facts copied before a successful return; NULL is valid when fact_count is zero.
fact_countsize_tin
Number of complete input facts, counting raw contributions before deduplication.
Outputs

Written on success.

out_group_iduint32_t *out
Optional destination for the accepted group ID; unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_group_window();
uint32_t id = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_push(group_window, facts, sizeof(facts) / sizeof(facts[0]), &id, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("group id: %" PRIu32 "\n", id);

group_window_push_until()

C · functionSince v0.13.0
group_window_push_until()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_push_until(
maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t *facts,
size_t fact_count,
uint64_t expires_at,
uint32_t *out_group_id,
maelys_datalog_diagnostic_t *out_diagnostic
);
Append a complete group of facts and an explicit expiration deadline.
Arguments
windowmaelys_datalog_group_window_t *handlemodified
Multi-fact group window (maelys_datalog_group_window_t) to modify by appending the new group of complete facts.
factsconst maelys_datalog_fact_t *in
Complete facts copied before a successful return; NULL is valid when fact_count is zero.
fact_countsize_tin
Number of complete input facts, counting raw contributions before deduplication.
expires_atuint64_tin
Absolute deadline in caller-defined units. Insertion does not advance time. It does not expire other entries.
Outputs

Written on success.

out_group_iduint32_t *out
Optional destination for the accepted group ID; unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_group_window();
uint32_t id = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_push_until(group_window, facts, sizeof(facts) / sizeof(facts[0]), 10, &id, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("group id: %" PRIu32 "\n", id);

group_window_expire()

C · functionSince v0.13.0
group_window_expire()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_expire(
maelys_datalog_group_window_t *window,
uint64_t now,
size_t *out_expired,
maelys_datalog_diagnostic_t *out_diagnostic
);
Expire all entries whose deadlines are at or before the caller-supplied time.
Arguments
windowmaelys_datalog_group_window_t *handlemodified
Multi-fact group window (maelys_datalog_group_window_t) to modify by removing timed groups and committing the supplied watermark.
nowuint64_tin
Caller-supplied expiration watermark. It may stay equal to, but not precede, the last committed watermark.
Outputs

Written on success.

out_expiredsize_t *out
Optional destination for the number of expired groups. Unchanged on failure.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK after committing the watermark and any required recomputation. Failure preserves the committed watermark, facts, result and cursor. Returns UNSUPPORTED when expiration metadata was not enabled.

Example
populate_group_window();
size_t expired = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_expire(group_window, 10, &expired, &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("groups expired: %zu\n", expired);
status: ok
groups expired: 1

group_window_replace_static()

C · functionSince v0.13.0
group_window_replace_static()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_replace_static(
maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t *facts,
size_t fact_count,
maelys_datalog_diagnostic_t *out_diagnostic
);
Replace all static facts and recompute the result without consuming an event ID.
Arguments
windowmaelys_datalog_group_window_t *handlemodified
Multi-fact group window (maelys_datalog_group_window_t) whose complete static input is replaced and recomputed.
factsconst maelys_datalog_fact_t *in
Complete facts copied before a successful return; NULL is valid when fact_count is zero.
fact_countsize_tin
Number of complete input facts, counting raw contributions before deduplication.

out_diagnostic: optional diagnostic details on failure; pass NULL when not needed.

Return status

maelys_datalog_status_t — OK on success.

Returns OK only after publishing the complete new snapshot. Failure preserves the previously committed input, result and ID cursor; inputs are copied before a successful return.

Example
create_group_window();
maelys_datalog_status_t status = maelys_datalog_group_window_replace_static(group_window, static_facts,
    sizeof(static_facts) / sizeof(static_facts[0]), &diagnostic);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
check_status(maelys_datalog_group_window_static_facts(group_window, &stored, &count));
printf("static facts: %zu\n", count);
status: ok
static facts: 1

group_window_result()

C · functionSince v0.9.0
group_window_result()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_result(
const maelys_datalog_group_window_t *window,
maelys_datalog_result_t **out_result
);
Borrow the latest result; the window retains ownership of its lease.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_resultmaelys_datalog_result_t **out
Receives the latest borrowed result owned by the multi-fact group window. Do not call result_free() on this lease. Its lifetime follows the invalidation rules in the return description.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_group_window();
maelys_datalog_result_t *result = NULL;
maelys_datalog_status_t status = maelys_datalog_group_window_result(group_window, &result);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("alice may access roadmap.pdf: %s\n", allows_alice(result) ? "yes" : "no");
status: ok
alice may access roadmap.pdf: yes

group_window_groups()

C · functionSince v0.9.0
group_window_groups()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_groups(
const maelys_datalog_group_window_t *window,
const maelys_datalog_event_group_t **out_groups,
size_t *out_count
);
Borrow retained group metadata and the slices into its contribution view.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_groupsconst maelys_datalog_event_group_t **out
Receives a borrowed group array whose slices address the ordered contribution view.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_group_window();
const maelys_datalog_event_group_t *groups = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_groups(group_window, &groups, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("groups: %zu\n", count);
printf("first group contributions: %zu\n", groups[0].fact_count);
status: ok
groups: 2
first group contributions: 2

group_window_contributions()

C · functionSince v0.9.0
group_window_contributions()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_contributions(
const maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t **out_facts,
size_t *out_count
);
Borrow the retained raw contributions, including duplicate facts.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_factsconst maelys_datalog_fact_t **out
Receives a borrowed array of ordered raw contributions, including duplicate facts. Its lifetime follows the invalidation rules in the return description.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_group_window();
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_contributions(group_window, &stored, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("contributions: %zu\n", count);
status: ok
contributions: 4

group_window_facts()

C · functionSince v0.9.0
group_window_facts()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_facts(
const maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t **out_facts,
size_t *out_count
);
Borrow the sorted unique union of committed event and static facts.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_factsconst maelys_datalog_fact_t **out
Receives a borrowed array of sorted unique union of event and static facts. Its lifetime follows the invalidation rules in the return description.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_group_window();
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_facts(group_window, &stored, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("unique facts: %zu\n", count);
status: ok
unique facts: 2

group_window_state()

C · functionSince v0.9.0
group_window_state()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_state(
const maelys_datalog_group_window_t *window,
maelys_datalog_group_window_usage_t *out_usage
);
Read committed group, contribution and unique-fact occupancy.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_usagemaelys_datalog_group_window_usage_t *out
Receives the committed occupancy and next group ID, rather than an attempt peak.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
populate_group_window();
maelys_datalog_group_window_usage_t usage;
maelys_datalog_status_t status = maelys_datalog_group_window_state(group_window, &usage);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("groups: %zu\n", usage.groups);
printf("contributions: %zu\n", usage.contributions);
printf("unique facts: %zu\n", usage.unique_facts);
status: ok
groups: 2
contributions: 4
unique facts: 2

group_window_static_facts()

C · functionSince v0.13.0
group_window_static_facts()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_static_facts(
const maelys_datalog_group_window_t *window,
const maelys_datalog_fact_t **out_facts,
size_t *out_count
);
Borrow the committed static facts without changing the window.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_factsconst maelys_datalog_fact_t **out
Receives a borrowed array of ordered raw static facts, including duplicates. Its lifetime follows the invalidation rules in the return description.
out_countsize_t *out
Receives the number of entries in the returned view.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed state or borrowed view. Outputs remain unchanged on failure. Successful pushes, static-input replacements, expiration that removes entries, and release invalidate borrowed results and views. Expiration with no due entry advances only the watermark and preserves them.

Example
create_group_window();
check_status(maelys_datalog_group_window_replace_static(group_window, static_facts, 1, &diagnostic));
const maelys_datalog_fact_t *stored = NULL;
size_t count = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_static_facts(group_window, &stored, &count);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("static facts: %zu\n", count);
status: ok
static facts: 1

group_window_expiry_watermark()

C · functionSince v0.13.0
group_window_expiry_watermark()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_expiry_watermark(
const maelys_datalog_group_window_t *window,
uint64_t *out_now,
int *out_has_now
);
Read the last time committed by an explicit expiration call.
Arguments
windowconst maelys_datalog_group_window_t *handleread
Multi-fact group window (maelys_datalog_group_window_t) to read without changing its committed input.
Outputs

Written on success.

out_nowuint64_t *out
Receives the last committed expiration watermark. Receives zero before the first explicit expiration.
out_has_nowint *out
Receives whether an expiration watermark has been committed.
Return status

maelys_datalog_status_t — OK on success.

Returns OK with the committed watermark state. Returns UNSUPPORTED when expiration metadata was not enabled; outputs remain unchanged on failure.

Example
populate_group_window();
check_status(maelys_datalog_group_window_expire(group_window, 10, NULL, &diagnostic));
uint64_t now = 0;
int has_now = 0;
maelys_datalog_status_t status = maelys_datalog_group_window_expiry_watermark(group_window, &now, &has_now);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
printf("watermark set: %s\n", has_now ? "yes" : "no");
printf("watermark: %" PRIu64 "\n", now);
status: ok
watermark set: yes
watermark: 10

Release

group_window_free()

C · functionSince v0.9.0
group_window_free()

#include <maelys/datalog_window.h>

maelys_datalog_status_t
maelys_datalog_group_window_free(
maelys_datalog_group_window_t *window
);
Release the current result and return the borrowed sessions without freeing caller storage.
Arguments
windowmaelys_datalog_group_window_t *handlereleased
Multi-fact group window (maelys_datalog_group_window_t) to release, returning its borrowed sessions to the caller. Its arena must remain alive and unmodified during release.
Return status

maelys_datalog_status_t — OK on success.

Returns OK after releasing the current result and returning both sessions. A live prepared explanation or result-release failure leaves the window usable; a closed handle returns INVALID_STATE while its arena remains intact.

Example
create_group_window();
maelys_datalog_status_t status = maelys_datalog_group_window_free(group_window);
printf("status: %s\n", maelys_datalog_status_name(status));
check_status(status);
group_window = NULL;

Struct: window_options_t

C · structSince v0.13.0
window_options_t

#include <maelys/datalog_window.h>

Reserves optional static input and deadline storage when creating either window adapter.
Fields
struct_sizesize_t
Set to sizeof(maelys_datalog_window_options_t); initialize every member before passing the options.
static_fact_capacitysize_t
Maximum raw static facts, counting duplicates, reserved in addition to event slots or event contributions.
flagsuint32_t
Set to zero or MAELYS_DATALOG_WINDOW_EXPIRATION. Other bits are rejected; the expiration flag reserves deadline storage.
Typedef
typedef struct {
    size_t struct_size;
    size_t static_fact_capacity; /* Raw static slots in addition to event slots. */
    uint32_t flags;
} maelys_datalog_window_options_t;

Constants

Expiration option

WINDOW_EXPIRATION

C · constantSince v0.13.0
WINDOW_EXPIRATION
#define MAELYS_DATALOG_WINDOW_EXPIRATION 1u

Reserve per-event or per-group deadline metadata in both caller-owned input banks. Set this flag in window_options_t.flags before initialization to enable explicit expiration.

Value

1

Struct: group_window_capacities_t

C · structSince v0.9.0
group_window_capacities_t

#include <maelys/datalog_window.h>

Sets separate bounds for retained groups, raw contributions, unique facts and text.
Fields
groupssize_t
Maximum retained groups, from 1 through INT32_MAX + 1; empty groups also occupy a slot.
contributionssize_t
Maximum raw event contributions before deduplication, from 1 through the loaded MAX_EDB_FACTS bound.
unique_factssize_t
Maximum distinct combined runtime input facts. Without static input this is at most contributions; configured static input may raise it to contributions + static_fact_capacity.
text_bytessize_t
Interned predicate and symbol bytes per input bank, including NUL terminators; event and static input share this capacity.
Typedef
typedef struct {
    size_t groups;        /* 1..INT32_MAX+1; independent of fact capacities. */
    size_t contributions; /* 1..loaded MAX_EDB_FACTS, BEFORE deduplication. */
    size_t unique_facts;  /* 1..contributions; runtime union, excluding policy/IDB. */
    size_t text_bytes;    /* Per bank, input_edb's interned text capacity. */
} maelys_datalog_group_window_capacities_t;

Struct: event_group_t

C · structSince v0.9.0
event_group_t

#include <maelys/datalog_window.h>

Identifies a retained group and its slice of the ordered event contributions.
Fields
iduint32_t
Generated group identifier, kept as adapter metadata rather than inserted into the facts.
fact_offsetsize_t
Starting index of this group in the ordered event-contributions view.
fact_countsize_t
Number of raw contributions in this group, including duplicates; an empty group has zero.
Typedef
typedef struct {
    uint32_t id;
    size_t fact_offset;   /* Slice of the committed contributions view. */
    size_t fact_count;    /* Includes duplicates; zero is a valid group. */
} maelys_datalog_event_group_t;

Struct: group_window_usage_t

C · structSince v0.9.0
group_window_usage_t

#include <maelys/datalog_window.h>

Reports the committed groups, contributions, unique facts and text use.
Fields
groupssize_t
Number of committed retained groups, including empty groups.
contributionssize_t
Number of raw retained event contributions, including duplicates and excluding static input.
unique_factssize_t
Number of distinct facts in the combined event and static input union, excluding policy facts and derived facts.
text_bytessize_t
Committed interned predicate and symbol bytes, including NUL terminators and both event and static input.
next_groupuint64_t
Next generated group identifier; INT32_MAX + 1 means that the identifier sequence is exhausted.
Typedef
typedef struct {
    size_t groups;
    size_t contributions;
    size_t unique_facts;
    size_t text_bytes;    /* Interned predicate/symbol bytes, including NULs. */
    uint64_t next_group;  /* INT32_MAX+1 denotes exhaustion. */
} maelys_datalog_group_window_usage_t;

Usage guides