Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: 构建
run: cmake -B build && cmake --build build
run: cmake -B build -DCMAKE_BUILD_TYPE=Release && cmake --build build
- name: 构建 CLI(cli/ 独立 Cargo 项目,走 dispatch 前端 C ABI)
run: |
# CLI 用 #[link(name = "kvspace")] 链本仓刚构建的前端 → 把 build/ 交给链接器
Expand Down
5 changes: 5 additions & 0 deletions include/kvspace/kvspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ typedef struct {
int kvspaceResolveRef(void *h, const char *key, kvspaceRef_t *ref);
int kvspaceGetByRef(void *h, kvspaceRef_t *ref, const char *key_fallback,
uint8_t **out, uint32_t *out_len);
/* Same semantics as SetValue. ref must belong to key; unsupported backends
* use SetValue. The reference stores an address, never a value snapshot. */
int kvspaceSetValueByRef(void *h, kvspaceRef_t *ref, const char *key,
const uint8_t *value, uint32_t value_len,
uint8_t ro, uint32_t vid, char *err, uint32_t err_cap);
int kvspaceSetPartByRef(void *h, kvspaceRef_t *ref, const char *key_fallback,
uint32_t offset, const uint8_t *buf, uint32_t buf_len,
char *err, uint32_t err_cap);
Expand Down
15 changes: 15 additions & 0 deletions src/frontend.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ typedef struct {
int (*resolveref)(void *h, const char *key, kvspaceRef_t *ref);
int (*getbyref)(void *h, kvspaceRef_t *ref, const char *key_fallback,
uint8_t **out, uint32_t *out_len);
int (*setvaluebyref)(void *h, kvspaceRef_t *ref, const char *key,
const uint8_t *value, uint32_t value_len,
uint8_t ro, uint32_t vid, char *err, uint32_t err_cap);
int (*setpartbyref)(void *h, kvspaceRef_t *ref, const char *key_fallback,
uint32_t offset, const uint8_t *buf, uint32_t buf_len,
char *err, uint32_t err_cap);
Expand Down Expand Up @@ -186,6 +189,7 @@ void *kvspaceConnect(const char *dsn) {
LOAD(watch, "kvspaceWatch");
#undef LOAD
*(void **)&vt->resolveref = dlsym(dl, "kvspaceResolveRef");
*(void **)&vt->setvaluebyref = dlsym(dl, "kvspaceSetValueByRef");
*(void **)&vt->getbyref = dlsym(dl, "kvspaceGetByRef");
*(void **)&vt->setpartbyref = dlsym(dl, "kvspaceSetPartByRef");

Expand Down Expand Up @@ -241,6 +245,17 @@ int kvspaceGetByRef(void *h, kvspaceRef_t *ref, const char *key_fallback,
return x->vt->get(x->backend, key_fallback, 0, out, out_len);
}

int kvspaceSetValueByRef(void *h, kvspaceRef_t *ref, const char *key,
const uint8_t *value, uint32_t value_len,
uint8_t ro, uint32_t vid, char *err, uint32_t err_cap) {
kvspace_handle *x = H(h);
if (x->vt->setvaluebyref)
return x->vt->setvaluebyref(x->backend, ref, key, value, value_len,
ro, vid, err, err_cap);
return x->vt->setvalue(x->backend, key, value, value_len, ro, vid,
err, err_cap);
}

int kvspaceSetPartByRef(void *h, kvspaceRef_t *ref, const char *key_fallback,
uint32_t offset, const uint8_t *buf, uint32_t buf_len,
char *err, uint32_t err_cap) {
Expand Down
Loading