@based/db 0.0.30 → 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.
Files changed (175) hide show
  1. package/README.md +565 -3
  2. package/dist/lib/darwin_aarch64/include/selva/db.h +3 -2
  3. package/dist/lib/darwin_aarch64/include/selva/fields.h +10 -7
  4. package/dist/lib/darwin_aarch64/include/selva/types.h +3 -1
  5. package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
  6. package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
  7. package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
  8. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  9. package/dist/src/client/flushModify.d.ts +1 -1
  10. package/dist/src/client/flushModify.js +5 -4
  11. package/dist/src/client/index.d.ts +3 -2
  12. package/dist/src/client/modify/binary.js +1 -1
  13. package/dist/src/client/modify/cardinality.js +1 -1
  14. package/dist/src/client/modify/references/appendEdgeRefs.js +3 -0
  15. package/dist/src/client/modify/references/edge.js +6 -0
  16. package/dist/src/client/modify/references/getEdgeSize.js +1 -1
  17. package/dist/src/client/modify/string.js +10 -4
  18. package/dist/src/client/modify/text.js +1 -9
  19. package/dist/src/client/modify/types.d.ts +1 -0
  20. package/dist/src/client/modify/types.js +1 -0
  21. package/dist/src/client/modify/upsert.js +33 -21
  22. package/dist/src/client/query/BasedDbQuery.js +1 -1
  23. package/dist/src/client/query/BasedIterable.d.ts +2 -2
  24. package/dist/src/client/query/BasedIterable.js +7 -1
  25. package/dist/src/client/query/aggregates/aggregation.d.ts +4 -0
  26. package/dist/src/client/query/aggregates/aggregation.js +12 -0
  27. package/dist/src/client/query/aggregation.d.ts +1 -1
  28. package/dist/src/client/query/debug.js +3 -2
  29. package/dist/src/client/query/display.js +1 -1
  30. package/dist/src/client/query/filter/createFixedFilterBuffer.js +1 -1
  31. package/dist/src/client/query/filter/createVariableFilterBuffer.js +1 -1
  32. package/dist/src/client/query/filter/parseFilterValue.js +1 -2
  33. package/dist/src/client/query/queryDef.js +2 -2
  34. package/dist/src/client/query/read/read.js +4 -14
  35. package/dist/src/client/query/registerQuery.js +1 -1
  36. package/dist/src/client/query/search/index.d.ts +1 -1
  37. package/dist/src/client/query/search/index.js +1 -1
  38. package/dist/src/client/query/sort.d.ts +1 -1
  39. package/dist/src/client/query/toBuffer.js +11 -15
  40. package/dist/src/client/query/types.d.ts +7 -0
  41. package/dist/src/client/query/types.js +8 -0
  42. package/dist/src/client/query/validation.d.ts +1 -1
  43. package/dist/src/client/query/validation.js +4 -5
  44. package/dist/src/client/string.js +1 -3
  45. package/dist/src/client/xxHash64.d.ts +1 -1
  46. package/dist/src/index.d.ts +1 -0
  47. package/dist/src/index.js +31 -3
  48. package/dist/src/native.d.ts +1 -2
  49. package/dist/src/native.js +2 -5
  50. package/dist/src/server/csmt/draw-dot.d.ts +3 -1
  51. package/dist/src/server/csmt/draw-dot.js +7 -2
  52. package/dist/src/server/csmt/match.d.ts +1 -1
  53. package/dist/src/server/csmt/memebership-proof.d.ts +1 -1
  54. package/dist/src/server/csmt/tree-utils.d.ts +4 -4
  55. package/dist/src/server/csmt/tree.d.ts +1 -1
  56. package/dist/src/server/csmt/tree.js +1 -1
  57. package/dist/src/server/csmt/types.d.ts +10 -10
  58. package/dist/src/server/dbHash.d.ts +1 -1
  59. package/dist/src/server/dbHash.js +1 -1
  60. package/dist/src/server/index.d.ts +8 -4
  61. package/dist/src/server/index.js +28 -13
  62. package/dist/src/server/migrate/worker.js +11 -0
  63. package/dist/src/server/save.js +4 -6
  64. package/dist/src/server/start.js +17 -11
  65. package/dist/src/server/tree.d.ts +1 -1
  66. package/dist/src/server/tree.js +2 -2
  67. package/dist/src/utils.d.ts +0 -10
  68. package/dist/src/utils.js +0 -152
  69. package/package.json +3 -3
  70. package/dist/lib/darwin_aarch64/include/selva/xxhash64.h +0 -23
  71. package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
  72. package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
  73. package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
  74. package/dist/lib/linux_aarch64/include/cdefs.h +0 -317
  75. package/dist/lib/linux_aarch64/include/jemalloc.h +0 -468
  76. package/dist/lib/linux_aarch64/include/libdeflate.h +0 -322
  77. package/dist/lib/linux_aarch64/include/libdeflate_strings.h +0 -35
  78. package/dist/lib/linux_aarch64/include/linker_set.h +0 -109
  79. package/dist/lib/linux_aarch64/include/queue.h +0 -627
  80. package/dist/lib/linux_aarch64/include/selva/_export.h +0 -7
  81. package/dist/lib/linux_aarch64/include/selva/align.h +0 -9
  82. package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +0 -29
  83. package/dist/lib/linux_aarch64/include/selva/bitmap.h +0 -95
  84. package/dist/lib/linux_aarch64/include/selva/crc32c.h +0 -17
  85. package/dist/lib/linux_aarch64/include/selva/ctime.h +0 -135
  86. package/dist/lib/linux_aarch64/include/selva/db.h +0 -417
  87. package/dist/lib/linux_aarch64/include/selva/endian.h +0 -301
  88. package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +0 -23
  89. package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +0 -18
  90. package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +0 -11
  91. package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +0 -36
  92. package/dist/lib/linux_aarch64/include/selva/fields.h +0 -378
  93. package/dist/lib/linux_aarch64/include/selva/find.h +0 -47
  94. package/dist/lib/linux_aarch64/include/selva/history.h +0 -64
  95. package/dist/lib/linux_aarch64/include/selva/hll.h +0 -81
  96. package/dist/lib/linux_aarch64/include/selva/lpf.h +0 -28
  97. package/dist/lib/linux_aarch64/include/selva/node_id_set.h +0 -43
  98. package/dist/lib/linux_aarch64/include/selva/poptop.h +0 -114
  99. package/dist/lib/linux_aarch64/include/selva/queue_r.h +0 -190
  100. package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +0 -49
  101. package/dist/lib/linux_aarch64/include/selva/selva_lang.h +0 -105
  102. package/dist/lib/linux_aarch64/include/selva/selva_math.h +0 -37
  103. package/dist/lib/linux_aarch64/include/selva/selva_string.h +0 -674
  104. package/dist/lib/linux_aarch64/include/selva/sort.h +0 -140
  105. package/dist/lib/linux_aarch64/include/selva/strsearch.h +0 -43
  106. package/dist/lib/linux_aarch64/include/selva/timestamp.h +0 -25
  107. package/dist/lib/linux_aarch64/include/selva/traverse.h +0 -65
  108. package/dist/lib/linux_aarch64/include/selva/types.h +0 -104
  109. package/dist/lib/linux_aarch64/include/selva/vector.h +0 -35
  110. package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -13
  111. package/dist/lib/linux_aarch64/include/selva/xxhash64.h +0 -23
  112. package/dist/lib/linux_aarch64/include/selva_error.h +0 -137
  113. package/dist/lib/linux_aarch64/include/selva_lang_code.h +0 -157
  114. package/dist/lib/linux_aarch64/include/tree.h +0 -852
  115. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  116. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  117. package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
  118. package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
  119. package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
  120. package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
  121. package/dist/lib/linux_aarch64/libselva.so +0 -0
  122. package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
  123. package/dist/lib/linux_x86_64/include/cdefs.h +0 -317
  124. package/dist/lib/linux_x86_64/include/jemalloc.h +0 -468
  125. package/dist/lib/linux_x86_64/include/libdeflate.h +0 -322
  126. package/dist/lib/linux_x86_64/include/libdeflate_strings.h +0 -35
  127. package/dist/lib/linux_x86_64/include/linker_set.h +0 -109
  128. package/dist/lib/linux_x86_64/include/queue.h +0 -627
  129. package/dist/lib/linux_x86_64/include/selva/_export.h +0 -7
  130. package/dist/lib/linux_x86_64/include/selva/align.h +0 -9
  131. package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +0 -29
  132. package/dist/lib/linux_x86_64/include/selva/bitmap.h +0 -95
  133. package/dist/lib/linux_x86_64/include/selva/crc32c.h +0 -17
  134. package/dist/lib/linux_x86_64/include/selva/ctime.h +0 -135
  135. package/dist/lib/linux_x86_64/include/selva/db.h +0 -417
  136. package/dist/lib/linux_x86_64/include/selva/endian.h +0 -301
  137. package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +0 -23
  138. package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +0 -18
  139. package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +0 -11
  140. package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +0 -36
  141. package/dist/lib/linux_x86_64/include/selva/fields.h +0 -378
  142. package/dist/lib/linux_x86_64/include/selva/find.h +0 -47
  143. package/dist/lib/linux_x86_64/include/selva/history.h +0 -64
  144. package/dist/lib/linux_x86_64/include/selva/hll.h +0 -81
  145. package/dist/lib/linux_x86_64/include/selva/lpf.h +0 -28
  146. package/dist/lib/linux_x86_64/include/selva/node_id_set.h +0 -43
  147. package/dist/lib/linux_x86_64/include/selva/poptop.h +0 -114
  148. package/dist/lib/linux_x86_64/include/selva/queue_r.h +0 -190
  149. package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +0 -49
  150. package/dist/lib/linux_x86_64/include/selva/selva_lang.h +0 -105
  151. package/dist/lib/linux_x86_64/include/selva/selva_math.h +0 -37
  152. package/dist/lib/linux_x86_64/include/selva/selva_string.h +0 -674
  153. package/dist/lib/linux_x86_64/include/selva/sort.h +0 -140
  154. package/dist/lib/linux_x86_64/include/selva/strsearch.h +0 -43
  155. package/dist/lib/linux_x86_64/include/selva/timestamp.h +0 -25
  156. package/dist/lib/linux_x86_64/include/selva/traverse.h +0 -65
  157. package/dist/lib/linux_x86_64/include/selva/types.h +0 -104
  158. package/dist/lib/linux_x86_64/include/selva/vector.h +0 -35
  159. package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -13
  160. package/dist/lib/linux_x86_64/include/selva/xxhash64.h +0 -23
  161. package/dist/lib/linux_x86_64/include/selva_error.h +0 -137
  162. package/dist/lib/linux_x86_64/include/selva_lang_code.h +0 -157
  163. package/dist/lib/linux_x86_64/include/tree.h +0 -852
  164. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  165. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  166. package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
  167. package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
  168. package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
  169. package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
  170. package/dist/lib/linux_x86_64/libselva.so +0 -0
  171. package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
  172. package/dist/src/client/query/subscription/markers.d.ts +0 -10
  173. package/dist/src/client/query/subscription/markers.js +0 -213
  174. package/dist/src/client/query/subscription/run.d.ts +0 -5
  175. 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,104 +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_WEAK_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
- SELVA_EXPORT
101
- bool selva_is_valid_field_type(enum SelvaFieldType ftype);
102
-
103
- SELVA_EXPORT
104
- 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,13 +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
- SELVA_EXPORT
10
- void worker_ctx_init();
11
-
12
- SELVA_EXPORT
13
- void worker_ctx_deinit();
@@ -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);