|
ZephyrDB
Embedded database for Zephyr RTOS: KV, time-series, and document models
|
ZephyrDB public API. More...
#include <stdbool.h>#include <stddef.h>#include <stdint.h>#include <zephyr/kernel.h>#include <zephyr/sys/util.h>Go to the source code of this file.
Classes | |
| struct | zdb_bytes_t |
| Immutable byte span (pointer + length). More... | |
| struct | zdb_ts_stats_t |
| Time-series durability counters (see zdb_ts_stats_get()). More... | |
| struct | zdb_ts_stats_export_t |
| Compact, packed telemetry export of zdb_ts_stats_t for transport or logging. More... | |
| struct | zdb_kv_event_t |
| Payload delivered to KV event listeners. More... | |
| struct | zdb_event_listener_t |
| KV event listener registration entry. More... | |
| struct | zdb_ts_event_t |
| Payload delivered to time-series event listeners. More... | |
| struct | zdb_ts_event_listener_t |
| Time-series event listener registration entry. More... | |
| struct | zdb_doc_event_t |
| Payload delivered to document event listeners. More... | |
| struct | zdb_doc_event_listener_t |
| Document event listener registration entry. More... | |
| struct | zdb_core_event_t |
| Payload delivered to core event listeners. More... | |
| struct | zdb_core_event_listener_t |
| Core event listener registration entry. More... | |
| struct | zdb_kv_default_t |
| One entry in a key-value defaults table. More... | |
| struct | zdb_cfg_t |
| Instance configuration passed to zdb_init(). More... | |
| struct | zdb_t |
| Database instance. More... | |
| struct | zdb_cursor |
| Cursor for cooperative scans (currently opened via zdb_ts_cursor_open()). More... | |
| struct | zdb_kv_t |
| Open handle to one KV namespace (see zdb_kv_open()). More... | |
| struct | zdb_kv_iter_t |
| KV iterator state (see zdb_kv_iter_open()). More... | |
| struct | zdb_ts_t |
| Open handle to one time-series stream (see zdb_ts_open()). More... | |
| struct | zdb_ts_sample_i64_t |
| One int64 sample: timestamp + value. More... | |
| struct | zdb_ts_window_t |
| Inclusive timestamp window for queries and cursors. More... | |
| struct | zdb_ts_agg_result_t |
| Result of zdb_ts_query_aggregate(). More... | |
| union | zdb_doc_field_value_t |
| Field value storage; the active member follows zdb_doc_field_type_t. More... | |
| struct | zdb_doc_field_t |
| One named, typed document field. More... | |
| struct | zdb_doc |
| In-memory document handle. More... | |
| struct | zdb_doc_query_filter_t |
| One equality filter for zdb_doc_query(); filters AND-combine. More... | |
| struct | zdb_doc_query_t |
| Query description for zdb_doc_query(). More... | |
| struct | zdb_doc_metadata_t |
| Per-document metadata produced by zdb_doc_query(). More... | |
| struct | zdb_doc_manifest_entry_t |
| One (collection, document) pair in a collection manifest. More... | |
Macros | |
| #define | ZDB_VERSION_MAJOR 0 |
| Major version of this library. | |
| #define | ZDB_VERSION_MINOR 7 |
| Minor version of this library. | |
| #define | ZDB_VERSION_PATCH 0 |
| Patch version of this library. | |
| #define | ZDB_VERSION_STRING "0.7.0" |
| Version as a printable "MAJOR.MINOR.PATCH" string. | |
| #define | ZDB_ALIGN_UP(value, align) |
Round value up to the next multiple of align. | |
| #define | ZDB_MEM_SLAB_DEFINE(name, block_size, block_count, align) |
| Declare a static memory slab with build-time size validation. | |
| #define | ZDB_DEFINE_CORE_SLAB(name) |
Declare the core-context slab, sized by CONFIG_ZDB_CORE_SLAB_BLOCK_SIZE / _COUNT. | |
| #define | ZDB_DEFINE_CURSOR_SLAB(name) |
Declare the cursor slab, sized by CONFIG_ZDB_CURSOR_SLAB_BLOCK_SIZE / _COUNT. | |
| #define | ZDB_DEFINE_KV_IO_SLAB(name) |
Declare the KV I/O slab, sized by CONFIG_ZDB_KV_IO_SLAB_BLOCK_SIZE / _COUNT. | |
| #define | ZDB_DEFINE_TS_INGEST_SLAB(name) |
Declare the time-series ingest slab, sized by CONFIG_ZDB_TS_INGEST_SLAB_BLOCK_SIZE / _COUNT. | |
| #define | ZDB_DEFINE_STATIC(db_name, cfg_name) |
| Declare a static zdb_t wired to Kconfig-sized slabs. | |
| #define | ZDB_TS_WINDOW_ALL ((zdb_ts_window_t){.from_ts_ms = 0, .to_ts_ms = UINT64_MAX}) |
| A zdb_ts_window_t covering all possible timestamps. | |
Typedefs | |
| typedef bool(* | zdb_predicate_fn) (zdb_model_t model, const zdb_bytes_t *record, void *user_ctx) |
| Record filter callback for cursor scans. | |
| typedef struct zdb_cursor | zdb_cursor_t |
| Cursor for cooperative scans (currently opened via zdb_ts_cursor_open()). | |
| typedef struct zdb_doc | zdb_doc_t |
| In-memory document handle. | |
Functions | |
| zdb_status_t | zdb_init (zdb_t *db, const zdb_cfg_t *cfg) |
| Initialize a database instance. | |
| zdb_status_t | zdb_deinit (zdb_t *db) |
| Tear down an instance and release all module state. | |
| zdb_health_t | zdb_health (const zdb_t *db) |
| Report the instance's current health. | |
| const char * | zdb_status_str (zdb_status_t status) |
| Return a short printable name for a status code. | |
| const char * | zdb_health_str (zdb_health_t health) |
| Return a short printable name for a health value. | |
| void | zdb_ts_stats_get (const zdb_t *db, zdb_ts_stats_t *out_stats) |
| Copy the live time-series durability counters. | |
| void | zdb_ts_stats_reset (zdb_t *db) |
| Reset the time-series durability counters to zero. | |
| zdb_status_t | zdb_ts_stats_export (const zdb_t *db, zdb_ts_stats_export_t *out_export) |
| Fill a packed, CRC-protected telemetry export of the TS stats. | |
| zdb_status_t | zdb_ts_stats_export_validate (const zdb_ts_stats_export_t *export_data) |
| Validate a received telemetry export record. | |
| zdb_status_t | zdb_cursor_reset (zdb_cursor_t *cursor) |
| Rewind a cursor to the start of its scan. | |
| zdb_status_t | zdb_cursor_close (zdb_cursor_t *cursor) |
| Close a cursor and release its slab allocation. | |
| zdb_status_t | zdb_kv_open (zdb_t *db, const char *namespace_name, zdb_kv_t *kv) |
| Open a namespace handle. | |
| zdb_status_t | zdb_kv_close (zdb_kv_t *kv) |
| Close a namespace handle. | |
| zdb_status_t | zdb_kv_set (zdb_kv_t *kv, const char *key, const void *value, size_t value_len) |
| Store (create or overwrite) a value under a key. | |
| zdb_status_t | zdb_kv_get (zdb_kv_t *kv, const char *key, void *out_value, size_t out_capacity, size_t *out_len) |
| Read the value stored under a key. | |
| zdb_status_t | zdb_kv_set_str (zdb_kv_t *kv, const char *key, const char *value) |
| Store a NUL-terminated string. | |
| zdb_status_t | zdb_kv_defaults_apply (zdb_t *db) |
| Write any missing entries of the configured defaults table. | |
| zdb_status_t | zdb_kv_reset_namespace (zdb_kv_t *kv) |
| Delete every key in a namespace, then re-apply its defaults. | |
| zdb_status_t | zdb_kv_get_str (zdb_kv_t *kv, const char *key, char *out_str, size_t out_capacity, size_t *out_len) |
| Read a value as a NUL-terminated string. | |
| zdb_status_t | zdb_kv_delete (zdb_kv_t *kv, const char *key) |
| Delete the record stored under a key. | |
| zdb_status_t | zdb_kv_iter_open (zdb_kv_t *kv, zdb_kv_iter_t *out_iter) |
| Open an iterator over the namespace's keys. | |
| zdb_status_t | zdb_kv_iter_next (zdb_kv_iter_t *iter, char *out_key, size_t out_key_capacity, size_t *out_key_len, void *out_value, size_t out_value_capacity, size_t *out_value_len) |
| Fetch the next key (and its value) from an iterator. | |
| zdb_status_t | zdb_kv_iter_close (zdb_kv_iter_t *iter) |
| Close an iterator. | |
| zdb_status_t | zdb_ts_open (zdb_t *db, const char *stream_name, zdb_ts_t *ts) |
| Open a stream for appending and reading. | |
| zdb_status_t | zdb_ts_close (zdb_ts_t *ts) |
| Close a stream handle and release its slot. | |
| zdb_status_t | zdb_ts_append_i64 (zdb_ts_t *ts, const zdb_ts_sample_i64_t *sample) |
| Append one sample to the stream's ingest buffer. | |
| zdb_status_t | zdb_ts_append_batch_i64 (zdb_ts_t *ts, const zdb_ts_sample_i64_t *samples, size_t sample_count) |
| Append a batch of samples. | |
| zdb_status_t | zdb_ts_flush_async (zdb_ts_t *ts) |
| Queue an asynchronous flush of the ingest buffer. | |
| zdb_status_t | zdb_ts_flush_sync (zdb_ts_t *ts, k_timeout_t timeout) |
| Flush the ingest buffer and wait for completion. | |
| zdb_status_t | zdb_ts_query_aggregate (zdb_ts_t *ts, zdb_ts_window_t window, zdb_ts_agg_t agg, zdb_ts_agg_result_t *out_result) |
| Compute an aggregate over samples in a time window. | |
| zdb_status_t | zdb_ts_recover_stream (zdb_ts_t *ts, size_t *out_truncated_bytes) |
| Scan the stream's storage and truncate a corrupt tail. | |
| zdb_status_t | zdb_ts_cursor_open (zdb_ts_t *ts, zdb_ts_window_t window, zdb_predicate_fn predicate, void *predicate_ctx, zdb_cursor_t *out_cursor) |
| Open a cursor over the stream's samples. | |
| zdb_status_t | zdb_ts_cursor_open_desc (zdb_ts_t *ts, zdb_ts_window_t window, zdb_predicate_fn predicate, void *predicate_ctx, zdb_cursor_t *out_cursor) |
| Open a cursor that walks the stream newest-first. | |
| zdb_status_t | zdb_ts_watermark_set (zdb_ts_t *ts, uint64_t consumed_ts_ms) |
| Record how far a consumer has processed a stream. | |
| zdb_status_t | zdb_ts_watermark_get (zdb_ts_t *ts, uint64_t *out_consumed_ts_ms) |
| Read a stream's consumed watermark. | |
| zdb_status_t | zdb_ts_watermark_clear (zdb_ts_t *ts) |
| Forget a stream's consumed watermark. | |
| zdb_status_t | zdb_cursor_next (zdb_cursor_t *cursor, zdb_bytes_t *out_record) |
| Fetch the next record from a cursor. | |
| zdb_status_t | zdb_ts_cursor_next_sample (zdb_cursor_t *cursor, zdb_ts_sample_i64_t *out_sample) |
| Fetch the next sample from a time-series cursor. | |
| zdb_status_t | zdb_ts_sample_i64_export_flatbuffer (const zdb_ts_sample_i64_t *sample, uint8_t *out_buf, size_t out_capacity, size_t *out_len) |
Serialize one sample as a FlatBuffer (CONFIG_ZDB_FLATBUFFERS + CONFIG_FLATCC). | |
| zdb_status_t | zdb_doc_create (zdb_t *db, const char *collection_name, const char *document_id, zdb_doc_t *out_doc) |
| Create a new, empty document. | |
| zdb_status_t | zdb_doc_open (zdb_t *db, const char *collection_name, const char *document_id, zdb_doc_t *out_doc) |
| Load an existing document from storage. | |
| zdb_status_t | zdb_doc_save (zdb_doc_t *doc) |
| Persist a document's current fields. | |
| zdb_status_t | zdb_doc_delete (zdb_t *db, const char *collection_name, const char *document_id) |
| Delete a document from storage. | |
| zdb_status_t | zdb_doc_close (zdb_doc_t *doc) |
| Close a document handle and release its in-memory fields. | |
| zdb_status_t | zdb_doc_field_set_i64 (zdb_doc_t *doc, const char *field_name, int64_t value) |
| Set (create or replace) an INT64 field. | |
| zdb_status_t | zdb_doc_field_set_f64 (zdb_doc_t *doc, const char *field_name, double value) |
| Set (create or replace) a DOUBLE field. | |
| zdb_status_t | zdb_doc_field_set_string (zdb_doc_t *doc, const char *field_name, const char *value) |
| Set (create or replace) a STRING field. | |
| zdb_status_t | zdb_doc_field_set_bool (zdb_doc_t *doc, const char *field_name, bool value) |
| Set (create or replace) a BOOL field. | |
| zdb_status_t | zdb_doc_field_set_bytes (zdb_doc_t *doc, const char *field_name, const void *value, size_t len) |
| Set (create or replace) a BYTES field. | |
| zdb_status_t | zdb_doc_field_get_i64 (const zdb_doc_t *doc, const char *field_name, int64_t *out_value) |
| Read an INT64 field. | |
| zdb_status_t | zdb_doc_field_get_f64 (const zdb_doc_t *doc, const char *field_name, double *out_value) |
| Read a DOUBLE field. | |
| zdb_status_t | zdb_doc_field_get_string (const zdb_doc_t *doc, const char *field_name, const char **out_value) |
| Read a STRING field. | |
| zdb_status_t | zdb_doc_field_get_bool (const zdb_doc_t *doc, const char *field_name, bool *out_value) |
| Read a BOOL field. | |
| zdb_status_t | zdb_doc_field_get_bytes (const zdb_doc_t *doc, const char *field_name, zdb_bytes_t *out_value) |
| Read a BYTES field. | |
| zdb_status_t | zdb_doc_query (zdb_t *db, const zdb_doc_query_t *query, zdb_doc_metadata_t *out_metadata, size_t *out_count) |
| Query document metadata across all collections. | |
| zdb_status_t | zdb_doc_metadata_free (zdb_doc_metadata_t *metadata, size_t count) |
| Release strings owned by zdb_doc_query() results. | |
| zdb_status_t | zdb_doc_export_flatbuffer (zdb_doc_t *doc, uint8_t *out_buf, size_t out_capacity, size_t *out_len) |
| Serialize a document as a FlatBuffer for transport. | |
| void | zdb_shell_register (zdb_t *db) |
Bind an instance to the zdb shell command tree (CONFIG_ZDB_SHELL). | |
ZephyrDB public API.
Embedded database for Zephyr RTOS: Core + KV + TS + DOC + Eventing + Shell modules. Which declarations are visible depends on the enabled Kconfig options (see the per-module guards below); this generated documentation is built with every module enabled.