@based/db 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/libnode-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/libnode-v25.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +324 -0
- package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +345 -0
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
- package/dist/lib/linux_aarch64/include/queue.h +627 -0
- package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_aarch64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +450 -0
- package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +341 -0
- package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +85 -0
- package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_aarch64/include/selva/membar.h +32 -0
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +112 -0
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +115 -0
- package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
- package/dist/lib/linux_aarch64/include/selva_error.h +140 -0
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_aarch64/include/tree.h +852 -0
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-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/libnode-v25.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 +324 -0
- package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +345 -0
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
- package/dist/lib/linux_x86_64/include/queue.h +627 -0
- package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
- package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_x86_64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +450 -0
- package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +341 -0
- package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +85 -0
- package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_x86_64/include/selva/membar.h +32 -0
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +112 -0
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +115 -0
- package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
- package/dist/lib/linux_x86_64/include/selva_error.h +140 -0
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_x86_64/include/tree.h +852 -0
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-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/libnode-v25.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/package.json +1 -1
|
@@ -0,0 +1,140 @@
|
|
|
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);
|
|
@@ -0,0 +1,43 @@
|
|
|
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);
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
#include <stdint.h>
|
|
7
|
+
|
|
8
|
+
static inline uint64_t selva_get_thread_id(void);
|
|
9
|
+
|
|
10
|
+
#ifdef __linux__
|
|
11
|
+
#define _GNU_SOURCE
|
|
12
|
+
#include <unistd.h>
|
|
13
|
+
|
|
14
|
+
/*
|
|
15
|
+
* Sometimes the symbol for getid not there even if _GNU_SOURCE should now
|
|
16
|
+
* expose it on glibc 2.30+.
|
|
17
|
+
*/
|
|
18
|
+
pid_t gettid(void);
|
|
19
|
+
|
|
20
|
+
static inline uint64_t selva_get_thread_id(void)
|
|
21
|
+
{
|
|
22
|
+
return (uint64_t)gettid();
|
|
23
|
+
}
|
|
24
|
+
#elifdef __APPLE__
|
|
25
|
+
#include <pthread.h>
|
|
26
|
+
|
|
27
|
+
static inline uint64_t selva_get_thread_id(void)
|
|
28
|
+
{
|
|
29
|
+
uint64_t tid;
|
|
30
|
+
|
|
31
|
+
(void)pthread_threadid_np((void *)0, &tid);
|
|
32
|
+
|
|
33
|
+
return tid;
|
|
34
|
+
}
|
|
35
|
+
#else
|
|
36
|
+
#error "Platform not supported"
|
|
37
|
+
#endif
|
|
@@ -0,0 +1,25 @@
|
|
|
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);
|
|
@@ -0,0 +1,115 @@
|
|
|
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
|
+
#define SELVA_FIELDS_MAX 249
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Reserved (N/A) field id.
|
|
15
|
+
* Can be used to mark that a field doesn't exist.
|
|
16
|
+
* E.g. if created and updated fields don't exist their ids can be set to this
|
|
17
|
+
* value.
|
|
18
|
+
* Technically fields 251..255 are all reserved.
|
|
19
|
+
*/
|
|
20
|
+
#define SELVA_FIELDS_RESERVED 255
|
|
21
|
+
|
|
22
|
+
typedef uint32_t block_id_t;
|
|
23
|
+
typedef uint8_t field_t;
|
|
24
|
+
typedef uint32_t node_id_t;
|
|
25
|
+
typedef uint16_t node_type_t;
|
|
26
|
+
#ifndef __zig
|
|
27
|
+
typedef unsigned _BitInt(128) selva_hash128_t;
|
|
28
|
+
#else
|
|
29
|
+
typedef unsigned __int128 selva_hash128_t;
|
|
30
|
+
#endif
|
|
31
|
+
|
|
32
|
+
struct SelvaFieldsSchema;
|
|
33
|
+
|
|
34
|
+
enum SelvaFieldType {
|
|
35
|
+
SELVA_FIELD_TYPE_NULL = 0,
|
|
36
|
+
SELVA_FIELD_TYPE_MICRO_BUFFER = 1,
|
|
37
|
+
SELVA_FIELD_TYPE_STRING = 2,
|
|
38
|
+
SELVA_FIELD_TYPE_TEXT = 3,
|
|
39
|
+
SELVA_FIELD_TYPE_REFERENCE = 4,
|
|
40
|
+
SELVA_FIELD_TYPE_REFERENCES = 5,
|
|
41
|
+
SELVA_FIELD_TYPE_WEAK_REFERENCE __attribute__((deprecated)) = 6,
|
|
42
|
+
SELVA_FIELD_TYPE_WEAK_REFERENCES __attribute__((deprecated)) = 7,
|
|
43
|
+
SELVA_FIELD_TYPE_ALIAS = 8,
|
|
44
|
+
SELVA_FIELD_TYPE_ALIASES = 9,
|
|
45
|
+
SELVA_FIELD_TYPE_COLVEC = 10,
|
|
46
|
+
} __packed;
|
|
47
|
+
|
|
48
|
+
struct EdgeFieldConstraint {
|
|
49
|
+
enum EdgeFieldConstraintFlag {
|
|
50
|
+
EDGE_FIELD_CONSTRAINT_FLAG_DEPENDENT = 0x01,
|
|
51
|
+
} __packed flags;
|
|
52
|
+
field_t inverse_field;
|
|
53
|
+
node_type_t dst_node_type;
|
|
54
|
+
node_type_t meta_node_type;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
struct SelvaFieldSchema {
|
|
58
|
+
field_t field;
|
|
59
|
+
enum SelvaFieldType type;
|
|
60
|
+
union {
|
|
61
|
+
struct {
|
|
62
|
+
size_t fixed_len; /*!< Greater than zero if the string has a fixed maximum length. */
|
|
63
|
+
} string; /*!< SELVA_FIELD_TYPE_STRING */
|
|
64
|
+
struct EdgeFieldConstraint edge_constraint; /*!< SELVA_FIELD_TYPE_REFERENCE, SELVA_FIELD_TYPE_REFERENCES, SELVA_FIELD_TYPE_WEAK_REFERENCE, and SELVA_FIELD_TYPE_WEAK_REFERENCES. */
|
|
65
|
+
struct {
|
|
66
|
+
uint16_t len; /*!< Size of the smb. */
|
|
67
|
+
uint32_t default_off; /*!< Offset to the default in the raw schema buffer. */
|
|
68
|
+
} smb; /*!< SELVA_FIELD_TYPE_MICRO_BUFFER */
|
|
69
|
+
size_t alias_index; /*!< Index in aliases for SELVA_FIELD_TYPE_ALIAS and SELVA_FIELD_TYPE_ALIASES. */
|
|
70
|
+
struct {
|
|
71
|
+
uint16_t vec_len; /*!< Length of a single vector. */
|
|
72
|
+
uint16_t comp_size; /*!< Component size in the vector. */
|
|
73
|
+
field_t index; /*!< Index in te->col_fields.colvec.v. */
|
|
74
|
+
} colvec;
|
|
75
|
+
};
|
|
76
|
+
} __designated_init;
|
|
77
|
+
|
|
78
|
+
struct SelvaFieldsSchema {
|
|
79
|
+
field_t nr_fields; /*!< The total number of fields in this schema. */
|
|
80
|
+
field_t nr_fixed_fields; /*!< The number of fixed fields that are always allocated. */
|
|
81
|
+
field_t nr_virtual_fields; /*!< The number of fields that are not included in fields.fields_map. These must be the last field ids used. */
|
|
82
|
+
/**
|
|
83
|
+
* Template for fields->fields_map.
|
|
84
|
+
*/
|
|
85
|
+
struct {
|
|
86
|
+
void *field_map_buf;
|
|
87
|
+
size_t field_map_len;
|
|
88
|
+
void *fixed_data_buf;
|
|
89
|
+
size_t fixed_data_len;
|
|
90
|
+
} template;
|
|
91
|
+
struct SelvaFieldSchema field_schemas[SELVA_FIELDS_MAX];
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
struct SelvaNodeSchema {
|
|
95
|
+
size_t nr_aliases; /*!< Number of alias fields in this type. */
|
|
96
|
+
size_t nr_colvecs; /*!< Number of columnar vector fields. */
|
|
97
|
+
struct SelvaFieldsSchema fields_schema;
|
|
98
|
+
/* Nothing must be put after this line. */
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
struct SelvaAlias;
|
|
102
|
+
struct SelvaAliases;
|
|
103
|
+
struct SelvaDb;
|
|
104
|
+
struct SelvaFieldInfo;
|
|
105
|
+
struct SelvaFields;
|
|
106
|
+
struct SelvaNode;
|
|
107
|
+
struct SelvaTypeEntry;
|
|
108
|
+
|
|
109
|
+
typedef void (*selva_dirty_node_cb_t)(void *ctx, node_type_t type, node_id_t node_id);
|
|
110
|
+
|
|
111
|
+
SELVA_EXPORT
|
|
112
|
+
bool selva_is_valid_field_type(enum SelvaFieldType ftype);
|
|
113
|
+
|
|
114
|
+
SELVA_EXPORT
|
|
115
|
+
const char *selva_str_field_type(enum SelvaFieldType ftype);
|
|
@@ -0,0 +1,35 @@
|
|
|
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);
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2022-2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
|
|
7
|
+
#include "selva/_export.h"
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
* Error codes.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* General error.
|
|
15
|
+
*/
|
|
16
|
+
#define SELVA_EGENERAL (-1)
|
|
17
|
+
/**
|
|
18
|
+
* Operation not supported.
|
|
19
|
+
*/
|
|
20
|
+
#define SELVA_ENOTSUP (-2)
|
|
21
|
+
/**
|
|
22
|
+
* Invalid argument/input value.
|
|
23
|
+
*/
|
|
24
|
+
#define SELVA_EINVAL (-3)
|
|
25
|
+
/**
|
|
26
|
+
* Result too large.
|
|
27
|
+
*/
|
|
28
|
+
#define SELVA_ERANGE (-4)
|
|
29
|
+
/**
|
|
30
|
+
* Invalid type.
|
|
31
|
+
*/
|
|
32
|
+
#define SELVA_EINTYPE (-5)
|
|
33
|
+
/**
|
|
34
|
+
* Name too long.
|
|
35
|
+
*/
|
|
36
|
+
#define SELVA_ENAMETOOLONG (-6)
|
|
37
|
+
/**
|
|
38
|
+
* Out of memory.
|
|
39
|
+
*/
|
|
40
|
+
#define SELVA_ENOMEM (-7)
|
|
41
|
+
/**
|
|
42
|
+
* Node or entity not found.
|
|
43
|
+
*/
|
|
44
|
+
#define SELVA_ENOENT (-8)
|
|
45
|
+
/**
|
|
46
|
+
* Node or entity already exist.
|
|
47
|
+
*/
|
|
48
|
+
#define SELVA_EEXIST (-9)
|
|
49
|
+
/**
|
|
50
|
+
* Permission denied.
|
|
51
|
+
*/
|
|
52
|
+
#define SELVA_EACCES (-10)
|
|
53
|
+
/**
|
|
54
|
+
* No buffer or resource space available.
|
|
55
|
+
*/
|
|
56
|
+
#define SELVA_ENOBUFS (-11)
|
|
57
|
+
/**
|
|
58
|
+
* Operation already in progress.
|
|
59
|
+
*/
|
|
60
|
+
#define SELVA_EINPROGRESS (-12)
|
|
61
|
+
/**
|
|
62
|
+
* Input/output error.
|
|
63
|
+
*/
|
|
64
|
+
#define SELVA_EIO (-13)
|
|
65
|
+
/**
|
|
66
|
+
* Timed out.
|
|
67
|
+
*/
|
|
68
|
+
#define SELVA_ETIMEDOUT (-14)
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Maximum number of recursion depth reached.
|
|
72
|
+
*/
|
|
73
|
+
#define SELVA_ETRMAX (-15)
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Resource temporarily unavailable.
|
|
77
|
+
*/
|
|
78
|
+
#define SELVA_PROTO_EAGAIN (-16)
|
|
79
|
+
/**
|
|
80
|
+
* Operation already in progress.
|
|
81
|
+
*/
|
|
82
|
+
#define SELVA_PROTO_EALREADY (-17)
|
|
83
|
+
/**
|
|
84
|
+
* Operation not supported.
|
|
85
|
+
*/
|
|
86
|
+
#define SELVA_PROTO_ENOTSUP (-18)
|
|
87
|
+
/**
|
|
88
|
+
* Invalid argument/input value.
|
|
89
|
+
*/
|
|
90
|
+
#define SELVA_PROTO_EINVAL (-19)
|
|
91
|
+
/**
|
|
92
|
+
* Invalid type.
|
|
93
|
+
*/
|
|
94
|
+
#define SELVA_PROTO_EINTYPE (-20)
|
|
95
|
+
/**
|
|
96
|
+
* Out of memory.
|
|
97
|
+
*/
|
|
98
|
+
#define SELVA_PROTO_ENOMEM (-21)
|
|
99
|
+
/**
|
|
100
|
+
* Node or entity not found.
|
|
101
|
+
*/
|
|
102
|
+
#define SELVA_PROTO_ENOENT (-22)
|
|
103
|
+
/**
|
|
104
|
+
* Entity already exist.
|
|
105
|
+
*/
|
|
106
|
+
#define SELVA_PROTO_EEXIST (-23)
|
|
107
|
+
/**
|
|
108
|
+
* No buffer or resource space available.
|
|
109
|
+
*/
|
|
110
|
+
#define SELVA_PROTO_ENOBUFS (-24)
|
|
111
|
+
/**
|
|
112
|
+
* Bad message.
|
|
113
|
+
*/
|
|
114
|
+
#define SELVA_PROTO_EBADMSG (-25)
|
|
115
|
+
/**
|
|
116
|
+
* Not a valid open file descriptor.
|
|
117
|
+
*/
|
|
118
|
+
#define SELVA_PROTO_EBADF (-26)
|
|
119
|
+
/**
|
|
120
|
+
* Connection reset by peer.
|
|
121
|
+
*/
|
|
122
|
+
#define SELVA_PROTO_ECONNRESET (-27)
|
|
123
|
+
/**
|
|
124
|
+
* The socket is not connected.
|
|
125
|
+
*/
|
|
126
|
+
#define SELVA_PROTO_ENOTCONN (-28)
|
|
127
|
+
/**
|
|
128
|
+
* The local end has been shutdown.
|
|
129
|
+
*/
|
|
130
|
+
#define SELVA_PROTO_EPIPE (-29)
|
|
131
|
+
|
|
132
|
+
/* This must be the last error */
|
|
133
|
+
#define SELVA_INVALID_ERROR (-30)
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Selva error code to string.
|
|
137
|
+
* Implemented in libutil.
|
|
138
|
+
*/
|
|
139
|
+
SELVA_EXPORT
|
|
140
|
+
const char *selva_strerror(int err);
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2024 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
#ifndef SELVA_LANG_CODE_H
|
|
7
|
+
#define SELVA_LANG_CODE_H
|
|
8
|
+
|
|
9
|
+
enum selva_lang_code {
|
|
10
|
+
selva_lang_none = 0,
|
|
11
|
+
selva_lang_aa,
|
|
12
|
+
selva_lang_ab,
|
|
13
|
+
selva_lang_af,
|
|
14
|
+
selva_lang_ak,
|
|
15
|
+
selva_lang_sq,
|
|
16
|
+
selva_lang_am,
|
|
17
|
+
selva_lang_ar,
|
|
18
|
+
selva_lang_an,
|
|
19
|
+
selva_lang_hy,
|
|
20
|
+
selva_lang_as,
|
|
21
|
+
selva_lang_av,
|
|
22
|
+
selva_lang_ae,
|
|
23
|
+
selva_lang_ay,
|
|
24
|
+
selva_lang_az,
|
|
25
|
+
selva_lang_eu,
|
|
26
|
+
selva_lang_be,
|
|
27
|
+
selva_lang_bn,
|
|
28
|
+
selva_lang_bi,
|
|
29
|
+
selva_lang_bs,
|
|
30
|
+
selva_lang_br,
|
|
31
|
+
selva_lang_bg,
|
|
32
|
+
selva_lang_my,
|
|
33
|
+
selva_lang_ca,
|
|
34
|
+
selva_lang_km,
|
|
35
|
+
selva_lang_ce,
|
|
36
|
+
selva_lang_zh,
|
|
37
|
+
selva_lang_cv,
|
|
38
|
+
selva_lang_kw,
|
|
39
|
+
selva_lang_co,
|
|
40
|
+
selva_lang_hr,
|
|
41
|
+
selva_lang_cs,
|
|
42
|
+
selva_lang_da,
|
|
43
|
+
selva_lang_dv,
|
|
44
|
+
selva_lang_nl,
|
|
45
|
+
selva_lang_dz,
|
|
46
|
+
selva_lang_en,
|
|
47
|
+
selva_lang_et,
|
|
48
|
+
selva_lang_fo,
|
|
49
|
+
selva_lang_fi,
|
|
50
|
+
selva_lang_fr,
|
|
51
|
+
selva_lang_ff,
|
|
52
|
+
selva_lang_gd,
|
|
53
|
+
selva_lang_gl,
|
|
54
|
+
selva_lang_de,
|
|
55
|
+
selva_lang_gsw,
|
|
56
|
+
selva_lang_el,
|
|
57
|
+
selva_lang_kl,
|
|
58
|
+
selva_lang_gu,
|
|
59
|
+
selva_lang_ht,
|
|
60
|
+
selva_lang_ha,
|
|
61
|
+
selva_lang_he,
|
|
62
|
+
selva_lang_hi,
|
|
63
|
+
selva_lang_hu,
|
|
64
|
+
selva_lang_is,
|
|
65
|
+
selva_lang_ig,
|
|
66
|
+
selva_lang_id,
|
|
67
|
+
selva_lang_ia,
|
|
68
|
+
selva_lang_iu,
|
|
69
|
+
selva_lang_ik,
|
|
70
|
+
selva_lang_ga,
|
|
71
|
+
selva_lang_it,
|
|
72
|
+
selva_lang_ja,
|
|
73
|
+
selva_lang_kn,
|
|
74
|
+
selva_lang_ks,
|
|
75
|
+
selva_lang_kk,
|
|
76
|
+
selva_lang_rw,
|
|
77
|
+
selva_lang_ko,
|
|
78
|
+
selva_lang_ku,
|
|
79
|
+
selva_lang_ky,
|
|
80
|
+
selva_lang_lo,
|
|
81
|
+
selva_lang_la,
|
|
82
|
+
selva_lang_lv,
|
|
83
|
+
selva_lang_lb,
|
|
84
|
+
selva_lang_li,
|
|
85
|
+
selva_lang_ln,
|
|
86
|
+
selva_lang_lt,
|
|
87
|
+
selva_lang_mk,
|
|
88
|
+
selva_lang_mg,
|
|
89
|
+
selva_lang_ms,
|
|
90
|
+
selva_lang_ml,
|
|
91
|
+
selva_lang_mt,
|
|
92
|
+
selva_lang_gv,
|
|
93
|
+
selva_lang_mi,
|
|
94
|
+
selva_lang_ro,
|
|
95
|
+
selva_lang_mn,
|
|
96
|
+
selva_lang_ne,
|
|
97
|
+
selva_lang_se,
|
|
98
|
+
selva_lang_no,
|
|
99
|
+
selva_lang_nb,
|
|
100
|
+
selva_lang_nn,
|
|
101
|
+
selva_lang_oc,
|
|
102
|
+
selva_lang_or,
|
|
103
|
+
selva_lang_om,
|
|
104
|
+
selva_lang_os,
|
|
105
|
+
selva_lang_pa,
|
|
106
|
+
selva_lang_ps,
|
|
107
|
+
selva_lang_fa,
|
|
108
|
+
selva_lang_pl,
|
|
109
|
+
selva_lang_pt,
|
|
110
|
+
selva_lang_qu,
|
|
111
|
+
selva_lang_rm,
|
|
112
|
+
selva_lang_ru,
|
|
113
|
+
selva_lang_sm,
|
|
114
|
+
selva_lang_sa,
|
|
115
|
+
selva_lang_sc,
|
|
116
|
+
selva_lang_sr,
|
|
117
|
+
selva_lang_sd,
|
|
118
|
+
selva_lang_si,
|
|
119
|
+
selva_lang_sk,
|
|
120
|
+
selva_lang_sl,
|
|
121
|
+
selva_lang_so,
|
|
122
|
+
selva_lang_st,
|
|
123
|
+
selva_lang_nr,
|
|
124
|
+
selva_lang_es,
|
|
125
|
+
selva_lang_sw,
|
|
126
|
+
selva_lang_ss,
|
|
127
|
+
selva_lang_sv,
|
|
128
|
+
selva_lang_tl,
|
|
129
|
+
selva_lang_tg,
|
|
130
|
+
selva_lang_ta,
|
|
131
|
+
selva_lang_tt,
|
|
132
|
+
selva_lang_te,
|
|
133
|
+
selva_lang_th,
|
|
134
|
+
selva_lang_bo,
|
|
135
|
+
selva_lang_ti,
|
|
136
|
+
selva_lang_to,
|
|
137
|
+
selva_lang_ts,
|
|
138
|
+
selva_lang_tn,
|
|
139
|
+
selva_lang_tr,
|
|
140
|
+
selva_lang_tk,
|
|
141
|
+
selva_lang_ug,
|
|
142
|
+
selva_lang_uk,
|
|
143
|
+
selva_lang_ur,
|
|
144
|
+
selva_lang_uz,
|
|
145
|
+
selva_lang_ve,
|
|
146
|
+
selva_lang_vi,
|
|
147
|
+
selva_lang_wa,
|
|
148
|
+
selva_lang_cy,
|
|
149
|
+
selva_lang_fy,
|
|
150
|
+
selva_lang_wo,
|
|
151
|
+
selva_lang_xh,
|
|
152
|
+
selva_lang_yi,
|
|
153
|
+
selva_lang_yo,
|
|
154
|
+
selva_lang_zu,
|
|
155
|
+
selva_lang_ka,
|
|
156
|
+
selva_lang_cnr,
|
|
157
|
+
_selva_lang_last,
|
|
158
|
+
} __packed;
|
|
159
|
+
|
|
160
|
+
#endif /* SELVA_LANG_CODE_H */
|