@based/db 0.0.31 → 0.0.32
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/README.md +565 -3
- package/dist/lib/darwin_aarch64/include/selva/db.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/fields.h +0 -2
- 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/libselva.dylib +0 -0
- package/dist/src/client/flushModify.d.ts +1 -1
- package/dist/src/client/flushModify.js +5 -4
- package/dist/src/client/index.d.ts +3 -2
- package/dist/src/client/modify/binary.js +1 -1
- package/dist/src/client/modify/cardinality.js +1 -1
- package/dist/src/client/modify/references/appendEdgeRefs.js +3 -0
- package/dist/src/client/modify/references/edge.js +6 -0
- package/dist/src/client/modify/references/getEdgeSize.js +1 -1
- package/dist/src/client/modify/string.js +10 -4
- package/dist/src/client/modify/text.js +1 -9
- package/dist/src/client/modify/types.d.ts +1 -0
- package/dist/src/client/modify/types.js +1 -0
- package/dist/src/client/modify/upsert.js +33 -21
- package/dist/src/client/query/BasedDbQuery.js +1 -1
- package/dist/src/client/query/BasedIterable.d.ts +2 -2
- package/dist/src/client/query/BasedIterable.js +7 -1
- package/dist/src/client/query/aggregates/aggregation.d.ts +4 -0
- package/dist/src/client/query/aggregates/aggregation.js +12 -0
- package/dist/src/client/query/aggregation.d.ts +1 -1
- package/dist/src/client/query/debug.js +3 -2
- package/dist/src/client/query/display.js +1 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +1 -1
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +1 -1
- package/dist/src/client/query/filter/parseFilterValue.js +1 -2
- package/dist/src/client/query/queryDef.js +2 -2
- package/dist/src/client/query/read/read.js +4 -14
- package/dist/src/client/query/registerQuery.js +1 -1
- package/dist/src/client/query/search/index.d.ts +1 -1
- package/dist/src/client/query/search/index.js +1 -1
- package/dist/src/client/query/sort.d.ts +1 -1
- package/dist/src/client/query/toBuffer.js +11 -15
- package/dist/src/client/query/types.d.ts +7 -0
- package/dist/src/client/query/types.js +8 -0
- package/dist/src/client/query/validation.d.ts +1 -1
- package/dist/src/client/query/validation.js +4 -5
- package/dist/src/client/string.js +1 -3
- package/dist/src/client/xxHash64.d.ts +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.js +5 -1
- package/dist/src/native.d.ts +1 -2
- package/dist/src/native.js +2 -5
- package/dist/src/server/csmt/draw-dot.d.ts +3 -1
- package/dist/src/server/csmt/draw-dot.js +7 -2
- package/dist/src/server/csmt/match.d.ts +1 -1
- package/dist/src/server/csmt/memebership-proof.d.ts +1 -1
- package/dist/src/server/csmt/tree-utils.d.ts +4 -4
- package/dist/src/server/csmt/tree.d.ts +1 -1
- package/dist/src/server/csmt/tree.js +1 -1
- package/dist/src/server/csmt/types.d.ts +10 -10
- package/dist/src/server/dbHash.d.ts +1 -1
- package/dist/src/server/dbHash.js +1 -1
- package/dist/src/server/index.d.ts +8 -4
- package/dist/src/server/index.js +28 -13
- package/dist/src/server/migrate/worker.js +11 -0
- package/dist/src/server/save.js +3 -2
- package/dist/src/server/start.js +9 -5
- package/dist/src/utils.d.ts +0 -10
- package/dist/src/utils.js +0 -152
- package/package.json +3 -3
- package/dist/lib/darwin_aarch64/include/selva/xxhash64.h +0 -23
- 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/linux_aarch64/include/cdefs.h +0 -317
- package/dist/lib/linux_aarch64/include/jemalloc.h +0 -468
- package/dist/lib/linux_aarch64/include/libdeflate.h +0 -322
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +0 -35
- package/dist/lib/linux_aarch64/include/linker_set.h +0 -109
- package/dist/lib/linux_aarch64/include/queue.h +0 -627
- package/dist/lib/linux_aarch64/include/selva/_export.h +0 -7
- package/dist/lib/linux_aarch64/include/selva/align.h +0 -9
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +0 -29
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +0 -95
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +0 -17
- package/dist/lib/linux_aarch64/include/selva/ctime.h +0 -135
- package/dist/lib/linux_aarch64/include/selva/db.h +0 -418
- package/dist/lib/linux_aarch64/include/selva/endian.h +0 -301
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +0 -23
- package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +0 -18
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +0 -11
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +0 -36
- package/dist/lib/linux_aarch64/include/selva/fields.h +0 -383
- package/dist/lib/linux_aarch64/include/selva/find.h +0 -47
- package/dist/lib/linux_aarch64/include/selva/history.h +0 -64
- package/dist/lib/linux_aarch64/include/selva/hll.h +0 -81
- package/dist/lib/linux_aarch64/include/selva/lpf.h +0 -28
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +0 -43
- package/dist/lib/linux_aarch64/include/selva/poptop.h +0 -114
- package/dist/lib/linux_aarch64/include/selva/queue_r.h +0 -190
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +0 -49
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +0 -105
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +0 -37
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +0 -674
- package/dist/lib/linux_aarch64/include/selva/sort.h +0 -140
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +0 -43
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +0 -25
- package/dist/lib/linux_aarch64/include/selva/traverse.h +0 -65
- package/dist/lib/linux_aarch64/include/selva/types.h +0 -106
- package/dist/lib/linux_aarch64/include/selva/vector.h +0 -35
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -13
- package/dist/lib/linux_aarch64/include/selva/xxhash64.h +0 -23
- package/dist/lib/linux_aarch64/include/selva_error.h +0 -137
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +0 -157
- package/dist/lib/linux_aarch64/include/tree.h +0 -852
- 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 +0 -317
- package/dist/lib/linux_x86_64/include/jemalloc.h +0 -468
- package/dist/lib/linux_x86_64/include/libdeflate.h +0 -322
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +0 -35
- package/dist/lib/linux_x86_64/include/linker_set.h +0 -109
- package/dist/lib/linux_x86_64/include/queue.h +0 -627
- package/dist/lib/linux_x86_64/include/selva/_export.h +0 -7
- package/dist/lib/linux_x86_64/include/selva/align.h +0 -9
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +0 -29
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +0 -95
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +0 -17
- package/dist/lib/linux_x86_64/include/selva/ctime.h +0 -135
- package/dist/lib/linux_x86_64/include/selva/db.h +0 -418
- package/dist/lib/linux_x86_64/include/selva/endian.h +0 -301
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +0 -23
- package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +0 -18
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +0 -11
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +0 -36
- package/dist/lib/linux_x86_64/include/selva/fields.h +0 -383
- package/dist/lib/linux_x86_64/include/selva/find.h +0 -47
- package/dist/lib/linux_x86_64/include/selva/history.h +0 -64
- package/dist/lib/linux_x86_64/include/selva/hll.h +0 -81
- package/dist/lib/linux_x86_64/include/selva/lpf.h +0 -28
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +0 -43
- package/dist/lib/linux_x86_64/include/selva/poptop.h +0 -114
- package/dist/lib/linux_x86_64/include/selva/queue_r.h +0 -190
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +0 -49
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +0 -105
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +0 -37
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +0 -674
- package/dist/lib/linux_x86_64/include/selva/sort.h +0 -140
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +0 -43
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +0 -25
- package/dist/lib/linux_x86_64/include/selva/traverse.h +0 -65
- package/dist/lib/linux_x86_64/include/selva/types.h +0 -106
- package/dist/lib/linux_x86_64/include/selva/vector.h +0 -35
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -13
- package/dist/lib/linux_x86_64/include/selva/xxhash64.h +0 -23
- package/dist/lib/linux_x86_64/include/selva_error.h +0 -137
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +0 -157
- package/dist/lib/linux_x86_64/include/tree.h +0 -852
- 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/query/subscription/markers.d.ts +0 -10
- package/dist/src/client/query/subscription/markers.js +0 -213
- package/dist/src/client/query/subscription/run.d.ts +0 -5
- package/dist/src/client/query/subscription/run.js +0 -76
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022-2025 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
#include <stdint.h>
|
|
7
|
-
#include <stddef.h>
|
|
8
|
-
#include "selva/_export.h"
|
|
9
|
-
#include "selva_lang_code.h"
|
|
10
|
-
|
|
11
|
-
/*
|
|
12
|
-
* Usage
|
|
13
|
-
* -----
|
|
14
|
-
*
|
|
15
|
-
* ```c
|
|
16
|
-
* struct SelvaSortCtx *sort = selva_sort_init(SELVA_SORT_ORDER_I64_ASC);
|
|
17
|
-
* selva_sort_insert_i64(sort, num, data);
|
|
18
|
-
*
|
|
19
|
-
* selva_sort_foreach_begin(sort);
|
|
20
|
-
* while (!selva_sort_foreach_done(sort)) {
|
|
21
|
-
* item = selva_sort_foreach(sort);
|
|
22
|
-
* print(item);
|
|
23
|
-
* }
|
|
24
|
-
*
|
|
25
|
-
* selva_sort_destroy(sort);
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
enum SelvaSortOrder {
|
|
30
|
-
SELVA_SORT_ORDER_NONE = 0,
|
|
31
|
-
SELVA_SORT_ORDER_I64_ASC,
|
|
32
|
-
SELVA_SORT_ORDER_I64_DESC,
|
|
33
|
-
SELVA_SORT_ORDER_FLOAT_ASC,
|
|
34
|
-
SELVA_SORT_ORDER_FLOAT_DESC,
|
|
35
|
-
SELVA_SORT_ORDER_DOUBLE_ASC,
|
|
36
|
-
SELVA_SORT_ORDER_DOUBLE_DESC,
|
|
37
|
-
SELVA_SORT_ORDER_BUFFER_ASC,
|
|
38
|
-
SELVA_SORT_ORDER_BUFFER_DESC,
|
|
39
|
-
SELVA_SORT_ORDER_TEXT_ASC,
|
|
40
|
-
SELVA_SORT_ORDER_TEXT_DESC,
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
struct SelvaSortItem;
|
|
44
|
-
struct SelvaSortCtx;
|
|
45
|
-
|
|
46
|
-
struct SelvaSortIterator {
|
|
47
|
-
struct SelvaSortItem *next;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
SELVA_EXPORT
|
|
51
|
-
struct SelvaSortCtx *selva_sort_init(enum SelvaSortOrder order);
|
|
52
|
-
|
|
53
|
-
SELVA_EXPORT
|
|
54
|
-
struct SelvaSortCtx *selva_sort_init2(enum SelvaSortOrder order, size_t fixed_size);
|
|
55
|
-
|
|
56
|
-
SELVA_EXPORT
|
|
57
|
-
void selva_sort_set_lang(struct SelvaSortCtx *ctx, enum selva_lang_code lang, enum selva_langs_trans trans);
|
|
58
|
-
|
|
59
|
-
SELVA_EXPORT
|
|
60
|
-
void selva_sort_destroy(struct SelvaSortCtx *ctx);
|
|
61
|
-
|
|
62
|
-
SELVA_EXPORT
|
|
63
|
-
void selva_sort_insert(struct SelvaSortCtx *ctx, const void *p);
|
|
64
|
-
|
|
65
|
-
SELVA_EXPORT
|
|
66
|
-
void selva_sort_insert_i64(struct SelvaSortCtx *ctx, int64_t v, const void *p);
|
|
67
|
-
|
|
68
|
-
SELVA_EXPORT
|
|
69
|
-
void selva_sort_insert_float(struct SelvaSortCtx *ctx, float f, const void *p);
|
|
70
|
-
|
|
71
|
-
SELVA_EXPORT
|
|
72
|
-
void selva_sort_insert_double(struct SelvaSortCtx *ctx, double d, const void *p);
|
|
73
|
-
|
|
74
|
-
SELVA_EXPORT
|
|
75
|
-
void selva_sort_insert_buf(struct SelvaSortCtx *ctx, const void *buf, size_t len, const void *p);
|
|
76
|
-
|
|
77
|
-
SELVA_EXPORT
|
|
78
|
-
void selva_sort_insert_text(struct SelvaSortCtx *ctx, const char *str, size_t len, const void *p);
|
|
79
|
-
|
|
80
|
-
SELVA_EXPORT
|
|
81
|
-
void selva_sort_remove(struct SelvaSortCtx *ctx, const void *p);
|
|
82
|
-
|
|
83
|
-
SELVA_EXPORT
|
|
84
|
-
void selva_sort_remove_i64(struct SelvaSortCtx *ctx, int64_t v, const void *p);
|
|
85
|
-
|
|
86
|
-
SELVA_EXPORT
|
|
87
|
-
void selva_sort_remove_float(struct SelvaSortCtx *ctx, float f, const void *p);
|
|
88
|
-
|
|
89
|
-
SELVA_EXPORT
|
|
90
|
-
void selva_sort_remove_double(struct SelvaSortCtx *ctx, double d, const void *p);
|
|
91
|
-
|
|
92
|
-
SELVA_EXPORT
|
|
93
|
-
void selva_sort_remove_buf(struct SelvaSortCtx *ctx, const void *buf, size_t len, const void *p);
|
|
94
|
-
|
|
95
|
-
SELVA_EXPORT
|
|
96
|
-
void selva_sort_remove_text(struct SelvaSortCtx *ctx, const char *str, size_t len, const void *p);
|
|
97
|
-
|
|
98
|
-
SELVA_EXPORT
|
|
99
|
-
void selva_sort_foreach_begin(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it);
|
|
100
|
-
|
|
101
|
-
SELVA_EXPORT
|
|
102
|
-
void selva_sort_foreach_begin_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it);
|
|
103
|
-
|
|
104
|
-
SELVA_EXPORT
|
|
105
|
-
void *selva_sort_foreach(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it);
|
|
106
|
-
|
|
107
|
-
SELVA_EXPORT
|
|
108
|
-
void *selva_sort_foreach_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it);
|
|
109
|
-
|
|
110
|
-
SELVA_EXPORT
|
|
111
|
-
void *selva_sort_foreach_i64(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, int64_t *v);
|
|
112
|
-
|
|
113
|
-
SELVA_EXPORT
|
|
114
|
-
void *selva_sort_foreach_i64_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, int64_t *v);
|
|
115
|
-
|
|
116
|
-
SELVA_EXPORT
|
|
117
|
-
void *selva_sort_foreach_float(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, float *f);
|
|
118
|
-
|
|
119
|
-
SELVA_EXPORT
|
|
120
|
-
void *selva_sort_foreach_float_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, float *f);
|
|
121
|
-
|
|
122
|
-
SELVA_EXPORT
|
|
123
|
-
void *selva_sort_foreach_double(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, double *d);
|
|
124
|
-
|
|
125
|
-
SELVA_EXPORT
|
|
126
|
-
void *selva_sort_foreach_double_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, double *d);
|
|
127
|
-
|
|
128
|
-
SELVA_EXPORT
|
|
129
|
-
void *selva_sort_foreach_buffer(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, void **buf, size_t *len);
|
|
130
|
-
|
|
131
|
-
SELVA_EXPORT
|
|
132
|
-
void *selva_sort_foreach_buffer_reverse(struct SelvaSortCtx *ctx, struct SelvaSortIterator *it, void **buf, size_t *len);
|
|
133
|
-
|
|
134
|
-
static inline bool selva_sort_foreach_done(struct SelvaSortIterator *it)
|
|
135
|
-
{
|
|
136
|
-
return !it->next;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
SELVA_EXPORT
|
|
140
|
-
int selva_sort_defrag(struct SelvaSortCtx *ctx);
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024-2025 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include <stdint.h>
|
|
8
|
-
#if defined(__APPLE__) && __MACH__
|
|
9
|
-
#include <xlocale.h>
|
|
10
|
-
#endif
|
|
11
|
-
#include <locale.h>
|
|
12
|
-
#include <wctype.h>
|
|
13
|
-
#include "selva/_export.h"
|
|
14
|
-
|
|
15
|
-
#define STRSEARCH_NEEDLE_MAX 39
|
|
16
|
-
|
|
17
|
-
struct strsearch_wneedle {
|
|
18
|
-
wchar_t buf[STRSEARCH_NEEDLE_MAX + 1];
|
|
19
|
-
size_t len;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
SELVA_EXPORT
|
|
23
|
-
int strsearch_make_wneedle(struct strsearch_wneedle *wneedle, locale_t loc, wctrans_t trans, const char *needle, size_t needle_len);
|
|
24
|
-
|
|
25
|
-
SELVA_EXPORT
|
|
26
|
-
uint8_t strsearch_levenshtein_u8(const char * restrict s, size_t m, const char * restrict t, size_t n);
|
|
27
|
-
|
|
28
|
-
SELVA_EXPORT
|
|
29
|
-
uint8_t strsearch_levenshtein_mbs(locale_t loc, wctrans_t trans, const char *s, size_t m, const struct strsearch_wneedle *wneedle);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Calculate the Hamming distance of two strings of the same length.
|
|
33
|
-
*/
|
|
34
|
-
SELVA_EXPORT
|
|
35
|
-
uint32_t strsearch_hamming(const char * restrict s, const char * restrict t, size_t n);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Calculate the Hamming distance of two strings of the same length in code points.
|
|
39
|
-
* The input string mbs must be NFKD normalized and the string t must contain
|
|
40
|
-
* only ASCII characters. At most t_len bytes will be compared.
|
|
41
|
-
*/
|
|
42
|
-
SELVA_EXPORT
|
|
43
|
-
uint32_t strsearch_hamming_mbs(const char * restrict mbs, size_t mbs_len, const char * restrict t, size_t t_len);
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022-2023, 2025 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include "selva/_export.h"
|
|
8
|
-
|
|
9
|
-
struct timespec;
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get current UNIX time in ms.
|
|
13
|
-
*/
|
|
14
|
-
long long ts_now(void);
|
|
15
|
-
|
|
16
|
-
SELVA_EXPORT
|
|
17
|
-
void ts_monotime(struct timespec *spec)
|
|
18
|
-
__attribute__((access(write_only, 1)));
|
|
19
|
-
|
|
20
|
-
SELVA_EXPORT
|
|
21
|
-
void ts_monorealtime(struct timespec *spec)
|
|
22
|
-
__attribute__((access(write_only, 1)));
|
|
23
|
-
|
|
24
|
-
SELVA_EXPORT
|
|
25
|
-
long long ts_monorealtime_now(void);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include "selva/_export.h"
|
|
8
|
-
|
|
9
|
-
struct SelvaNode;
|
|
10
|
-
struct SelvaDb;
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Traversal metadata for child/adjacent nodes.
|
|
14
|
-
* Note that SelvaTraversalOrder expects this to be copyable.
|
|
15
|
-
*/
|
|
16
|
-
struct SelvaTraversalMetadata {
|
|
17
|
-
const struct SelvaFields *edge_data; /*!< Edge metadata. */
|
|
18
|
-
long long depth;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
#define SELVA_TRAVERSAL_ABORT (-2)
|
|
22
|
-
#define SELVA_TRAVERSAL_STOP (-1)
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Called for each node found during a traversal.
|
|
26
|
-
* @param node a pointer to the node.
|
|
27
|
-
* @param arg a pointer to node_arg give in SelvaTraversalCallback structure.
|
|
28
|
-
*/
|
|
29
|
-
typedef int (*SelvaTraversalNodeCallback)(
|
|
30
|
-
struct SelvaDb *db,
|
|
31
|
-
const struct SelvaTraversalMetadata *metadata,
|
|
32
|
-
struct SelvaNode *node,
|
|
33
|
-
void *arg);
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Callback descriptor used for traversals.
|
|
37
|
-
*/
|
|
38
|
-
struct SelvaTraversalParam {
|
|
39
|
-
/**
|
|
40
|
-
* Called for each orphan head in the hierarchy.
|
|
41
|
-
*/
|
|
42
|
-
SelvaTraversalNodeCallback head_cb;
|
|
43
|
-
void *head_arg;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Called for each node in the hierarchy.
|
|
47
|
-
*/
|
|
48
|
-
SelvaTraversalNodeCallback node_cb;
|
|
49
|
-
void *node_arg;
|
|
50
|
-
|
|
51
|
-
/**
|
|
52
|
-
* Called for each child of current node.
|
|
53
|
-
*/
|
|
54
|
-
SelvaTraversalNodeCallback child_cb;
|
|
55
|
-
void *child_arg;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
SELVA_EXPORT
|
|
59
|
-
int selva_traverse_field_bfs(
|
|
60
|
-
struct SelvaDb *db,
|
|
61
|
-
struct SelvaNode *head,
|
|
62
|
-
const struct SelvaTraversalParam *cb);
|
|
63
|
-
|
|
64
|
-
SELVA_EXPORT
|
|
65
|
-
int selva_traverse_type(struct SelvaDb *db, struct SelvaTypeEntry *te, SelvaTraversalNodeCallback node_cb, void *node_arg);
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2024-2025 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include <stddef.h>
|
|
8
|
-
#include <stdint.h>
|
|
9
|
-
#include "selva/_export.h"
|
|
10
|
-
|
|
11
|
-
typedef uint32_t block_id_t;
|
|
12
|
-
typedef uint8_t field_t;
|
|
13
|
-
typedef uint32_t node_id_t;
|
|
14
|
-
typedef uint16_t node_type_t;
|
|
15
|
-
typedef int32_t cursor_id_t;
|
|
16
|
-
#ifndef __zig
|
|
17
|
-
typedef unsigned _BitInt(128) selva_hash128_t;
|
|
18
|
-
#else
|
|
19
|
-
typedef unsigned __int128 selva_hash128_t;
|
|
20
|
-
#endif
|
|
21
|
-
|
|
22
|
-
struct SelvaFieldsSchema;
|
|
23
|
-
|
|
24
|
-
enum SelvaFieldType {
|
|
25
|
-
SELVA_FIELD_TYPE_NULL = 0,
|
|
26
|
-
SELVA_FIELD_TYPE_MICRO_BUFFER = 1,
|
|
27
|
-
SELVA_FIELD_TYPE_STRING = 2,
|
|
28
|
-
SELVA_FIELD_TYPE_TEXT = 3,
|
|
29
|
-
SELVA_FIELD_TYPE_REFERENCE = 4,
|
|
30
|
-
SELVA_FIELD_TYPE_REFERENCES = 5,
|
|
31
|
-
SELVA_FIELD_TYPE_WEAK_REFERENCE = 6,
|
|
32
|
-
SELVA_FIELD_TYPE_WEAK_REFERENCES = 7,
|
|
33
|
-
SELVA_FIELD_TYPE_ALIAS = 8,
|
|
34
|
-
SELVA_FIELD_TYPE_ALIASES = 9,
|
|
35
|
-
} __packed;
|
|
36
|
-
|
|
37
|
-
struct EdgeFieldConstraint {
|
|
38
|
-
enum EdgeFieldConstraintFlag {
|
|
39
|
-
EDGE_FIELD_CONSTRAINT_FLAG_DEPENDENT = 0x01,
|
|
40
|
-
/**
|
|
41
|
-
* _fields_schema is referenced from the opposite efc and shouldn't be freed.
|
|
42
|
-
*/
|
|
43
|
-
EDGE_FIELD_CONSTRAINT_FLAG_SCHEMA_REF_CACHED = 0x40,
|
|
44
|
-
/**
|
|
45
|
-
* Skip saving this field while dumping.
|
|
46
|
-
* If the field is of type SELVA_FIELD_TYPE_REFERENCES it's saved
|
|
47
|
-
* regardless of this flag to preserve the original order of references.
|
|
48
|
-
*/
|
|
49
|
-
EDGE_FIELD_CONSTRAINT_FLAG_SKIP_DUMP = 0x80,
|
|
50
|
-
} __packed flags;
|
|
51
|
-
field_t inverse_field;
|
|
52
|
-
node_type_t dst_node_type;
|
|
53
|
-
/**
|
|
54
|
-
* Don't use directly!
|
|
55
|
-
* Use: `selva_get_edge_field_fields_schema()`
|
|
56
|
-
*/
|
|
57
|
-
struct SelvaFieldsSchema *_fields_schema;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
struct SelvaFieldSchema {
|
|
61
|
-
field_t field;
|
|
62
|
-
enum SelvaFieldType type;
|
|
63
|
-
union {
|
|
64
|
-
struct {
|
|
65
|
-
size_t fixed_len; /*!< Greater than zero if the string has a fixed maximum length. */
|
|
66
|
-
} string; /*!< SELVA_FIELD_TYPE_STRING */
|
|
67
|
-
struct EdgeFieldConstraint edge_constraint; /*!< SELVA_FIELD_TYPE_REFERENCE, SELVA_FIELD_TYPE_REFERENCES, SELVA_FIELD_TYPE_WEAK_REFERENCE, and SELVA_FIELD_TYPE_WEAK_REFERENCES. */
|
|
68
|
-
struct {
|
|
69
|
-
uint16_t len;
|
|
70
|
-
} smb; /*!< SELVA_FIELD_TYPE_MICRO_BUFFER */
|
|
71
|
-
size_t alias_index; /*!< Index in aliases for SELVA_FIELD_TYPE_ALIAS and SELVA_FIELD_TYPE_ALIASES. */
|
|
72
|
-
};
|
|
73
|
-
} __designated_init;
|
|
74
|
-
|
|
75
|
-
struct SelvaFieldsSchema {
|
|
76
|
-
field_t nr_fields; /*!< The total number of fields for this node type. */
|
|
77
|
-
field_t nr_fixed_fields; /*!< Number of fixed fields that are always allocated. */
|
|
78
|
-
struct {
|
|
79
|
-
void *buf;
|
|
80
|
-
size_t len;
|
|
81
|
-
size_t fixed_data_size;
|
|
82
|
-
} field_map_template;
|
|
83
|
-
struct SelvaFieldSchema field_schemas[] __counted_by(nr_fields);
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
struct SelvaNodeSchema {
|
|
87
|
-
size_t nr_aliases; /*!< Number of alias fields in this type. */
|
|
88
|
-
struct SelvaFieldsSchema fields_schema;
|
|
89
|
-
/* Nothing must be put after this line. */
|
|
90
|
-
};
|
|
91
|
-
|
|
92
|
-
struct SelvaAlias;
|
|
93
|
-
struct SelvaAliases;
|
|
94
|
-
struct SelvaDb;
|
|
95
|
-
struct SelvaFieldInfo;
|
|
96
|
-
struct SelvaFields;
|
|
97
|
-
struct SelvaNode;
|
|
98
|
-
struct SelvaTypeEntry;
|
|
99
|
-
|
|
100
|
-
typedef void (*selva_dirty_node_cb_t)(void *ctx, node_type_t type, node_id_t node_id);
|
|
101
|
-
|
|
102
|
-
SELVA_EXPORT
|
|
103
|
-
bool selva_is_valid_field_type(enum SelvaFieldType ftype);
|
|
104
|
-
|
|
105
|
-
SELVA_EXPORT
|
|
106
|
-
const char *selva_str_field_type(enum SelvaFieldType ftype);
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2025 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
#include "selva/_export.h"
|
|
8
|
-
|
|
9
|
-
typedef float v2f __attribute__((vector_size(2 * sizeof(float))));
|
|
10
|
-
typedef float v4f __attribute__((vector_size(4 * sizeof(float))));
|
|
11
|
-
typedef float v8f __attribute__((vector_size(8 * sizeof(float))));
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Calculate the dot product of two vectors of length len.
|
|
15
|
-
*/
|
|
16
|
-
SELVA_EXPORT
|
|
17
|
-
float vector_dot(const float *a, const float *b, size_t len);
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Calculate the Manhattan distance of two vectors of length len.
|
|
21
|
-
*/
|
|
22
|
-
SELVA_EXPORT
|
|
23
|
-
float vector_l1(const float *a, const float *b, size_t len);
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Calculate the squared Euclidean distance of two vectors of length len.
|
|
27
|
-
*/
|
|
28
|
-
SELVA_EXPORT
|
|
29
|
-
float vector_l2s(const float *a, const float *b, size_t len);
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Calculate the cosine similarity of two vectors of length len.
|
|
33
|
-
*/
|
|
34
|
-
SELVA_EXPORT
|
|
35
|
-
float vector_sc(const float *a, const float *b, size_t len);
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
#pragma once
|
|
2
|
-
#ifndef XXHASH64_H
|
|
3
|
-
#define XXHASH64_H
|
|
4
|
-
|
|
5
|
-
#include <stdlib.h>
|
|
6
|
-
#include <stdint.h>
|
|
7
|
-
#include "selva/_export.h"
|
|
8
|
-
#include "cdefs.h"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @brief Wrapper function that computes the 64-bit hash of a given input string using the xxHash algorithm.
|
|
13
|
-
*
|
|
14
|
-
* Takes a string as input and returns a 64-bit hash value.
|
|
15
|
-
*
|
|
16
|
-
* @param s The input string to be hashed.
|
|
17
|
-
* @return A 64-bit hash value of the input string.
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
SELVA_EXPORT
|
|
21
|
-
uint64_t xxHash64(const char *s, size_t len);
|
|
22
|
-
|
|
23
|
-
#endif
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright (c) 2022-2024 SAULX
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
#pragma once
|
|
6
|
-
|
|
7
|
-
/*
|
|
8
|
-
* Error codes.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* General error.
|
|
13
|
-
*/
|
|
14
|
-
#define SELVA_EGENERAL (-1)
|
|
15
|
-
/**
|
|
16
|
-
* Operation not supported.
|
|
17
|
-
*/
|
|
18
|
-
#define SELVA_ENOTSUP (-2)
|
|
19
|
-
/**
|
|
20
|
-
* Invalid argument/input value.
|
|
21
|
-
*/
|
|
22
|
-
#define SELVA_EINVAL (-3)
|
|
23
|
-
/**
|
|
24
|
-
* Result too large.
|
|
25
|
-
*/
|
|
26
|
-
#define SELVA_ERANGE (-4)
|
|
27
|
-
/**
|
|
28
|
-
* Invalid type.
|
|
29
|
-
*/
|
|
30
|
-
#define SELVA_EINTYPE (-5)
|
|
31
|
-
/**
|
|
32
|
-
* Name too long.
|
|
33
|
-
*/
|
|
34
|
-
#define SELVA_ENAMETOOLONG (-6)
|
|
35
|
-
/**
|
|
36
|
-
* Out of memory.
|
|
37
|
-
*/
|
|
38
|
-
#define SELVA_ENOMEM (-7)
|
|
39
|
-
/**
|
|
40
|
-
* Node or entity not found.
|
|
41
|
-
*/
|
|
42
|
-
#define SELVA_ENOENT (-8)
|
|
43
|
-
/**
|
|
44
|
-
* Node or entity already exist.
|
|
45
|
-
*/
|
|
46
|
-
#define SELVA_EEXIST (-9)
|
|
47
|
-
/**
|
|
48
|
-
* Permission denied.
|
|
49
|
-
*/
|
|
50
|
-
#define SELVA_EACCES (-10)
|
|
51
|
-
/**
|
|
52
|
-
* No buffer or resource space available.
|
|
53
|
-
*/
|
|
54
|
-
#define SELVA_ENOBUFS (-11)
|
|
55
|
-
/**
|
|
56
|
-
* Operation already in progress.
|
|
57
|
-
*/
|
|
58
|
-
#define SELVA_EINPROGRESS (-12)
|
|
59
|
-
/**
|
|
60
|
-
* Input/output error.
|
|
61
|
-
*/
|
|
62
|
-
#define SELVA_EIO (-13)
|
|
63
|
-
/**
|
|
64
|
-
* Timed out.
|
|
65
|
-
*/
|
|
66
|
-
#define SELVA_ETIMEDOUT (-14)
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Maximum number of recursion depth reached.
|
|
70
|
-
*/
|
|
71
|
-
#define SELVA_ETRMAX (-15)
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Resource temporarily unavailable.
|
|
75
|
-
*/
|
|
76
|
-
#define SELVA_PROTO_EAGAIN (-16)
|
|
77
|
-
/**
|
|
78
|
-
* Operation already in progress.
|
|
79
|
-
*/
|
|
80
|
-
#define SELVA_PROTO_EALREADY (-17)
|
|
81
|
-
/**
|
|
82
|
-
* Operation not supported.
|
|
83
|
-
*/
|
|
84
|
-
#define SELVA_PROTO_ENOTSUP (-18)
|
|
85
|
-
/**
|
|
86
|
-
* Invalid argument/input value.
|
|
87
|
-
*/
|
|
88
|
-
#define SELVA_PROTO_EINVAL (-19)
|
|
89
|
-
/**
|
|
90
|
-
* Invalid type.
|
|
91
|
-
*/
|
|
92
|
-
#define SELVA_PROTO_EINTYPE (-20)
|
|
93
|
-
/**
|
|
94
|
-
* Out of memory.
|
|
95
|
-
*/
|
|
96
|
-
#define SELVA_PROTO_ENOMEM (-21)
|
|
97
|
-
/**
|
|
98
|
-
* Node or entity not found.
|
|
99
|
-
*/
|
|
100
|
-
#define SELVA_PROTO_ENOENT (-22)
|
|
101
|
-
/**
|
|
102
|
-
* Entity already exist.
|
|
103
|
-
*/
|
|
104
|
-
#define SELVA_PROTO_EEXIST (-23)
|
|
105
|
-
/**
|
|
106
|
-
* No buffer or resource space available.
|
|
107
|
-
*/
|
|
108
|
-
#define SELVA_PROTO_ENOBUFS (-24)
|
|
109
|
-
/**
|
|
110
|
-
* Bad message.
|
|
111
|
-
*/
|
|
112
|
-
#define SELVA_PROTO_EBADMSG (-25)
|
|
113
|
-
/**
|
|
114
|
-
* Not a valid open file descriptor.
|
|
115
|
-
*/
|
|
116
|
-
#define SELVA_PROTO_EBADF (-26)
|
|
117
|
-
/**
|
|
118
|
-
* Connection reset by peer.
|
|
119
|
-
*/
|
|
120
|
-
#define SELVA_PROTO_ECONNRESET (-27)
|
|
121
|
-
/**
|
|
122
|
-
* The socket is not connected.
|
|
123
|
-
*/
|
|
124
|
-
#define SELVA_PROTO_ENOTCONN (-28)
|
|
125
|
-
/**
|
|
126
|
-
* The local end has been shutdown.
|
|
127
|
-
*/
|
|
128
|
-
#define SELVA_PROTO_EPIPE (-29)
|
|
129
|
-
|
|
130
|
-
/* This must be the last error */
|
|
131
|
-
#define SELVA_INVALID_ERROR (-30)
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Selva error code to string.
|
|
135
|
-
* Implemented in libutil.
|
|
136
|
-
*/
|
|
137
|
-
const char *selva_strerror(int err);
|