@based/db 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +317 -0
- package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +322 -0
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
- package/dist/lib/linux_aarch64/include/queue.h +627 -0
- package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +418 -0
- package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +23 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +381 -0
- package/dist/lib/linux_aarch64/include/selva/find.h +47 -0
- package/dist/lib/linux_aarch64/include/selva/history.h +64 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +81 -0
- package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_aarch64/include/selva/queue_r.h +190 -0
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +674 -0
- package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_aarch64/include/selva/traverse.h +65 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +106 -0
- package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +13 -0
- package/dist/lib/linux_aarch64/include/selva_error.h +137 -0
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +157 -0
- package/dist/lib/linux_aarch64/include/tree.h +852 -0
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
- package/dist/lib/linux_x86_64/include/cdefs.h +317 -0
- package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +322 -0
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
- package/dist/lib/linux_x86_64/include/queue.h +627 -0
- package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
- package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +418 -0
- package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +23 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +381 -0
- package/dist/lib/linux_x86_64/include/selva/find.h +47 -0
- package/dist/lib/linux_x86_64/include/selva/history.h +64 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +81 -0
- package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_x86_64/include/selva/queue_r.h +190 -0
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +674 -0
- package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_x86_64/include/selva/traverse.h +65 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +106 -0
- package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +13 -0
- package/dist/lib/linux_x86_64/include/selva_error.h +137 -0
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +157 -0
- package/dist/lib/linux_x86_64/include/tree.h +852 -0
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
- package/dist/src/client/flushModify.d.ts +1 -1
- package/dist/src/client/query/aggregation.d.ts +1 -1
- package/dist/src/client/query/search/index.d.ts +1 -1
- package/dist/src/client/query/sort.d.ts +1 -1
- package/dist/src/client/xxHash64.d.ts +1 -1
- package/dist/src/server/csmt/match.d.ts +1 -1
- package/dist/src/server/dbHash.d.ts +1 -1
- package/dist/src/server/index.d.ts +2 -2
- package/package.json +1 -1
- package/dist/src/client/query/aggregates/aggregation.d.ts +0 -4
- package/dist/src/client/query/aggregates/aggregation.js +0 -12
- package/dist/src/client/tmpBuffer.d.ts +0 -3
- package/dist/src/client/tmpBuffer.js +0 -20
|
@@ -0,0 +1,381 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024-2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <sys/types.h>
|
|
8
|
+
#include "selva/_export.h"
|
|
9
|
+
#ifdef __zig
|
|
10
|
+
struct selva_string;
|
|
11
|
+
#else
|
|
12
|
+
#include "selva/selva_string.h"
|
|
13
|
+
#endif
|
|
14
|
+
#include "selva/types.h"
|
|
15
|
+
#include "selva_lang_code.h"
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Reserved (N/A) field id.
|
|
19
|
+
* Can be used to mark that a field doesn't exist.
|
|
20
|
+
* E.g. if created and updated fields don't exist their ids can be set to this
|
|
21
|
+
* value.
|
|
22
|
+
* Technically fields 251..255 are all reserved.
|
|
23
|
+
*/
|
|
24
|
+
#define SELVA_FIELDS_RESERVED 255
|
|
25
|
+
|
|
26
|
+
struct XXH3_state_s; /* RFE Not good? */
|
|
27
|
+
|
|
28
|
+
#ifndef __zig
|
|
29
|
+
struct SelvaTextField {
|
|
30
|
+
struct selva_string *tl __pcounted_by(len);
|
|
31
|
+
uint8_t len;
|
|
32
|
+
} __packed;
|
|
33
|
+
#endif
|
|
34
|
+
|
|
35
|
+
struct SelvaNodeReference {
|
|
36
|
+
struct SelvaNode *dst;
|
|
37
|
+
struct SelvaFields *meta;
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
struct SelvaNodeReferences {
|
|
41
|
+
uint32_t nr_refs;
|
|
42
|
+
uint16_t offset;
|
|
43
|
+
struct SelvaNodeReference *refs __pcounted_by(nr_refs);
|
|
44
|
+
node_id_t *index __pcounted_by(nr_refs); /*!< Sorted index of all nodes in `.refs`. */
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
struct SelvaNodeWeakReference {
|
|
48
|
+
/* THe type can be found from the schema. */
|
|
49
|
+
#if 0
|
|
50
|
+
node_type_t dst_type;
|
|
51
|
+
#endif
|
|
52
|
+
node_id_t dst_id;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
struct SelvaNodeWeakReferences {
|
|
56
|
+
uint32_t nr_refs;
|
|
57
|
+
uint32_t offset;
|
|
58
|
+
struct SelvaNodeWeakReference *refs __pcounted_by(nr_refs);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Type helper to determine the size of statically (constant/fixed) sized fields.
|
|
63
|
+
*/
|
|
64
|
+
union SelvaStaticFields {
|
|
65
|
+
bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
|
|
66
|
+
double number; /*!< SELVA_FIELD_TYPE_NUMBER */
|
|
67
|
+
struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
|
|
68
|
+
int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
|
|
69
|
+
uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
|
|
70
|
+
int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
|
|
71
|
+
uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
|
|
72
|
+
int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
|
|
73
|
+
uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
|
|
74
|
+
uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
|
|
75
|
+
struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
struct SelvaFieldsPointer {
|
|
79
|
+
uint8_t *ptr;
|
|
80
|
+
size_t off;
|
|
81
|
+
size_t len;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
#if __has_c_attribute(unsequenced)
|
|
85
|
+
[[unsequenced]]
|
|
86
|
+
#else
|
|
87
|
+
__purefn
|
|
88
|
+
#endif
|
|
89
|
+
size_t selva_fields_get_data_size(const struct SelvaFieldSchema *fs);
|
|
90
|
+
|
|
91
|
+
#if __has_c_attribute(reproducible)
|
|
92
|
+
[[reproducible]]
|
|
93
|
+
#endif
|
|
94
|
+
void *selva_fields_nfo2p(struct SelvaFields *fields, const struct SelvaFieldInfo *nfo);
|
|
95
|
+
|
|
96
|
+
void selva_fields_ensure_ref_meta(
|
|
97
|
+
struct SelvaDb *db,
|
|
98
|
+
struct SelvaNode *node,
|
|
99
|
+
struct SelvaNodeReference *ref,
|
|
100
|
+
const struct EdgeFieldConstraint *efc)
|
|
101
|
+
__attribute__((nonnull));
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Set field value.
|
|
105
|
+
*/
|
|
106
|
+
SELVA_EXPORT
|
|
107
|
+
int selva_fields_set(
|
|
108
|
+
struct SelvaNode *node,
|
|
109
|
+
const struct SelvaFieldSchema *fs,
|
|
110
|
+
const void *value, size_t len);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Set field value by a `fields` pointer.
|
|
114
|
+
* @param fields can be either `node->fields` or any other `fields` structure
|
|
115
|
+
* associated with the given node (currently edge).
|
|
116
|
+
*/
|
|
117
|
+
SELVA_EXPORT
|
|
118
|
+
int fields_set2(
|
|
119
|
+
struct SelvaNode *node,
|
|
120
|
+
const struct SelvaFieldSchema *fs,
|
|
121
|
+
struct SelvaFields *fields,
|
|
122
|
+
const void *value, size_t len);
|
|
123
|
+
|
|
124
|
+
SELVA_EXPORT
|
|
125
|
+
int selva_fields_get_mutable_string(
|
|
126
|
+
struct SelvaNode *node,
|
|
127
|
+
const struct SelvaFieldSchema *fs,
|
|
128
|
+
size_t len,
|
|
129
|
+
struct selva_string **s)
|
|
130
|
+
__attribute__((access(write_only, 4)));
|
|
131
|
+
|
|
132
|
+
SELVA_EXPORT
|
|
133
|
+
struct SelvaFieldInfo *selva_fields_ensure(struct SelvaFields *fields, const struct SelvaFieldSchema *fs);
|
|
134
|
+
|
|
135
|
+
/*
|
|
136
|
+
* TODO Document diff to get_mutable_string
|
|
137
|
+
*/
|
|
138
|
+
SELVA_EXPORT
|
|
139
|
+
struct selva_string *selva_fields_ensure_string(
|
|
140
|
+
struct SelvaNode *node,
|
|
141
|
+
const struct SelvaFieldSchema *fs,
|
|
142
|
+
size_t initial_len);
|
|
143
|
+
|
|
144
|
+
SELVA_EXPORT
|
|
145
|
+
struct selva_string *selva_fields_ensure_string2(
|
|
146
|
+
struct SelvaDb *db,
|
|
147
|
+
struct SelvaNode *node,
|
|
148
|
+
const struct EdgeFieldConstraint *efc,
|
|
149
|
+
struct SelvaNodeReference *ref,
|
|
150
|
+
const struct SelvaFieldSchema *fs,
|
|
151
|
+
size_t initial_len);
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Set reference to fields.
|
|
155
|
+
* @param dirty_nodes returns the nodes that were changed, apart from src and dst.
|
|
156
|
+
* [n].id = 0 = nil;
|
|
157
|
+
* [0] = the node src was pointing to previously (same type as dst);
|
|
158
|
+
* [1] = the node dst was pointing to previously (same type as src).
|
|
159
|
+
*/
|
|
160
|
+
SELVA_EXPORT
|
|
161
|
+
int selva_fields_reference_set(
|
|
162
|
+
struct SelvaDb *db,
|
|
163
|
+
struct SelvaNode * restrict src,
|
|
164
|
+
const struct SelvaFieldSchema *fs_src,
|
|
165
|
+
struct SelvaNode * restrict dst,
|
|
166
|
+
struct SelvaNodeReference **ref_out,
|
|
167
|
+
node_id_t dirty_nodes[static 2])
|
|
168
|
+
__attribute__((access(write_only, 5), access(write_only, 6)));
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @param index 0 = first; -1 = last.
|
|
172
|
+
* @param reorder move the existing ref to `index` instead of returning EEXIST.
|
|
173
|
+
*/
|
|
174
|
+
SELVA_EXPORT
|
|
175
|
+
int selva_fields_references_insert(
|
|
176
|
+
struct SelvaDb *db,
|
|
177
|
+
struct SelvaNode * restrict node,
|
|
178
|
+
const struct SelvaFieldSchema *fs,
|
|
179
|
+
ssize_t index,
|
|
180
|
+
bool reorder,
|
|
181
|
+
struct SelvaTypeEntry *te_dst,
|
|
182
|
+
struct SelvaNode * restrict dst,
|
|
183
|
+
struct SelvaNodeReference **ref_out)
|
|
184
|
+
__attribute__((access(write_only, 8)));
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Prealloc a references field buffer.
|
|
188
|
+
* @returns nr_refs.
|
|
189
|
+
*/
|
|
190
|
+
SELVA_EXPORT
|
|
191
|
+
size_t selva_fields_prealloc_refs(struct SelvaNode *node, const struct SelvaFieldSchema *fs, size_t nr_refs_min);
|
|
192
|
+
|
|
193
|
+
SELVA_EXPORT
|
|
194
|
+
int selva_fields_references_insert_tail_wupsert(
|
|
195
|
+
struct SelvaDb *db,
|
|
196
|
+
struct SelvaNode * restrict node,
|
|
197
|
+
const struct SelvaFieldSchema *fs,
|
|
198
|
+
struct SelvaTypeEntry *te_dst,
|
|
199
|
+
const node_id_t ids[],
|
|
200
|
+
size_t nr_ids)
|
|
201
|
+
__attribute__((access(read_only, 5, 6)));
|
|
202
|
+
|
|
203
|
+
/**
|
|
204
|
+
* Move reference from old to new index in a references field array.
|
|
205
|
+
* If index_new > index_old then the ref will be after the reference that was in index_new before the operation;
|
|
206
|
+
* If index_new < index_ld then the ref will be before the reference that was in the index_new before the operation.
|
|
207
|
+
* index_new and index_old can be negative, which will start counting the references array from the last position.
|
|
208
|
+
* It's not possible to create a gap of null references using this function.
|
|
209
|
+
*/
|
|
210
|
+
SELVA_EXPORT
|
|
211
|
+
int selva_fields_references_move(
|
|
212
|
+
struct SelvaNode *node,
|
|
213
|
+
const struct SelvaFieldSchema *fs,
|
|
214
|
+
ssize_t index_old,
|
|
215
|
+
ssize_t index_new);
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Swap two references in a references field array.
|
|
219
|
+
*/
|
|
220
|
+
SELVA_EXPORT
|
|
221
|
+
int selva_fields_references_swap(
|
|
222
|
+
struct SelvaNode *node,
|
|
223
|
+
const struct SelvaFieldSchema *fs,
|
|
224
|
+
size_t index_a,
|
|
225
|
+
size_t index_b);
|
|
226
|
+
|
|
227
|
+
SELVA_EXPORT
|
|
228
|
+
int selva_fields_set_reference_meta(
|
|
229
|
+
struct SelvaDb *db,
|
|
230
|
+
struct SelvaNode *node,
|
|
231
|
+
struct SelvaNodeReference *ref,
|
|
232
|
+
const struct EdgeFieldConstraint *efc,
|
|
233
|
+
field_t field,
|
|
234
|
+
const void *value, size_t len);
|
|
235
|
+
|
|
236
|
+
SELVA_EXPORT
|
|
237
|
+
int selva_fields_get_reference_meta_mutable_string(
|
|
238
|
+
struct SelvaDb *db,
|
|
239
|
+
struct SelvaNode *node,
|
|
240
|
+
struct SelvaNodeReference *ref,
|
|
241
|
+
const struct EdgeFieldConstraint *efc,
|
|
242
|
+
field_t field,
|
|
243
|
+
size_t len,
|
|
244
|
+
struct selva_string **s);
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Set string field.
|
|
248
|
+
*
|
|
249
|
+
* str format:
|
|
250
|
+
* 0 1 2 len
|
|
251
|
+
* +------+------+--------+-----+
|
|
252
|
+
* | LANG | COMP | DATA | CRC |
|
|
253
|
+
* +------+------+--------+-----+
|
|
254
|
+
*/
|
|
255
|
+
SELVA_EXPORT
|
|
256
|
+
int selva_fields_set_string(
|
|
257
|
+
struct SelvaNode *node,
|
|
258
|
+
const struct SelvaFieldSchema *fs,
|
|
259
|
+
struct SelvaFieldInfo *nfo,
|
|
260
|
+
const char *str,
|
|
261
|
+
size_t len);
|
|
262
|
+
|
|
263
|
+
/**
|
|
264
|
+
* Set text field translation.
|
|
265
|
+
*
|
|
266
|
+
* str format:
|
|
267
|
+
* 0 1 2 len
|
|
268
|
+
* +------+------+--------+-----+
|
|
269
|
+
* | LANG | COMP | DATA | CRC |
|
|
270
|
+
* +------+------+--------+-----+
|
|
271
|
+
*/
|
|
272
|
+
SELVA_EXPORT
|
|
273
|
+
int selva_fields_set_text(
|
|
274
|
+
struct SelvaNode *node,
|
|
275
|
+
const struct SelvaFieldSchema *fs,
|
|
276
|
+
const char *str,
|
|
277
|
+
size_t len);
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Get text field translation.
|
|
281
|
+
*
|
|
282
|
+
* str format:
|
|
283
|
+
* 0 1 2 len
|
|
284
|
+
* +------+------+--------+-----+
|
|
285
|
+
* | LANG | COMP | DATA | CRC |
|
|
286
|
+
* +------+------+--------+-----+
|
|
287
|
+
*/
|
|
288
|
+
SELVA_EXPORT
|
|
289
|
+
int selva_fields_get_text(
|
|
290
|
+
struct SelvaDb *db,
|
|
291
|
+
struct SelvaNode * restrict node,
|
|
292
|
+
const struct SelvaFieldSchema *fs,
|
|
293
|
+
enum selva_lang_code lang,
|
|
294
|
+
const char **str,
|
|
295
|
+
size_t *len);
|
|
296
|
+
|
|
297
|
+
SELVA_EXPORT
|
|
298
|
+
struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
299
|
+
__attribute__((nonnull));
|
|
300
|
+
|
|
301
|
+
SELVA_EXPORT
|
|
302
|
+
struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
303
|
+
__attribute__((nonnull));
|
|
304
|
+
|
|
305
|
+
SELVA_EXPORT
|
|
306
|
+
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaDb *db, struct SelvaFields *fields, field_t field)
|
|
307
|
+
__attribute__((nonnull));
|
|
308
|
+
|
|
309
|
+
SELVA_EXPORT
|
|
310
|
+
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaDb *db, struct SelvaFields *fields, field_t field)
|
|
311
|
+
__attribute__((nonnull));
|
|
312
|
+
|
|
313
|
+
SELVA_EXPORT
|
|
314
|
+
struct SelvaNode *selva_fields_resolve_weak_reference(
|
|
315
|
+
const struct SelvaDb *db,
|
|
316
|
+
const struct SelvaFieldSchema *fs,
|
|
317
|
+
const struct SelvaNodeWeakReference *weak_ref)
|
|
318
|
+
__attribute__((nonnull));
|
|
319
|
+
|
|
320
|
+
SELVA_EXPORT
|
|
321
|
+
struct selva_string *selva_fields_get_selva_string3(struct SelvaNodeReference *ref, const struct SelvaFieldSchema *fs)
|
|
322
|
+
__attribute__((nonnull));
|
|
323
|
+
|
|
324
|
+
SELVA_EXPORT
|
|
325
|
+
struct selva_string *selva_fields_get_selva_string2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs)
|
|
326
|
+
__attribute__((nonnull));
|
|
327
|
+
|
|
328
|
+
SELVA_EXPORT
|
|
329
|
+
struct selva_string *selva_fields_get_selva_string(struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
330
|
+
__attribute__((nonnull));
|
|
331
|
+
|
|
332
|
+
SELVA_EXPORT
|
|
333
|
+
struct SelvaFieldsPointer selva_fields_get_raw2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs)
|
|
334
|
+
__attribute__((nonnull));
|
|
335
|
+
|
|
336
|
+
SELVA_EXPORT
|
|
337
|
+
struct SelvaFieldsPointer selva_fields_get_raw(struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
338
|
+
__attribute__((nonnull));
|
|
339
|
+
|
|
340
|
+
/**
|
|
341
|
+
* Delete field.
|
|
342
|
+
* @param dirty_cb will be called with the deleted node_id in case of a reference(s) field.
|
|
343
|
+
*/
|
|
344
|
+
SELVA_EXPORT
|
|
345
|
+
int selva_fields_del(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx)
|
|
346
|
+
__attribute__((nonnull(1, 2, 3)));
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Delete an edge from a references field.
|
|
350
|
+
*/
|
|
351
|
+
SELVA_EXPORT
|
|
352
|
+
int selva_fields_del_ref(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst_node_id);
|
|
353
|
+
|
|
354
|
+
/**
|
|
355
|
+
* Clear a references field but don't free it.
|
|
356
|
+
*/
|
|
357
|
+
SELVA_EXPORT
|
|
358
|
+
void selva_fields_clear_references(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx)
|
|
359
|
+
__attribute__((nonnull(1, 2, 3)));
|
|
360
|
+
|
|
361
|
+
/**
|
|
362
|
+
* Init the fields struct of a node or edge.
|
|
363
|
+
*/
|
|
364
|
+
SELVA_EXPORT
|
|
365
|
+
void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaFields *fields)
|
|
366
|
+
__attribute__((nonnull));
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* Destroy all fields of a node.
|
|
370
|
+
* This will set nr_fields = 0, making setting new field values impossible
|
|
371
|
+
* regardless wether the schema defines fields for this node.
|
|
372
|
+
*/
|
|
373
|
+
SELVA_EXPORT
|
|
374
|
+
void selva_fields_destroy(struct SelvaDb *db, struct SelvaNode *node, selva_dirty_node_cb_t dirty_cb, void *dirty_ctx)
|
|
375
|
+
__attribute__((nonnull(1, 2)));
|
|
376
|
+
|
|
377
|
+
SELVA_EXPORT
|
|
378
|
+
void selva_fields_hash_update(struct XXH3_state_s *hash_state, struct SelvaDb *db, const struct SelvaFieldsSchema *schema, const struct SelvaFields *fields);
|
|
379
|
+
|
|
380
|
+
SELVA_EXPORT
|
|
381
|
+
selva_hash128_t selva_fields_hash(struct SelvaDb *db, const struct SelvaFieldsSchema *schema, const struct SelvaFields *fields);
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "selva/_export.h"
|
|
8
|
+
#include "selva/types.h"
|
|
9
|
+
#include "selva/traverse.h"
|
|
10
|
+
|
|
11
|
+
struct SelvaFindParam {
|
|
12
|
+
SelvaTraversalNodeCallback node_cb;
|
|
13
|
+
void *node_arg;
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Traverse field selector.
|
|
17
|
+
*/
|
|
18
|
+
const struct FindFields {
|
|
19
|
+
uint8_t len;
|
|
20
|
+
struct {
|
|
21
|
+
node_type_t type;
|
|
22
|
+
field_t field;
|
|
23
|
+
} __packed data[];
|
|
24
|
+
} __packed *fields;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Skip the first n nodes in the traversal.
|
|
28
|
+
* This happens before filtering.
|
|
29
|
+
*/
|
|
30
|
+
ssize_t skip;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Skip the first n - 1 results.
|
|
34
|
+
* This skipping is executed on the final result set.
|
|
35
|
+
* 0 for no offset.
|
|
36
|
+
*/
|
|
37
|
+
ssize_t offset;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Limit the number of results.
|
|
41
|
+
* -1 for no limit (inf).
|
|
42
|
+
*/
|
|
43
|
+
ssize_t limit;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
SELVA_EXPORT
|
|
47
|
+
int selva_find(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFindParam *param);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include <stddef.h>
|
|
8
|
+
#include <stdint.h>
|
|
9
|
+
#include "selva/types.h"
|
|
10
|
+
#include "selva/_export.h"
|
|
11
|
+
|
|
12
|
+
struct selva_history;
|
|
13
|
+
|
|
14
|
+
struct selva_history_event {
|
|
15
|
+
int64_t ts;
|
|
16
|
+
node_id_t node_id;
|
|
17
|
+
uint32_t crc;
|
|
18
|
+
} __packed __attribute__((aligned(4)));
|
|
19
|
+
|
|
20
|
+
static_assert(alignof(struct selva_history_event) == alignof(uint32_t));
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Create a new history object.
|
|
24
|
+
*/
|
|
25
|
+
SELVA_EXPORT
|
|
26
|
+
int selva_history_create(const char *pathname, size_t bsize, struct selva_history **hist_out);
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Destroy a history object.
|
|
30
|
+
*/
|
|
31
|
+
SELVA_EXPORT
|
|
32
|
+
void selva_history_destroy(struct selva_history *hist);
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Append a block of size `bsize` to a history object.
|
|
36
|
+
*/
|
|
37
|
+
SELVA_EXPORT
|
|
38
|
+
void selva_history_append(struct selva_history *hist, int64_t ts, node_id_t node_id, void *buf);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Ensure that the history file is fully written to the disk.
|
|
42
|
+
*/
|
|
43
|
+
SELVA_EXPORT
|
|
44
|
+
void selva_history_fsync(struct selva_history *hist);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Find a range.
|
|
48
|
+
* The returned buffer must be freed with selva_history_free_range().
|
|
49
|
+
*/
|
|
50
|
+
SELVA_EXPORT
|
|
51
|
+
uint32_t *selva_history_find_range(struct selva_history *hist, int64_t from, int64_t to, size_t *size_out);
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Find a range.
|
|
55
|
+
* The returned buffer must be freed with selva_history_free_range().
|
|
56
|
+
*/
|
|
57
|
+
SELVA_EXPORT
|
|
58
|
+
uint32_t *selva_history_find_range_node(struct selva_history *hist, int64_t from, int64_t to, node_id_t node_id, size_t *size_out);
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Free a range returned by selva_history_find_range() or selva_history_find_range_node().
|
|
62
|
+
*/
|
|
63
|
+
SELVA_EXPORT
|
|
64
|
+
void selva_history_free_range(uint32_t *range);
|