aboutsummaryrefslogtreecommitdiffstats
path: root/core/module-store.c
diff options
context:
space:
mode:
authoreunhhu <[email protected]>2026-10-18 19:30:16 +0100
committereunhhu <[email protected]>2026-10-18 19:30:16 +0100
commitb22b8c3f6c5378b47c36370225d7c41d4394bb7c (patch)
treed1a3cbf1b0e718f0acafa08ec6741761f08e5dd5 /core/module-store.c
parente8b3499289022c8729900a58ed218d961a85fec8 (diff)
downloadpure-b22b8c3f6c5378b47c36370225d7c41d4394bb7c.tar.gz
pure-b22b8c3f6c5378b47c36370225d7c41d4394bb7c.zip
Module format v7, 027's 4b-2: keyed documents gone, a keyed list of records holding bytes doing their work: no collections table, DOC, DOC_SIZE or REPLACE (106 opcodes now 103, those from LEN on moved up), keyed messages or a base revision (pure_app_message takes an input and a payload), no PureData document callbacks (a data host opens states and saves them together), no burst by document key; the header 38 bytes; pure-edit-module gone; pure-serve without /objects, ETag, If-Match and If-None-Match, 412 or an app a thread for a module of documents alone (one without states or outputs runs so); a hole closed: an instruction in no handler's, view's or function's block was never verified yet the load's later passes read its arguments (a damaged module read out of bounds once the header moved what the mutation test damaged), now blanked to CONST 0; checks moved: server_documents (DOCS_SOURCE, keyed byte documents with the app's revision, against a Python model, one and three connection threads, a restart) in place of the parity with editor.pure, pipelining and bursts through kill -9 on its inputs and views, the lent budget on a text view (lending a document's read is server_lent_views' already), clocks and tokens on it; message tests without a document host; the HTTP benchmark's document suite runs the earlier document server and the baselines alone; the count harness builds against either message API (runs.sh build: -DPURE_KEYED_MESSAGES before 4b); counts: b33 against b32 with batches within 0.002% but BFS -0.33%, without batches BFS +0.63%, knapsack +0.52%, join +0.38%; the bank's queries (s32 on a v6 module, s33 on v7) field +0.68%, found +0.44%, large +0.42%, the rest within 0.13%; 008 as v7, 027's 4b-2 as made and 4c designed
Diffstat (limited to 'core/module-store.c')
-rw-r--r--core/module-store.c77
1 files changed, 8 insertions, 69 deletions
diff --git a/core/module-store.c b/core/module-store.c
index 92200af..7ca2dc0 100644
--- a/core/module-store.c
+++ b/core/module-store.c
@@ -1,92 +1,31 @@
#include "module-store.h"
-static PureResult open_document(void *context, uint32_t collection, const char *key,
- void **document, int64_t *revision) {
- (void)collection; /* v2 modules have one collection: the store's key space */
- PureDraft *draft;
- PureResult result = pure_draft_open(context, key, &draft);
- if (result != PURE_OK) return result;
- pure_draft_hold(draft, true); /* values read in the event stay readable */
- *document = draft;
- *revision = pure_draft_revision(draft);
- return PURE_OK;
-}
-
-static PureVersion version(void *context, void *document) {
- (void)context;
- return pure_draft_version(document);
-}
-
-static PureResult read(void *context, void *document, PureVersion at, size_t offset, size_t length,
- bool (*visit)(void *, PureSpan), void *visit_context) {
- (void)context;
- return pure_draft_read_version(document, at, offset, length, visit, visit_context);
-}
-
-static PureResult splice(void *context, void *document, size_t offset, size_t remove, PureSpan insert) {
- (void)context;
- return pure_draft_splice(document, offset, remove, insert);
-}
-
-static PureResult commit(void *context, void *document, int64_t *revision) {
- (void)context;
- return pure_draft_commit(document, revision);
-}
-
-static void close_document(void *context, void *document) {
- (void)context;
- pure_draft_close(document);
-}
-
static PureResult state(void *context, const char *name, PureDraft **out) {
return pure_state_open(context, name, out);
}
-enum { SAVED = PURE_APP_PENDING + 2 * PURE_MODULE_STATES + 1 };
+enum { SAVED = 2 * PURE_MODULE_STATES + 3 };
-/* The documents and the app's changed states in one tree commit. */
-static PureResult save(void *context, void *const *documents, size_t document_count, PureDraft *const *states,
- size_t count, int64_t *revisions) {
+/* The app's changed states in one tree commit. */
+static PureResult save(void *context, PureDraft *const *states, size_t count) {
(void)context;
- PureDraft *drafts[SAVED] = {0};
- int64_t all[SAVED] = {0};
- if (document_count > PURE_APP_PENDING || count > SAVED - document_count) return PURE_LIMIT;
- for (size_t i = 0; i < document_count; ++i) drafts[i] = documents[i];
- for (size_t i = 0; i < count; ++i) drafts[document_count + i] = states[i];
- PureResult result = pure_draft_commit_all(drafts, document_count + count, all);
- for (size_t i = 0; i < document_count; ++i) revisions[i] = all[i];
- return result;
+ int64_t revisions[SAVED];
+ if (count > SAVED) return PURE_LIMIT;
+ return pure_draft_commit_all(states, count, revisions);
}
static const char *path_directory(void *context) { return context; }
static const char *handle_directory(void *context) { return pure_store_path(context); }
-/* Through a store handle: documents and states share its mapping. */
-static PureResult open_handle_document(void *context, uint32_t collection, const char *key, void **document,
- int64_t *revision) {
- (void)collection;
- PureDraft *draft;
- PureResult result = pure_store_draft(context, key, &draft);
- if (result != PURE_OK) return result;
- pure_draft_hold(draft, true);
- *document = draft;
- *revision = pure_draft_revision(draft);
- return PURE_OK;
-}
-
static PureResult handle_state(void *context, const char *name, PureDraft **out) {
return pure_store_state(context, name, out);
}
PureData pure_store_data(PureStore *store) {
- return (PureData){.context = store, .open = open_handle_document, .version = version, .read = read,
- .splice = splice, .commit = commit, .close = close_document, .state = handle_state,
- .save = save, .directory = handle_directory};
+ return (PureData){.context = store, .state = handle_state, .save = save, .directory = handle_directory};
}
PureData pure_tree_data(const char *path) {
- return (PureData){.context = (void *)path, .open = open_document, .version = version,
- .read = read, .splice = splice, .commit = commit, .close = close_document,
- .state = state, .save = save, .directory = path_directory};
+ return (PureData){.context = (void *)path, .state = state, .save = save, .directory = path_directory};
}