@based/db 0.0.64 → 0.0.66
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/include/selva/db.h +30 -4
- package/dist/lib/darwin_aarch64/include/selva/fields.h +36 -24
- package/dist/lib/darwin_aarch64/include/selva/hll.h +5 -3
- package/dist/lib/darwin_aarch64/include/selva/membar.h +23 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +19 -3
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- 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/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +30 -4
- package/dist/lib/linux_aarch64/include/selva/fields.h +36 -24
- package/dist/lib/linux_aarch64/include/selva/hll.h +5 -3
- package/dist/lib/linux_aarch64/include/selva/membar.h +23 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +1 -1
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +19 -3
- 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/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +30 -4
- package/dist/lib/linux_x86_64/include/selva/fields.h +36 -24
- package/dist/lib/linux_x86_64/include/selva/hll.h +5 -3
- package/dist/lib/linux_x86_64/include/selva/membar.h +23 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +1 -1
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +19 -3
- 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/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/fixed.js +1 -1
- package/dist/src/client/query/BasedDbQuery.d.ts +3 -2
- package/dist/src/client/query/BasedDbQuery.js +23 -12
- package/dist/src/client/query/aggregates/types.d.ts +2 -1
- package/dist/src/client/query/read/read.js +6 -3
- package/dist/src/client/query/validation.d.ts +3 -0
- package/dist/src/client/query/validation.js +9 -0
- package/dist/src/index.d.ts +1 -1
- package/dist/src/native.d.ts +5 -2
- package/dist/src/native.js +16 -5
- package/dist/src/server/DbWorker.d.ts +2 -2
- package/dist/src/server/index.d.ts +1 -0
- package/dist/src/server/index.js +3 -1
- package/dist/src/server/migrate/index.js +1 -0
- package/dist/src/server/migrate/worker.js +3 -0
- package/dist/src/server/save.js +4 -4
- package/dist/src/server/start.js +1 -1
- package/package.json +2 -2
- package/dist/lib/darwin_aarch64/include/selva/find.h +0 -47
- package/dist/lib/darwin_aarch64/include/selva/queue_r.h +0 -190
- package/dist/lib/darwin_aarch64/include/selva/traverse.h +0 -65
- package/dist/lib/linux_aarch64/include/selva/find.h +0 -47
- package/dist/lib/linux_aarch64/include/selva/queue_r.h +0 -190
- package/dist/lib/linux_aarch64/include/selva/traverse.h +0 -65
- package/dist/lib/linux_x86_64/include/selva/find.h +0 -47
- package/dist/lib/linux_x86_64/include/selva/queue_r.h +0 -190
- package/dist/lib/linux_x86_64/include/selva/traverse.h +0 -65
|
@@ -42,24 +42,24 @@ SELVA_EXPORT
|
|
|
42
42
|
int selva_dump_save_common(struct SelvaDb *db, const char *filename) __attribute__((nonnull));
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Save a
|
|
45
|
+
* Save a nodes block starting from start.
|
|
46
46
|
*/
|
|
47
47
|
SELVA_EXPORT
|
|
48
|
-
int
|
|
48
|
+
int selva_dump_save_block(struct SelvaDb *db, struct SelvaTypeEntry *te, const char *filename, node_id_t start, selva_hash128_t *range_hash_out) __attribute__((nonnull));
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* **Usage:**
|
|
52
52
|
* ```c
|
|
53
53
|
* struct SelvaDb *db = selva_db_create();
|
|
54
54
|
* selva_dump_load_common(db, filename_common);
|
|
55
|
-
*
|
|
55
|
+
* selva_dump_load_block(db, filename_range_n);
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
SELVA_EXPORT
|
|
59
59
|
int selva_dump_load_common(struct SelvaDb *db, const char *filename, char *errlog_buf, size_t errlog_size) __attribute__((nonnull));
|
|
60
60
|
|
|
61
61
|
SELVA_EXPORT
|
|
62
|
-
int
|
|
62
|
+
int selva_dump_load_block(struct SelvaDb *db, const char *filename, char *errlog_buf, size_t errlog_size) __attribute__((nonnull));
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Find a type by type id.
|
|
@@ -83,6 +83,32 @@ inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
|
|
|
83
83
|
;
|
|
84
84
|
#endif
|
|
85
85
|
|
|
86
|
+
inline block_id_t selva_node_id2block_i3(block_id_t block_capacity, node_id_t node_id)
|
|
87
|
+
{
|
|
88
|
+
assert(node_id > 0);
|
|
89
|
+
return ((node_id - 1) - ((node_id - 1) % block_capacity)) / block_capacity;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
SELVA_EXPORT
|
|
93
|
+
inline block_id_t selva_node_id2block_i(const struct SelvaTypeBlocks *blocks, node_id_t node_id)
|
|
94
|
+
#ifndef __zig
|
|
95
|
+
{
|
|
96
|
+
return selva_node_id2block_i3(blocks->block_capacity, node_id);
|
|
97
|
+
}
|
|
98
|
+
#else
|
|
99
|
+
;
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
SELVA_EXPORT
|
|
103
|
+
inline block_id_t selva_node_id2block_i2(const struct SelvaTypeEntry *te, node_id_t node_id)
|
|
104
|
+
#ifndef __zig
|
|
105
|
+
{
|
|
106
|
+
return selva_node_id2block_i(te->blocks, node_id);
|
|
107
|
+
}
|
|
108
|
+
#else
|
|
109
|
+
;
|
|
110
|
+
#endif
|
|
111
|
+
|
|
86
112
|
/**
|
|
87
113
|
* Get the node schema for type.
|
|
88
114
|
*/
|
|
@@ -46,7 +46,7 @@ struct SelvaNodeReferences {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
struct SelvaNodeWeakReference {
|
|
49
|
-
/*
|
|
49
|
+
/* The type can be found from the schema. */
|
|
50
50
|
#if 0
|
|
51
51
|
node_type_t dst_type;
|
|
52
52
|
#endif
|
|
@@ -99,11 +99,15 @@ __purefn
|
|
|
99
99
|
#endif
|
|
100
100
|
size_t selva_fields_get_data_size(const struct SelvaFieldSchema *fs);
|
|
101
101
|
|
|
102
|
+
SELVA_EXPORT
|
|
102
103
|
#if __has_c_attribute(reproducible)
|
|
103
104
|
[[reproducible]]
|
|
104
105
|
#endif
|
|
105
106
|
void *selva_fields_nfo2p(struct SelvaFields *fields, const struct SelvaFieldInfo *nfo);
|
|
106
107
|
|
|
108
|
+
SELVA_EXPORT
|
|
109
|
+
struct SelvaFields *selva_fields_node2fields(struct SelvaNode *node);
|
|
110
|
+
|
|
107
111
|
void selva_fields_ensure_ref_meta(
|
|
108
112
|
struct SelvaDb *db,
|
|
109
113
|
struct SelvaNode *node,
|
|
@@ -118,19 +122,7 @@ SELVA_EXPORT
|
|
|
118
122
|
int selva_fields_set(
|
|
119
123
|
struct SelvaNode *node,
|
|
120
124
|
const struct SelvaFieldSchema *fs,
|
|
121
|
-
const void *value, size_t len);
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Set field value by a `fields` pointer.
|
|
125
|
-
* @param fields can be either `node->fields` or any other `fields` structure
|
|
126
|
-
* associated with the given node (currently edge).
|
|
127
|
-
*/
|
|
128
|
-
SELVA_EXPORT
|
|
129
|
-
int fields_set2(
|
|
130
|
-
struct SelvaNode *node,
|
|
131
|
-
const struct SelvaFieldSchema *fs,
|
|
132
|
-
struct SelvaFields *fields,
|
|
133
|
-
const void *value, size_t len);
|
|
125
|
+
const void *value, size_t len) __attribute__((deprecated));
|
|
134
126
|
|
|
135
127
|
SELVA_EXPORT
|
|
136
128
|
int selva_fields_get_mutable_string(
|
|
@@ -163,10 +155,6 @@ struct selva_string *selva_fields_ensure_string2(
|
|
|
163
155
|
|
|
164
156
|
/**
|
|
165
157
|
* Set reference to fields.
|
|
166
|
-
* @param dirty_nodes returns the nodes that were changed, apart from src and dst.
|
|
167
|
-
* [n].id = 0 = nil;
|
|
168
|
-
* [0] = the node src was pointing to previously (same type as dst);
|
|
169
|
-
* [1] = the node dst was pointing to previously (same type as src).
|
|
170
158
|
*/
|
|
171
159
|
SELVA_EXPORT
|
|
172
160
|
int selva_fields_reference_set(
|
|
@@ -175,8 +163,9 @@ int selva_fields_reference_set(
|
|
|
175
163
|
const struct SelvaFieldSchema *fs_src,
|
|
176
164
|
struct SelvaNode * restrict dst,
|
|
177
165
|
struct SelvaNodeReference **ref_out,
|
|
178
|
-
|
|
179
|
-
|
|
166
|
+
selva_dirty_node_cb_t dirty_cb,
|
|
167
|
+
void *dirty_ctx);
|
|
168
|
+
// __attribute__((access(write_only, 5), access(write_only, 6)));
|
|
180
169
|
|
|
181
170
|
/**
|
|
182
171
|
* @param index 0 = first; -1 = last.
|
|
@@ -241,7 +230,7 @@ int selva_fields_set_reference_meta(
|
|
|
241
230
|
struct SelvaNode *node,
|
|
242
231
|
struct SelvaNodeReference *ref,
|
|
243
232
|
const struct EdgeFieldConstraint *efc,
|
|
244
|
-
|
|
233
|
+
const struct SelvaFieldSchema *efs,
|
|
245
234
|
const void *value, size_t len);
|
|
246
235
|
|
|
247
236
|
SELVA_EXPORT
|
|
@@ -267,7 +256,6 @@ SELVA_EXPORT
|
|
|
267
256
|
int selva_fields_set_string(
|
|
268
257
|
struct SelvaNode *node,
|
|
269
258
|
const struct SelvaFieldSchema *fs,
|
|
270
|
-
struct SelvaFieldInfo *nfo,
|
|
271
259
|
const char *str,
|
|
272
260
|
size_t len);
|
|
273
261
|
|
|
@@ -304,6 +292,24 @@ int selva_fields_get_text(
|
|
|
304
292
|
const char **str,
|
|
305
293
|
size_t *len);
|
|
306
294
|
|
|
295
|
+
SELVA_EXPORT
|
|
296
|
+
int selva_fields_set_micro_buffer(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, const void *value, size_t len);
|
|
297
|
+
|
|
298
|
+
SELVA_EXPORT
|
|
299
|
+
int selva_fields_set_micro_buffer2(struct SelvaNode *node, const struct SelvaFieldSchema *fs, const void *value, size_t len);
|
|
300
|
+
|
|
301
|
+
SELVA_EXPORT
|
|
302
|
+
int selva_fields_set_weak_reference(struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst);
|
|
303
|
+
|
|
304
|
+
SELVA_EXPORT
|
|
305
|
+
int selva_fields_set_weak_reference2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, node_id_t dst);
|
|
306
|
+
|
|
307
|
+
SELVA_EXPORT
|
|
308
|
+
int selva_fields_set_weak_references2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, node_id_t dst[], size_t nr_dsts);
|
|
309
|
+
|
|
310
|
+
SELVA_EXPORT
|
|
311
|
+
int selva_fields_set_weak_references(struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst[], size_t nr_dsts);
|
|
312
|
+
|
|
307
313
|
SELVA_EXPORT
|
|
308
314
|
struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
309
315
|
__attribute__((nonnull));
|
|
@@ -313,11 +319,11 @@ struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, stru
|
|
|
313
319
|
__attribute__((nonnull));
|
|
314
320
|
|
|
315
321
|
SELVA_EXPORT
|
|
316
|
-
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct
|
|
322
|
+
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaFields *fields, field_t field)
|
|
317
323
|
__attribute__((nonnull));
|
|
318
324
|
|
|
319
325
|
SELVA_EXPORT
|
|
320
|
-
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct
|
|
326
|
+
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaFields *fields, field_t field)
|
|
321
327
|
__attribute__((nonnull));
|
|
322
328
|
|
|
323
329
|
SELVA_EXPORT
|
|
@@ -339,6 +345,9 @@ SELVA_EXPORT
|
|
|
339
345
|
struct selva_string *selva_fields_get_selva_string(struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
340
346
|
__attribute__((nonnull));
|
|
341
347
|
|
|
348
|
+
SELVA_EXPORT
|
|
349
|
+
struct SelvaFieldInfo *selva_field_get_nfo(struct SelvaFields *fields, const struct SelvaFieldSchema *fs);
|
|
350
|
+
|
|
342
351
|
SELVA_EXPORT
|
|
343
352
|
struct SelvaFieldsPointer selva_fields_get_raw2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs)
|
|
344
353
|
__attribute__((nonnull));
|
|
@@ -375,6 +384,9 @@ SELVA_EXPORT
|
|
|
375
384
|
void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaFields *fields)
|
|
376
385
|
__attribute__((nonnull));
|
|
377
386
|
|
|
387
|
+
void selva_fields_init_node(struct SelvaTypeEntry *te, struct SelvaNode *node)
|
|
388
|
+
__attribute__((nonnull));
|
|
389
|
+
|
|
378
390
|
/**
|
|
379
391
|
* Destroy all fields of a node.
|
|
380
392
|
*/
|
|
@@ -17,10 +17,12 @@ void hll_add(struct selva_string *hllss, uint64_t element);
|
|
|
17
17
|
SELVA_EXPORT
|
|
18
18
|
uint8_t *hll_count(struct selva_string *hllss);
|
|
19
19
|
SELVA_EXPORT
|
|
20
|
-
struct selva_string
|
|
20
|
+
void hll_array_union(struct selva_string *res, struct selva_string *hll_array, size_t count);
|
|
21
|
+
SELVA_EXPORT
|
|
22
|
+
void hll_union(char*, size_t, const char*, size_t);
|
|
21
23
|
|
|
22
24
|
// size_t actual_cols[13] = { 79, 159, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 };
|
|
23
|
-
// float raw_estimate_data[13][200] =
|
|
25
|
+
// float raw_estimate_data[13][200] =
|
|
24
26
|
// {
|
|
25
27
|
// // precision 4
|
|
26
28
|
// { 11, 11.717, 12.207, 12.7896, 13.2882, 13.8204, 14.3772, 14.9342, 15.5202, 16.161, 16.7722,17.4636, 18.0396, 18.6766, 19.3566, 20.0454, 20.7936, 21.4856, 22.2666, 22.9946, 23.766,24.4692, 25.3638, 26.0764, 26.7864, 27.7602, 28.4814, 29.433, 30.2926, 31.0664, 31.9996,32.7956, 33.5366, 34.5894, 35.5738, 36.2698, 37.3682, 38.0544, 39.2342, 40.0108, 40.7966,41.9298, 42.8704, 43.6358, 44.5194, 45.773, 46.6772, 47.6174, 48.4888, 49.3304, 50.2506,51.4996, 52.3824, 53.3078, 54.3984, 55.5838, 56.6618, 57.2174, 58.3514, 59.0802, 60.1482,61.0376, 62.3598, 62.8078, 63.9744, 64.914, 65.781, 67.1806, 68.0594, 68.8446, 69.7928,70.8248, 71.8324, 72.8598, 73.6246, 74.7014, 75.393, 76.6708, 77.2394, },
|
|
@@ -78,4 +80,4 @@ struct selva_string hll_array_union(struct selva_string *hll_array, size_t count
|
|
|
78
80
|
// // precision 16
|
|
79
81
|
// { 47270, 46423.3584, 45585.7074, 44757.152, 43938.8416, 43130.9514, 42330.03, 41540.407,40759.6348, 39988.206, 39226.5144, 38473.2096, 37729.795, 36997.268, 36272.6448, 35558.665,34853.0248, 34157.4472, 33470.5204, 32793.5742, 32127.0194, 31469.4182, 30817.6136,30178.6968, 29546.8908, 28922.8544, 28312.271, 27707.0924, 27114.0326, 26526.692, 25948.6336,25383.7826, 24823.5998, 24272.2974, 23732.2572, 23201.4976, 22674.2796, 22163.6336, 21656.515,21161.7362, 20669.9368, 20189.4424, 19717.3358, 19256.3744, 18795.9638, 18352.197, 17908.5738,17474.391, 17052.918, 16637.2236, 16228.4602, 15823.3474, 15428.6974, 15043.0284, 14667.6278,14297.4588, 13935.2882, 13578.5402, 13234.6032, 12882.1578, 12548.0728, 12219.231, 11898.0072,11587.2626, 11279.9072, 10973.5048, 10678.5186, 10392.4876, 10105.2556, 9825.766, 9562.5444,9294.2222, 9038.2352, 8784.848, 8533.2644, 8301.7776, 8058.30859999999, 7822.94579999999,7599.11319999999, 7366.90779999999, 7161.217, 6957.53080000001, 6736.212, 6548.21220000001,6343.06839999999, 6156.28719999999, 5975.15419999999, 5791.75719999999, 5621.32019999999,5451.66, 5287.61040000001, 5118.09479999999, 4957.288, 4798.4246, 4662.17559999999,4512.05900000001, 4364.68539999999, 4220.77720000001, 4082.67259999999, 3957.19519999999,3842.15779999999, 3699.3328, 3583.01180000001, 3473.8964, 3338.66639999999, 3233.55559999999,3117.799, 3008.111, 2909.69140000001, 2814.86499999999, 2719.46119999999, 2624.742,2532.46979999999, 2444.7886, 2370.1868, 2272.45259999999, 2196.19260000001, 2117.90419999999,2023.2972, 1969.76819999999, 1885.58979999999, 1833.2824, 1733.91200000001, 1682.54920000001,1604.57980000001, 1556.11240000001, 1491.3064, 1421.71960000001, 1371.22899999999, 1322.1324,1264.7892, 1196.23920000001, 1143.8474, 1088.67240000001, 1073.60380000001, 1023.11660000001,959.036400000012, 927.433199999999, 906.792799999996, 853.433599999989, 841.873800000001,791.1054, 756.899999999994, 704.343200000003, 672.495599999995, 622.790399999998,611.254799999995, 567.283200000005, 519.406599999988, 519.188400000014, 495.312800000014,451.350799999986, 443.973399999988, 431.882199999993, 392.027000000002, 380.924200000009,345.128999999986, 298.901400000002, 287.771999999997, 272.625, 247.253000000026,222.490600000019, 223.590000000026, 196.407599999977, 176.425999999978, 134.725199999986,132.4804, 110.445599999977, 86.7939999999944, 56.7038000000175, 64.915399999998,38.3726000000024, 37.1606000000029, 46.170999999973, 49.1716000000015, 15.3362000000197,6.71639999997569,-34.8185999999987,-39.4476000000141, 12.6830000000191,-12.3331999999937,-50.6565999999875,-59.9538000000175,-65.1054000000004,-70.7576000000117,-106.325200000021,-126.852200000023,-110.227599999984,-132.885999999999,-113.897200000007,-142.713800000027,-151.145399999979,-150.799200000009,-177.756200000003,-156.036399999983,-182.735199999996,-177.259399999981,-198.663600000029,-174.577600000019,-193.84580000001, },
|
|
80
82
|
// };
|
|
81
|
-
#endif
|
|
83
|
+
#endif
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#include "selva/_export.h"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read memory barrier.
|
|
9
|
+
* Call this function before read in case another thread has potentially
|
|
10
|
+
* written to the memory addresses the current thread is going to access.
|
|
11
|
+
*/
|
|
12
|
+
SELVA_EXPORT
|
|
13
|
+
__attribute__((no_reorder))
|
|
14
|
+
void membar_sync_read(void);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Write memory barrier.
|
|
18
|
+
* Call this function after write to memory when another thread is expected to
|
|
19
|
+
* read the written data.
|
|
20
|
+
*/
|
|
21
|
+
SELVA_EXPORT
|
|
22
|
+
__attribute__((no_reorder))
|
|
23
|
+
void membar_sync_write(void);
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2024 SAULX
|
|
2
|
+
* Copyright (c) 2024-2025 SAULX
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
7
|
#include "selva/_export.h"
|
|
8
|
+
#include "libdeflate.h"
|
|
8
9
|
|
|
9
10
|
SELVA_EXPORT
|
|
10
|
-
void worker_ctx_init();
|
|
11
|
+
void worker_ctx_init(void);
|
|
11
12
|
|
|
12
13
|
SELVA_EXPORT
|
|
13
|
-
void worker_ctx_deinit();
|
|
14
|
+
void worker_ctx_deinit(void);
|
|
15
|
+
|
|
16
|
+
SELVA_EXPORT
|
|
17
|
+
enum libdeflate_result worker_ctx_libdeflate_decompress(
|
|
18
|
+
const void *in, size_t in_nbytes,
|
|
19
|
+
void *out, size_t out_nbytes_avail,
|
|
20
|
+
size_t *actual_out_nbytes_ret);
|
|
21
|
+
|
|
22
|
+
SELVA_EXPORT
|
|
23
|
+
enum libdeflate_result worker_ctx_libdeflate_decompress_stream(
|
|
24
|
+
const char *in_buf, size_t in_len,
|
|
25
|
+
libdeflate_decompress_stream_cb_t cb, void *ctx,
|
|
26
|
+
int *result);
|
|
27
|
+
|
|
28
|
+
SELVA_EXPORT
|
|
29
|
+
bool worker_ctx_libdeflate_block_state_growbuf(void);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -42,24 +42,24 @@ SELVA_EXPORT
|
|
|
42
42
|
int selva_dump_save_common(struct SelvaDb *db, const char *filename) __attribute__((nonnull));
|
|
43
43
|
|
|
44
44
|
/**
|
|
45
|
-
* Save a
|
|
45
|
+
* Save a nodes block starting from start.
|
|
46
46
|
*/
|
|
47
47
|
SELVA_EXPORT
|
|
48
|
-
int
|
|
48
|
+
int selva_dump_save_block(struct SelvaDb *db, struct SelvaTypeEntry *te, const char *filename, node_id_t start, selva_hash128_t *range_hash_out) __attribute__((nonnull));
|
|
49
49
|
|
|
50
50
|
/**
|
|
51
51
|
* **Usage:**
|
|
52
52
|
* ```c
|
|
53
53
|
* struct SelvaDb *db = selva_db_create();
|
|
54
54
|
* selva_dump_load_common(db, filename_common);
|
|
55
|
-
*
|
|
55
|
+
* selva_dump_load_block(db, filename_range_n);
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
58
|
SELVA_EXPORT
|
|
59
59
|
int selva_dump_load_common(struct SelvaDb *db, const char *filename, char *errlog_buf, size_t errlog_size) __attribute__((nonnull));
|
|
60
60
|
|
|
61
61
|
SELVA_EXPORT
|
|
62
|
-
int
|
|
62
|
+
int selva_dump_load_block(struct SelvaDb *db, const char *filename, char *errlog_buf, size_t errlog_size) __attribute__((nonnull));
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Find a type by type id.
|
|
@@ -83,6 +83,32 @@ inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
|
|
|
83
83
|
;
|
|
84
84
|
#endif
|
|
85
85
|
|
|
86
|
+
inline block_id_t selva_node_id2block_i3(block_id_t block_capacity, node_id_t node_id)
|
|
87
|
+
{
|
|
88
|
+
assert(node_id > 0);
|
|
89
|
+
return ((node_id - 1) - ((node_id - 1) % block_capacity)) / block_capacity;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
SELVA_EXPORT
|
|
93
|
+
inline block_id_t selva_node_id2block_i(const struct SelvaTypeBlocks *blocks, node_id_t node_id)
|
|
94
|
+
#ifndef __zig
|
|
95
|
+
{
|
|
96
|
+
return selva_node_id2block_i3(blocks->block_capacity, node_id);
|
|
97
|
+
}
|
|
98
|
+
#else
|
|
99
|
+
;
|
|
100
|
+
#endif
|
|
101
|
+
|
|
102
|
+
SELVA_EXPORT
|
|
103
|
+
inline block_id_t selva_node_id2block_i2(const struct SelvaTypeEntry *te, node_id_t node_id)
|
|
104
|
+
#ifndef __zig
|
|
105
|
+
{
|
|
106
|
+
return selva_node_id2block_i(te->blocks, node_id);
|
|
107
|
+
}
|
|
108
|
+
#else
|
|
109
|
+
;
|
|
110
|
+
#endif
|
|
111
|
+
|
|
86
112
|
/**
|
|
87
113
|
* Get the node schema for type.
|
|
88
114
|
*/
|
|
@@ -46,7 +46,7 @@ struct SelvaNodeReferences {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
struct SelvaNodeWeakReference {
|
|
49
|
-
/*
|
|
49
|
+
/* The type can be found from the schema. */
|
|
50
50
|
#if 0
|
|
51
51
|
node_type_t dst_type;
|
|
52
52
|
#endif
|
|
@@ -99,11 +99,15 @@ __purefn
|
|
|
99
99
|
#endif
|
|
100
100
|
size_t selva_fields_get_data_size(const struct SelvaFieldSchema *fs);
|
|
101
101
|
|
|
102
|
+
SELVA_EXPORT
|
|
102
103
|
#if __has_c_attribute(reproducible)
|
|
103
104
|
[[reproducible]]
|
|
104
105
|
#endif
|
|
105
106
|
void *selva_fields_nfo2p(struct SelvaFields *fields, const struct SelvaFieldInfo *nfo);
|
|
106
107
|
|
|
108
|
+
SELVA_EXPORT
|
|
109
|
+
struct SelvaFields *selva_fields_node2fields(struct SelvaNode *node);
|
|
110
|
+
|
|
107
111
|
void selva_fields_ensure_ref_meta(
|
|
108
112
|
struct SelvaDb *db,
|
|
109
113
|
struct SelvaNode *node,
|
|
@@ -118,19 +122,7 @@ SELVA_EXPORT
|
|
|
118
122
|
int selva_fields_set(
|
|
119
123
|
struct SelvaNode *node,
|
|
120
124
|
const struct SelvaFieldSchema *fs,
|
|
121
|
-
const void *value, size_t len);
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Set field value by a `fields` pointer.
|
|
125
|
-
* @param fields can be either `node->fields` or any other `fields` structure
|
|
126
|
-
* associated with the given node (currently edge).
|
|
127
|
-
*/
|
|
128
|
-
SELVA_EXPORT
|
|
129
|
-
int fields_set2(
|
|
130
|
-
struct SelvaNode *node,
|
|
131
|
-
const struct SelvaFieldSchema *fs,
|
|
132
|
-
struct SelvaFields *fields,
|
|
133
|
-
const void *value, size_t len);
|
|
125
|
+
const void *value, size_t len) __attribute__((deprecated));
|
|
134
126
|
|
|
135
127
|
SELVA_EXPORT
|
|
136
128
|
int selva_fields_get_mutable_string(
|
|
@@ -163,10 +155,6 @@ struct selva_string *selva_fields_ensure_string2(
|
|
|
163
155
|
|
|
164
156
|
/**
|
|
165
157
|
* Set reference to fields.
|
|
166
|
-
* @param dirty_nodes returns the nodes that were changed, apart from src and dst.
|
|
167
|
-
* [n].id = 0 = nil;
|
|
168
|
-
* [0] = the node src was pointing to previously (same type as dst);
|
|
169
|
-
* [1] = the node dst was pointing to previously (same type as src).
|
|
170
158
|
*/
|
|
171
159
|
SELVA_EXPORT
|
|
172
160
|
int selva_fields_reference_set(
|
|
@@ -175,8 +163,9 @@ int selva_fields_reference_set(
|
|
|
175
163
|
const struct SelvaFieldSchema *fs_src,
|
|
176
164
|
struct SelvaNode * restrict dst,
|
|
177
165
|
struct SelvaNodeReference **ref_out,
|
|
178
|
-
|
|
179
|
-
|
|
166
|
+
selva_dirty_node_cb_t dirty_cb,
|
|
167
|
+
void *dirty_ctx);
|
|
168
|
+
// __attribute__((access(write_only, 5), access(write_only, 6)));
|
|
180
169
|
|
|
181
170
|
/**
|
|
182
171
|
* @param index 0 = first; -1 = last.
|
|
@@ -241,7 +230,7 @@ int selva_fields_set_reference_meta(
|
|
|
241
230
|
struct SelvaNode *node,
|
|
242
231
|
struct SelvaNodeReference *ref,
|
|
243
232
|
const struct EdgeFieldConstraint *efc,
|
|
244
|
-
|
|
233
|
+
const struct SelvaFieldSchema *efs,
|
|
245
234
|
const void *value, size_t len);
|
|
246
235
|
|
|
247
236
|
SELVA_EXPORT
|
|
@@ -267,7 +256,6 @@ SELVA_EXPORT
|
|
|
267
256
|
int selva_fields_set_string(
|
|
268
257
|
struct SelvaNode *node,
|
|
269
258
|
const struct SelvaFieldSchema *fs,
|
|
270
|
-
struct SelvaFieldInfo *nfo,
|
|
271
259
|
const char *str,
|
|
272
260
|
size_t len);
|
|
273
261
|
|
|
@@ -304,6 +292,24 @@ int selva_fields_get_text(
|
|
|
304
292
|
const char **str,
|
|
305
293
|
size_t *len);
|
|
306
294
|
|
|
295
|
+
SELVA_EXPORT
|
|
296
|
+
int selva_fields_set_micro_buffer(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, const void *value, size_t len);
|
|
297
|
+
|
|
298
|
+
SELVA_EXPORT
|
|
299
|
+
int selva_fields_set_micro_buffer2(struct SelvaNode *node, const struct SelvaFieldSchema *fs, const void *value, size_t len);
|
|
300
|
+
|
|
301
|
+
SELVA_EXPORT
|
|
302
|
+
int selva_fields_set_weak_reference(struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst);
|
|
303
|
+
|
|
304
|
+
SELVA_EXPORT
|
|
305
|
+
int selva_fields_set_weak_reference2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, node_id_t dst);
|
|
306
|
+
|
|
307
|
+
SELVA_EXPORT
|
|
308
|
+
int selva_fields_set_weak_references2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs, node_id_t dst[], size_t nr_dsts);
|
|
309
|
+
|
|
310
|
+
SELVA_EXPORT
|
|
311
|
+
int selva_fields_set_weak_references(struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst[], size_t nr_dsts);
|
|
312
|
+
|
|
307
313
|
SELVA_EXPORT
|
|
308
314
|
struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
309
315
|
__attribute__((nonnull));
|
|
@@ -313,11 +319,11 @@ struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, stru
|
|
|
313
319
|
__attribute__((nonnull));
|
|
314
320
|
|
|
315
321
|
SELVA_EXPORT
|
|
316
|
-
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct
|
|
322
|
+
struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaFields *fields, field_t field)
|
|
317
323
|
__attribute__((nonnull));
|
|
318
324
|
|
|
319
325
|
SELVA_EXPORT
|
|
320
|
-
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct
|
|
326
|
+
struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaFields *fields, field_t field)
|
|
321
327
|
__attribute__((nonnull));
|
|
322
328
|
|
|
323
329
|
SELVA_EXPORT
|
|
@@ -339,6 +345,9 @@ SELVA_EXPORT
|
|
|
339
345
|
struct selva_string *selva_fields_get_selva_string(struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
340
346
|
__attribute__((nonnull));
|
|
341
347
|
|
|
348
|
+
SELVA_EXPORT
|
|
349
|
+
struct SelvaFieldInfo *selva_field_get_nfo(struct SelvaFields *fields, const struct SelvaFieldSchema *fs);
|
|
350
|
+
|
|
342
351
|
SELVA_EXPORT
|
|
343
352
|
struct SelvaFieldsPointer selva_fields_get_raw2(struct SelvaFields *fields, const struct SelvaFieldSchema *fs)
|
|
344
353
|
__attribute__((nonnull));
|
|
@@ -375,6 +384,9 @@ SELVA_EXPORT
|
|
|
375
384
|
void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaFields *fields)
|
|
376
385
|
__attribute__((nonnull));
|
|
377
386
|
|
|
387
|
+
void selva_fields_init_node(struct SelvaTypeEntry *te, struct SelvaNode *node)
|
|
388
|
+
__attribute__((nonnull));
|
|
389
|
+
|
|
378
390
|
/**
|
|
379
391
|
* Destroy all fields of a node.
|
|
380
392
|
*/
|
|
@@ -17,10 +17,12 @@ void hll_add(struct selva_string *hllss, uint64_t element);
|
|
|
17
17
|
SELVA_EXPORT
|
|
18
18
|
uint8_t *hll_count(struct selva_string *hllss);
|
|
19
19
|
SELVA_EXPORT
|
|
20
|
-
struct selva_string
|
|
20
|
+
void hll_array_union(struct selva_string *res, struct selva_string *hll_array, size_t count);
|
|
21
|
+
SELVA_EXPORT
|
|
22
|
+
void hll_union(char*, size_t, const char*, size_t);
|
|
21
23
|
|
|
22
24
|
// size_t actual_cols[13] = { 79, 159, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 };
|
|
23
|
-
// float raw_estimate_data[13][200] =
|
|
25
|
+
// float raw_estimate_data[13][200] =
|
|
24
26
|
// {
|
|
25
27
|
// // precision 4
|
|
26
28
|
// { 11, 11.717, 12.207, 12.7896, 13.2882, 13.8204, 14.3772, 14.9342, 15.5202, 16.161, 16.7722,17.4636, 18.0396, 18.6766, 19.3566, 20.0454, 20.7936, 21.4856, 22.2666, 22.9946, 23.766,24.4692, 25.3638, 26.0764, 26.7864, 27.7602, 28.4814, 29.433, 30.2926, 31.0664, 31.9996,32.7956, 33.5366, 34.5894, 35.5738, 36.2698, 37.3682, 38.0544, 39.2342, 40.0108, 40.7966,41.9298, 42.8704, 43.6358, 44.5194, 45.773, 46.6772, 47.6174, 48.4888, 49.3304, 50.2506,51.4996, 52.3824, 53.3078, 54.3984, 55.5838, 56.6618, 57.2174, 58.3514, 59.0802, 60.1482,61.0376, 62.3598, 62.8078, 63.9744, 64.914, 65.781, 67.1806, 68.0594, 68.8446, 69.7928,70.8248, 71.8324, 72.8598, 73.6246, 74.7014, 75.393, 76.6708, 77.2394, },
|
|
@@ -78,4 +80,4 @@ struct selva_string hll_array_union(struct selva_string *hll_array, size_t count
|
|
|
78
80
|
// // precision 16
|
|
79
81
|
// { 47270, 46423.3584, 45585.7074, 44757.152, 43938.8416, 43130.9514, 42330.03, 41540.407,40759.6348, 39988.206, 39226.5144, 38473.2096, 37729.795, 36997.268, 36272.6448, 35558.665,34853.0248, 34157.4472, 33470.5204, 32793.5742, 32127.0194, 31469.4182, 30817.6136,30178.6968, 29546.8908, 28922.8544, 28312.271, 27707.0924, 27114.0326, 26526.692, 25948.6336,25383.7826, 24823.5998, 24272.2974, 23732.2572, 23201.4976, 22674.2796, 22163.6336, 21656.515,21161.7362, 20669.9368, 20189.4424, 19717.3358, 19256.3744, 18795.9638, 18352.197, 17908.5738,17474.391, 17052.918, 16637.2236, 16228.4602, 15823.3474, 15428.6974, 15043.0284, 14667.6278,14297.4588, 13935.2882, 13578.5402, 13234.6032, 12882.1578, 12548.0728, 12219.231, 11898.0072,11587.2626, 11279.9072, 10973.5048, 10678.5186, 10392.4876, 10105.2556, 9825.766, 9562.5444,9294.2222, 9038.2352, 8784.848, 8533.2644, 8301.7776, 8058.30859999999, 7822.94579999999,7599.11319999999, 7366.90779999999, 7161.217, 6957.53080000001, 6736.212, 6548.21220000001,6343.06839999999, 6156.28719999999, 5975.15419999999, 5791.75719999999, 5621.32019999999,5451.66, 5287.61040000001, 5118.09479999999, 4957.288, 4798.4246, 4662.17559999999,4512.05900000001, 4364.68539999999, 4220.77720000001, 4082.67259999999, 3957.19519999999,3842.15779999999, 3699.3328, 3583.01180000001, 3473.8964, 3338.66639999999, 3233.55559999999,3117.799, 3008.111, 2909.69140000001, 2814.86499999999, 2719.46119999999, 2624.742,2532.46979999999, 2444.7886, 2370.1868, 2272.45259999999, 2196.19260000001, 2117.90419999999,2023.2972, 1969.76819999999, 1885.58979999999, 1833.2824, 1733.91200000001, 1682.54920000001,1604.57980000001, 1556.11240000001, 1491.3064, 1421.71960000001, 1371.22899999999, 1322.1324,1264.7892, 1196.23920000001, 1143.8474, 1088.67240000001, 1073.60380000001, 1023.11660000001,959.036400000012, 927.433199999999, 906.792799999996, 853.433599999989, 841.873800000001,791.1054, 756.899999999994, 704.343200000003, 672.495599999995, 622.790399999998,611.254799999995, 567.283200000005, 519.406599999988, 519.188400000014, 495.312800000014,451.350799999986, 443.973399999988, 431.882199999993, 392.027000000002, 380.924200000009,345.128999999986, 298.901400000002, 287.771999999997, 272.625, 247.253000000026,222.490600000019, 223.590000000026, 196.407599999977, 176.425999999978, 134.725199999986,132.4804, 110.445599999977, 86.7939999999944, 56.7038000000175, 64.915399999998,38.3726000000024, 37.1606000000029, 46.170999999973, 49.1716000000015, 15.3362000000197,6.71639999997569,-34.8185999999987,-39.4476000000141, 12.6830000000191,-12.3331999999937,-50.6565999999875,-59.9538000000175,-65.1054000000004,-70.7576000000117,-106.325200000021,-126.852200000023,-110.227599999984,-132.885999999999,-113.897200000007,-142.713800000027,-151.145399999979,-150.799200000009,-177.756200000003,-156.036399999983,-182.735199999996,-177.259399999981,-198.663600000029,-174.577600000019,-193.84580000001, },
|
|
80
82
|
// };
|
|
81
|
-
#endif
|
|
83
|
+
#endif
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#include "selva/_export.h"
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Read memory barrier.
|
|
9
|
+
* Call this function before read in case another thread has potentially
|
|
10
|
+
* written to the memory addresses the current thread is going to access.
|
|
11
|
+
*/
|
|
12
|
+
SELVA_EXPORT
|
|
13
|
+
__attribute__((no_reorder))
|
|
14
|
+
void membar_sync_read(void);
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Write memory barrier.
|
|
18
|
+
* Call this function after write to memory when another thread is expected to
|
|
19
|
+
* read the written data.
|
|
20
|
+
*/
|
|
21
|
+
SELVA_EXPORT
|
|
22
|
+
__attribute__((no_reorder))
|
|
23
|
+
void membar_sync_write(void);
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (c) 2024 SAULX
|
|
2
|
+
* Copyright (c) 2024-2025 SAULX
|
|
3
3
|
* SPDX-License-Identifier: MIT
|
|
4
4
|
*/
|
|
5
5
|
#pragma once
|
|
6
6
|
|
|
7
7
|
#include "selva/_export.h"
|
|
8
|
+
#include "libdeflate.h"
|
|
8
9
|
|
|
9
10
|
SELVA_EXPORT
|
|
10
|
-
void worker_ctx_init();
|
|
11
|
+
void worker_ctx_init(void);
|
|
11
12
|
|
|
12
13
|
SELVA_EXPORT
|
|
13
|
-
void worker_ctx_deinit();
|
|
14
|
+
void worker_ctx_deinit(void);
|
|
15
|
+
|
|
16
|
+
SELVA_EXPORT
|
|
17
|
+
enum libdeflate_result worker_ctx_libdeflate_decompress(
|
|
18
|
+
const void *in, size_t in_nbytes,
|
|
19
|
+
void *out, size_t out_nbytes_avail,
|
|
20
|
+
size_t *actual_out_nbytes_ret);
|
|
21
|
+
|
|
22
|
+
SELVA_EXPORT
|
|
23
|
+
enum libdeflate_result worker_ctx_libdeflate_decompress_stream(
|
|
24
|
+
const char *in_buf, size_t in_len,
|
|
25
|
+
libdeflate_decompress_stream_cb_t cb, void *ctx,
|
|
26
|
+
int *result);
|
|
27
|
+
|
|
28
|
+
SELVA_EXPORT
|
|
29
|
+
bool worker_ctx_libdeflate_block_state_growbuf(void);
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|