@based/db 0.0.26 → 0.0.27
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/cdefs.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/db.h +11 -11
- package/dist/lib/darwin_aarch64/include/selva/fields.h +47 -12
- package/dist/lib/darwin_aarch64/include/selva/hll.h +59 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +2 -0
- package/dist/lib/darwin_aarch64/include/tree.h +69 -69
- 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/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +1 -1
- package/dist/lib/linux_aarch64/include/selva/db.h +11 -11
- package/dist/lib/linux_aarch64/include/selva/fields.h +47 -12
- package/dist/lib/linux_aarch64/include/selva/hll.h +59 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +2 -0
- package/dist/lib/linux_aarch64/include/tree.h +69 -69
- package/dist/lib/linux_aarch64/libdeflate.so +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_x86_64/include/cdefs.h +1 -1
- package/dist/lib/linux_x86_64/include/selva/db.h +11 -11
- package/dist/lib/linux_x86_64/include/selva/fields.h +47 -12
- package/dist/lib/linux_x86_64/include/selva/hll.h +59 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +2 -0
- package/dist/lib/linux_x86_64/include/tree.h +69 -69
- package/dist/lib/linux_x86_64/libdeflate.so +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/src/client/modify/alias.js +3 -0
- package/dist/src/client/modify/binary.js +1 -1
- package/dist/src/client/modify/cardinality.d.ts +2 -2
- package/dist/src/client/modify/cardinality.js +17 -6
- package/dist/src/client/modify/fixed.js +6 -51
- package/dist/src/client/modify/json.js +15 -1
- package/dist/src/client/modify/references/edge.js +1 -1
- package/dist/src/client/modify/references/references.js +21 -6
- package/dist/src/client/modify/string.js +5 -6
- package/dist/src/client/modify/text.js +0 -11
- package/dist/src/client/modify/vector.js +3 -3
- package/dist/src/client/query/BasedDbQuery.js +6 -1
- package/dist/src/client/query/filter/parseFilterValue.js +2 -4
- package/dist/src/client/query/include/walk.js +1 -0
- package/dist/src/client/query/read/read.js +8 -1
- package/dist/src/client/query/validation.js +3 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +8 -2
- package/dist/src/server/index.js +10 -3
- package/dist/src/server/migrate/index.js +9 -5
- package/dist/src/server/migrate/worker.js +26 -1
- package/dist/src/server/save.js +1 -1
- package/package.json +3 -2
- package/dist/src/client/bitWise.d.ts +0 -6
- package/dist/src/client/bitWise.js +0 -72
- package/dist/src/client/operations.d.ts +0 -32
- package/dist/src/client/operations.js +0 -137
- package/dist/src/client/query/aggregationFn.d.ts +0 -3
- package/dist/src/client/query/aggregationFn.js +0 -9
- package/dist/src/client/tree.d.ts +0 -1
- package/dist/src/client/tree.js +0 -5
|
@@ -77,10 +77,10 @@ struct name { \
|
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
#define SPLAY_INITIALIZER(root) \
|
|
80
|
-
{
|
|
80
|
+
{ nullptr }
|
|
81
81
|
|
|
82
82
|
#define SPLAY_INIT(root) do { \
|
|
83
|
-
(root)->sph_root =
|
|
83
|
+
(root)->sph_root = nullptr; \
|
|
84
84
|
} while (/*CONSTCOND*/ 0)
|
|
85
85
|
|
|
86
86
|
#define SPLAY_ENTRY(type) \
|
|
@@ -92,7 +92,7 @@ struct { \
|
|
|
92
92
|
#define SPLAY_LEFT(elm, field) (elm)->field.spe_left
|
|
93
93
|
#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right
|
|
94
94
|
#define SPLAY_ROOT(head) (head)->sph_root
|
|
95
|
-
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) ==
|
|
95
|
+
#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == nullptr)
|
|
96
96
|
|
|
97
97
|
/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */
|
|
98
98
|
#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \
|
|
@@ -139,24 +139,24 @@ static __unused __inline struct type * \
|
|
|
139
139
|
name##_SPLAY_FIND(struct name *head, struct type *elm) \
|
|
140
140
|
{ \
|
|
141
141
|
if (SPLAY_EMPTY(head)) \
|
|
142
|
-
return
|
|
142
|
+
return nullptr; \
|
|
143
143
|
name##_SPLAY(head, elm); \
|
|
144
144
|
if ((cmp)(elm, (head)->sph_root) == 0) \
|
|
145
145
|
return (head->sph_root); \
|
|
146
|
-
return
|
|
146
|
+
return nullptr; \
|
|
147
147
|
} \
|
|
148
148
|
\
|
|
149
149
|
static __unused __inline struct type * \
|
|
150
150
|
name##_SPLAY_NEXT(struct name *head, struct type *elm) \
|
|
151
151
|
{ \
|
|
152
152
|
name##_SPLAY(head, elm); \
|
|
153
|
-
if (SPLAY_RIGHT(elm, field) !=
|
|
153
|
+
if (SPLAY_RIGHT(elm, field) != nullptr) { \
|
|
154
154
|
elm = SPLAY_RIGHT(elm, field); \
|
|
155
|
-
while (SPLAY_LEFT(elm, field) !=
|
|
155
|
+
while (SPLAY_LEFT(elm, field) != nullptr) { \
|
|
156
156
|
elm = SPLAY_LEFT(elm, field); \
|
|
157
157
|
} \
|
|
158
158
|
} else \
|
|
159
|
-
elm =
|
|
159
|
+
elm = nullptr; \
|
|
160
160
|
return (elm); \
|
|
161
161
|
} \
|
|
162
162
|
\
|
|
@@ -175,24 +175,24 @@ struct type * \
|
|
|
175
175
|
name##_SPLAY_INSERT(struct name *head, struct type *elm) \
|
|
176
176
|
{ \
|
|
177
177
|
if (SPLAY_EMPTY(head)) { \
|
|
178
|
-
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) =
|
|
178
|
+
SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = nullptr; \
|
|
179
179
|
} else { \
|
|
180
|
-
__typeof(cmp(
|
|
180
|
+
__typeof(cmp((void *)1, (void *)1)) __comp; \
|
|
181
181
|
name##_SPLAY(head, elm); \
|
|
182
182
|
__comp = (cmp)(elm, (head)->sph_root); \
|
|
183
183
|
if (__comp < 0) { \
|
|
184
184
|
SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field);\
|
|
185
185
|
SPLAY_RIGHT(elm, field) = (head)->sph_root; \
|
|
186
|
-
SPLAY_LEFT((head)->sph_root, field) =
|
|
186
|
+
SPLAY_LEFT((head)->sph_root, field) = nullptr; \
|
|
187
187
|
} else if (__comp > 0) { \
|
|
188
188
|
SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field);\
|
|
189
189
|
SPLAY_LEFT(elm, field) = (head)->sph_root; \
|
|
190
|
-
SPLAY_RIGHT((head)->sph_root, field) =
|
|
190
|
+
SPLAY_RIGHT((head)->sph_root, field) = nullptr; \
|
|
191
191
|
} else \
|
|
192
192
|
return ((head)->sph_root); \
|
|
193
193
|
} \
|
|
194
194
|
(head)->sph_root = (elm); \
|
|
195
|
-
return
|
|
195
|
+
return nullptr; \
|
|
196
196
|
} \
|
|
197
197
|
\
|
|
198
198
|
struct type * \
|
|
@@ -200,10 +200,10 @@ name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
|
|
|
200
200
|
{ \
|
|
201
201
|
struct type *__tmp; \
|
|
202
202
|
if (SPLAY_EMPTY(head)) \
|
|
203
|
-
return
|
|
203
|
+
return nullptr; \
|
|
204
204
|
name##_SPLAY(head, elm); \
|
|
205
205
|
if ((cmp)(elm, (head)->sph_root) == 0) { \
|
|
206
|
-
if (SPLAY_LEFT((head)->sph_root, field) ==
|
|
206
|
+
if (SPLAY_LEFT((head)->sph_root, field) == nullptr) { \
|
|
207
207
|
(head)->sph_root = SPLAY_RIGHT((head)->sph_root, field);\
|
|
208
208
|
} else { \
|
|
209
209
|
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
|
@@ -213,36 +213,36 @@ name##_SPLAY_REMOVE(struct name *head, struct type *elm) \
|
|
|
213
213
|
} \
|
|
214
214
|
return (elm); \
|
|
215
215
|
} \
|
|
216
|
-
return
|
|
216
|
+
return nullptr; \
|
|
217
217
|
} \
|
|
218
218
|
\
|
|
219
219
|
void \
|
|
220
220
|
name##_SPLAY(struct name *head, struct type *elm) \
|
|
221
221
|
{ \
|
|
222
222
|
struct type __node, *__left, *__right, *__tmp; \
|
|
223
|
-
__typeof(cmp(
|
|
223
|
+
__typeof(cmp((void *)1, (void *)1)) __comp; \
|
|
224
224
|
\
|
|
225
|
-
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) =
|
|
225
|
+
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = nullptr;\
|
|
226
226
|
__left = __right = &__node; \
|
|
227
227
|
\
|
|
228
228
|
while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \
|
|
229
229
|
if (__comp < 0) { \
|
|
230
230
|
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
|
231
|
-
if (__tmp ==
|
|
231
|
+
if (__tmp == nullptr) \
|
|
232
232
|
break; \
|
|
233
233
|
if ((cmp)(elm, __tmp) < 0){ \
|
|
234
234
|
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
|
235
|
-
if (SPLAY_LEFT((head)->sph_root, field) ==
|
|
235
|
+
if (SPLAY_LEFT((head)->sph_root, field) == nullptr)\
|
|
236
236
|
break; \
|
|
237
237
|
} \
|
|
238
238
|
SPLAY_LINKLEFT(head, __right, field); \
|
|
239
239
|
} else if (__comp > 0) { \
|
|
240
240
|
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
|
241
|
-
if (__tmp ==
|
|
241
|
+
if (__tmp == nullptr) \
|
|
242
242
|
break; \
|
|
243
243
|
if ((cmp)(elm, __tmp) > 0){ \
|
|
244
244
|
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
|
245
|
-
if (SPLAY_RIGHT((head)->sph_root, field) ==
|
|
245
|
+
if (SPLAY_RIGHT((head)->sph_root, field) == nullptr)\
|
|
246
246
|
break; \
|
|
247
247
|
} \
|
|
248
248
|
SPLAY_LINKRIGHT(head, __left, field); \
|
|
@@ -258,27 +258,27 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \
|
|
|
258
258
|
{ \
|
|
259
259
|
struct type __node, *__left, *__right, *__tmp; \
|
|
260
260
|
\
|
|
261
|
-
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) =
|
|
261
|
+
SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = nullptr;\
|
|
262
262
|
__left = __right = &__node; \
|
|
263
263
|
\
|
|
264
264
|
while (1) { \
|
|
265
265
|
if (__comp < 0) { \
|
|
266
266
|
__tmp = SPLAY_LEFT((head)->sph_root, field); \
|
|
267
|
-
if (__tmp ==
|
|
267
|
+
if (__tmp == nullptr) \
|
|
268
268
|
break; \
|
|
269
269
|
if (__comp < 0){ \
|
|
270
270
|
SPLAY_ROTATE_RIGHT(head, __tmp, field); \
|
|
271
|
-
if (SPLAY_LEFT((head)->sph_root, field) ==
|
|
271
|
+
if (SPLAY_LEFT((head)->sph_root, field) == nullptr)\
|
|
272
272
|
break; \
|
|
273
273
|
} \
|
|
274
274
|
SPLAY_LINKLEFT(head, __right, field); \
|
|
275
275
|
} else if (__comp > 0) { \
|
|
276
276
|
__tmp = SPLAY_RIGHT((head)->sph_root, field); \
|
|
277
|
-
if (__tmp ==
|
|
277
|
+
if (__tmp == nullptr) \
|
|
278
278
|
break; \
|
|
279
279
|
if (__comp > 0) { \
|
|
280
280
|
SPLAY_ROTATE_LEFT(head, __tmp, field); \
|
|
281
|
-
if (SPLAY_RIGHT((head)->sph_root, field) ==
|
|
281
|
+
if (SPLAY_RIGHT((head)->sph_root, field) == nullptr)\
|
|
282
282
|
break; \
|
|
283
283
|
} \
|
|
284
284
|
SPLAY_LINKRIGHT(head, __left, field); \
|
|
@@ -294,14 +294,14 @@ void name##_SPLAY_MINMAX(struct name *head, int __comp) \
|
|
|
294
294
|
#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y)
|
|
295
295
|
#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y)
|
|
296
296
|
#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y)
|
|
297
|
-
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ?
|
|
297
|
+
#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? nullptr \
|
|
298
298
|
: name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF))
|
|
299
|
-
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ?
|
|
299
|
+
#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? nullptr \
|
|
300
300
|
: name##_SPLAY_MIN_MAX(x, SPLAY_INF))
|
|
301
301
|
|
|
302
302
|
#define SPLAY_FOREACH(x, name, head) \
|
|
303
303
|
for ((x) = SPLAY_MIN(name, head); \
|
|
304
|
-
(x) !=
|
|
304
|
+
(x) != nullptr; \
|
|
305
305
|
(x) = SPLAY_NEXT(name, head, x))
|
|
306
306
|
|
|
307
307
|
/* Macros that define a rank-balanced tree */
|
|
@@ -311,10 +311,10 @@ struct name { \
|
|
|
311
311
|
}
|
|
312
312
|
|
|
313
313
|
#define RB_INITIALIZER(root) \
|
|
314
|
-
{
|
|
314
|
+
{ nullptr }
|
|
315
315
|
|
|
316
316
|
#define RB_INIT(root) do { \
|
|
317
|
-
(root)->rbh_root =
|
|
317
|
+
(root)->rbh_root = nullptr; \
|
|
318
318
|
} while (/*CONSTCOND*/ 0)
|
|
319
319
|
|
|
320
320
|
#define RB_ENTRY(type) \
|
|
@@ -350,7 +350,7 @@ struct { \
|
|
|
350
350
|
#define RB_PARENT(elm, field) ((__typeof(RB_UP(elm, field))) \
|
|
351
351
|
(RB_BITS(elm, field) & ~RB_RED_MASK))
|
|
352
352
|
#define RB_ROOT(head) (head)->rbh_root
|
|
353
|
-
#define RB_EMPTY(head) (RB_ROOT(head) ==
|
|
353
|
+
#define RB_EMPTY(head) (RB_ROOT(head) == nullptr)
|
|
354
354
|
|
|
355
355
|
#define RB_SET_PARENT(dst, src, field) do { \
|
|
356
356
|
RB_BITS(dst, field) &= RB_RED_MASK; \
|
|
@@ -359,10 +359,10 @@ struct { \
|
|
|
359
359
|
|
|
360
360
|
#define RB_SET(elm, parent, field) do { \
|
|
361
361
|
RB_UP(elm, field) = parent; \
|
|
362
|
-
RB_LEFT(elm, field) = RB_RIGHT(elm, field) =
|
|
362
|
+
RB_LEFT(elm, field) = RB_RIGHT(elm, field) = nullptr; \
|
|
363
363
|
} while (/*CONSTCOND*/ 0)
|
|
364
364
|
|
|
365
|
-
#define RB_COLOR(elm, field) (RB_PARENT(elm, field) ==
|
|
365
|
+
#define RB_COLOR(elm, field) (RB_PARENT(elm, field) == nullptr ? 0 : \
|
|
366
366
|
RB_LEFT(RB_PARENT(elm, field), field) == elm ? \
|
|
367
367
|
RB_RED_LEFT(RB_PARENT(elm, field), field) : \
|
|
368
368
|
RB_RED_RIGHT(RB_PARENT(elm, field), field))
|
|
@@ -376,7 +376,7 @@ struct { \
|
|
|
376
376
|
#endif
|
|
377
377
|
|
|
378
378
|
#define RB_SWAP_CHILD(head, out, in, field) do { \
|
|
379
|
-
if (RB_PARENT(out, field) ==
|
|
379
|
+
if (RB_PARENT(out, field) == nullptr) \
|
|
380
380
|
RB_ROOT(head) = (in); \
|
|
381
381
|
else if ((out) == RB_LEFT(RB_PARENT(out, field), field)) \
|
|
382
382
|
RB_LEFT(RB_PARENT(out, field), field) = (in); \
|
|
@@ -386,7 +386,7 @@ struct { \
|
|
|
386
386
|
|
|
387
387
|
#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \
|
|
388
388
|
(tmp) = RB_RIGHT(elm, field); \
|
|
389
|
-
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) !=
|
|
389
|
+
if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != nullptr) { \
|
|
390
390
|
RB_SET_PARENT(RB_RIGHT(elm, field), elm, field); \
|
|
391
391
|
} \
|
|
392
392
|
RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
|
|
@@ -398,7 +398,7 @@ struct { \
|
|
|
398
398
|
|
|
399
399
|
#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \
|
|
400
400
|
(tmp) = RB_LEFT(elm, field); \
|
|
401
|
-
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) !=
|
|
401
|
+
if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != nullptr) { \
|
|
402
402
|
RB_SET_PARENT(RB_LEFT(elm, field), elm, field); \
|
|
403
403
|
} \
|
|
404
404
|
RB_SET_PARENT(tmp, RB_PARENT(elm, field), field); \
|
|
@@ -524,7 +524,7 @@ name##_RB_INSERT_COLOR(struct name *head, struct type *parent, struct type *elm)
|
|
|
524
524
|
} \
|
|
525
525
|
RB_BITS(elm, field) &= ~RB_RED_MASK; \
|
|
526
526
|
break; \
|
|
527
|
-
} while ((parent = RB_PARENT(elm, field)) !=
|
|
527
|
+
} while ((parent = RB_PARENT(elm, field)) != nullptr); \
|
|
528
528
|
}
|
|
529
529
|
|
|
530
530
|
#define RB_GENERATE_REMOVE_COLOR(name, type, field, attr) \
|
|
@@ -538,7 +538,7 @@ name##_RB_REMOVE_COLOR(struct name *head, \
|
|
|
538
538
|
RB_BITS(parent, field) &= ~RB_RED_MASK; \
|
|
539
539
|
elm = parent; \
|
|
540
540
|
parent = RB_PARENT(elm, field); \
|
|
541
|
-
if (parent ==
|
|
541
|
+
if (parent == nullptr) \
|
|
542
542
|
return; \
|
|
543
543
|
} \
|
|
544
544
|
do { \
|
|
@@ -604,7 +604,7 @@ name##_RB_REMOVE_COLOR(struct name *head, \
|
|
|
604
604
|
RB_ROTATE_RIGHT(head, parent, sib, field); \
|
|
605
605
|
} \
|
|
606
606
|
break; \
|
|
607
|
-
} while ((parent = RB_PARENT(elm, field)) !=
|
|
607
|
+
} while ((parent = RB_PARENT(elm, field)) != nullptr); \
|
|
608
608
|
}
|
|
609
609
|
|
|
610
610
|
#define RB_GENERATE_REMOVE(name, type, field, attr) \
|
|
@@ -616,19 +616,19 @@ name##_RB_REMOVE(struct name *head, struct type *elm) \
|
|
|
616
616
|
old = elm; \
|
|
617
617
|
parent = RB_PARENT(elm, field); \
|
|
618
618
|
right = RB_RIGHT(elm, field); \
|
|
619
|
-
if (RB_LEFT(elm, field) ==
|
|
619
|
+
if (RB_LEFT(elm, field) == nullptr) \
|
|
620
620
|
elm = child = right; \
|
|
621
|
-
else if (right ==
|
|
621
|
+
else if (right == nullptr) \
|
|
622
622
|
elm = child = RB_LEFT(elm, field); \
|
|
623
623
|
else { \
|
|
624
|
-
if ((child = RB_LEFT(right, field)) ==
|
|
624
|
+
if ((child = RB_LEFT(right, field)) == nullptr) { \
|
|
625
625
|
child = RB_RIGHT(right, field); \
|
|
626
626
|
RB_RIGHT(old, field) = child; \
|
|
627
627
|
parent = elm = right; \
|
|
628
628
|
} else { \
|
|
629
629
|
do \
|
|
630
630
|
elm = child; \
|
|
631
|
-
while ((child = RB_LEFT(elm, field)) !=
|
|
631
|
+
while ((child = RB_LEFT(elm, field)) != nullptr); \
|
|
632
632
|
child = RB_RIGHT(elm, field); \
|
|
633
633
|
parent = RB_PARENT(elm, field); \
|
|
634
634
|
RB_LEFT(parent, field) = child; \
|
|
@@ -638,11 +638,11 @@ name##_RB_REMOVE(struct name *head, struct type *elm) \
|
|
|
638
638
|
elm->field = old->field; \
|
|
639
639
|
} \
|
|
640
640
|
RB_SWAP_CHILD(head, old, elm, field); \
|
|
641
|
-
if (child !=
|
|
641
|
+
if (child != nullptr) \
|
|
642
642
|
RB_SET_PARENT(child, parent, field); \
|
|
643
|
-
if (parent !=
|
|
643
|
+
if (parent != nullptr) \
|
|
644
644
|
name##_RB_REMOVE_COLOR(head, parent, child); \
|
|
645
|
-
while (parent !=
|
|
645
|
+
while (parent != nullptr) { \
|
|
646
646
|
RB_AUGMENT(parent); \
|
|
647
647
|
parent = RB_PARENT(parent, field); \
|
|
648
648
|
} \
|
|
@@ -657,12 +657,12 @@ name##_RB_INSERT_FINISH(struct name *head, struct type *parent, \
|
|
|
657
657
|
{ \
|
|
658
658
|
RB_SET(elm, parent, field); \
|
|
659
659
|
*pptr = elm; \
|
|
660
|
-
if (parent !=
|
|
661
|
-
while (elm !=
|
|
660
|
+
if (parent != nullptr) name##_RB_INSERT_COLOR(head, parent, elm); \
|
|
661
|
+
while (elm != nullptr) { \
|
|
662
662
|
RB_AUGMENT(elm); \
|
|
663
663
|
elm = RB_PARENT(elm, field); \
|
|
664
664
|
} \
|
|
665
|
-
return
|
|
665
|
+
return nullptr; \
|
|
666
666
|
}
|
|
667
667
|
|
|
668
668
|
#define RB_GENERATE_INSERT(name, type, field, cmp, attr) \
|
|
@@ -672,10 +672,10 @@ name##_RB_INSERT(struct name *head, struct type *elm) \
|
|
|
672
672
|
{ \
|
|
673
673
|
struct type *tmp; \
|
|
674
674
|
struct type **tmpp = &RB_ROOT(head); \
|
|
675
|
-
struct type *parent =
|
|
676
|
-
while ((tmp = *tmpp) !=
|
|
675
|
+
struct type *parent = nullptr; \
|
|
676
|
+
while ((tmp = *tmpp) != nullptr) { \
|
|
677
677
|
parent = tmp; \
|
|
678
|
-
__typeof(cmp(
|
|
678
|
+
__typeof(cmp((void *)1, (void *)1)) comp = (cmp)(elm, parent); \
|
|
679
679
|
if (comp < 0) tmpp = &RB_LEFT(parent, field); \
|
|
680
680
|
else if (comp > 0) tmpp = &RB_RIGHT(parent, field); \
|
|
681
681
|
else return (parent); \
|
|
@@ -689,7 +689,7 @@ name##_RB_INSERT_NEXT(struct name *head, struct type * restrict elm, struct type
|
|
|
689
689
|
{ \
|
|
690
690
|
struct type *tmp; \
|
|
691
691
|
struct type **tmpp = &RB_RIGHT(elm, field); \
|
|
692
|
-
while ((tmp = *tmpp) !=
|
|
692
|
+
while ((tmp = *tmpp) != nullptr) { \
|
|
693
693
|
elm = tmp; \
|
|
694
694
|
tmpp = &RB_LEFT(elm, field); \
|
|
695
695
|
} \
|
|
@@ -702,7 +702,7 @@ attr struct type * \
|
|
|
702
702
|
name##_RB_FIND(struct name *head, struct type *elm) \
|
|
703
703
|
{ \
|
|
704
704
|
struct type *tmp = RB_ROOT(head); \
|
|
705
|
-
__typeof(cmp(
|
|
705
|
+
__typeof(cmp((void *)1, (void *)1)) comp; \
|
|
706
706
|
while (tmp) { \
|
|
707
707
|
comp = cmp(elm, tmp); \
|
|
708
708
|
if (comp < 0) \
|
|
@@ -712,7 +712,7 @@ name##_RB_FIND(struct name *head, struct type *elm) \
|
|
|
712
712
|
else \
|
|
713
713
|
return (tmp); \
|
|
714
714
|
} \
|
|
715
|
-
return
|
|
715
|
+
return nullptr; \
|
|
716
716
|
}
|
|
717
717
|
|
|
718
718
|
#define RB_GENERATE_NFIND(name, type, field, cmp, attr) \
|
|
@@ -721,8 +721,8 @@ attr struct type * \
|
|
|
721
721
|
name##_RB_NFIND(struct name *head, struct type *elm) \
|
|
722
722
|
{ \
|
|
723
723
|
struct type *tmp = RB_ROOT(head); \
|
|
724
|
-
struct type *res =
|
|
725
|
-
__typeof(cmp(
|
|
724
|
+
struct type *res = nullptr; \
|
|
725
|
+
__typeof(cmp((void *)1, (void *)1)) comp; \
|
|
726
726
|
while (tmp) { \
|
|
727
727
|
comp = cmp(elm, tmp); \
|
|
728
728
|
if (comp < 0) { \
|
|
@@ -778,7 +778,7 @@ attr struct type * \
|
|
|
778
778
|
name##_RB_MINMAX(struct name *head, int val) \
|
|
779
779
|
{ \
|
|
780
780
|
struct type *tmp = RB_ROOT(head); \
|
|
781
|
-
struct type *parent =
|
|
781
|
+
struct type *parent = nullptr; \
|
|
782
782
|
while (tmp) { \
|
|
783
783
|
parent = tmp; \
|
|
784
784
|
if (val < 0) \
|
|
@@ -794,15 +794,15 @@ attr struct type * \
|
|
|
794
794
|
name##_RB_REINSERT(struct name *head, struct type *elm) \
|
|
795
795
|
{ \
|
|
796
796
|
struct type *cmpelm; \
|
|
797
|
-
if (((cmpelm = RB_PREV(name, head, elm)) !=
|
|
797
|
+
if (((cmpelm = RB_PREV(name, head, elm)) != nullptr && \
|
|
798
798
|
cmp(cmpelm, elm) >= 0) || \
|
|
799
|
-
((cmpelm = RB_NEXT(name, head, elm)) !=
|
|
799
|
+
((cmpelm = RB_NEXT(name, head, elm)) != nullptr && \
|
|
800
800
|
cmp(elm, cmpelm) >= 0)) { \
|
|
801
801
|
/* XXXLAS: Remove/insert is heavy handed. */ \
|
|
802
802
|
RB_REMOVE(name, head, elm); \
|
|
803
803
|
return (RB_INSERT(name, head, elm)); \
|
|
804
804
|
} \
|
|
805
|
-
return
|
|
805
|
+
return nullptr; \
|
|
806
806
|
} \
|
|
807
807
|
|
|
808
808
|
#define RB_NEGINF -1
|
|
@@ -821,32 +821,32 @@ name##_RB_REINSERT(struct name *head, struct type *elm) \
|
|
|
821
821
|
|
|
822
822
|
#define RB_FOREACH(x, name, head) \
|
|
823
823
|
for ((x) = RB_MIN(name, head); \
|
|
824
|
-
(x) !=
|
|
824
|
+
(x) != nullptr; \
|
|
825
825
|
(x) = name##_RB_NEXT(x))
|
|
826
826
|
|
|
827
827
|
#define RB_FOREACH_FROM(x, name, y) \
|
|
828
828
|
for ((x) = (y); \
|
|
829
|
-
((x) !=
|
|
829
|
+
((x) != nullptr) && ((y) = name##_RB_NEXT(x), (x) != nullptr); \
|
|
830
830
|
(x) = (y))
|
|
831
831
|
|
|
832
832
|
#define RB_FOREACH_SAFE(x, name, head, y) \
|
|
833
833
|
for ((x) = RB_MIN(name, head); \
|
|
834
|
-
((x) !=
|
|
834
|
+
((x) != nullptr) && ((y) = name##_RB_NEXT(x), (x) != nullptr); \
|
|
835
835
|
(x) = (y))
|
|
836
836
|
|
|
837
837
|
#define RB_FOREACH_REVERSE(x, name, head) \
|
|
838
838
|
for ((x) = RB_MAX(name, head); \
|
|
839
|
-
(x) !=
|
|
839
|
+
(x) != nullptr; \
|
|
840
840
|
(x) = name##_RB_PREV(x))
|
|
841
841
|
|
|
842
842
|
#define RB_FOREACH_REVERSE_FROM(x, name, y) \
|
|
843
843
|
for ((x) = (y); \
|
|
844
|
-
((x) !=
|
|
844
|
+
((x) != nullptr) && ((y) = name##_RB_PREV(x), (x) != nullptr); \
|
|
845
845
|
(x) = (y))
|
|
846
846
|
|
|
847
847
|
#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \
|
|
848
848
|
for ((x) = RB_MAX(name, head); \
|
|
849
|
-
((x) !=
|
|
849
|
+
((x) != nullptr) && ((y) = name##_RB_PREV(x), (x) != nullptr); \
|
|
850
850
|
(x) = (y))
|
|
851
851
|
|
|
852
852
|
#endif /* _SYS_TREE_H_ */
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
* Size of a struct with its flexible array member.
|
|
296
296
|
*/
|
|
297
297
|
#define sizeof_wflex(t, f, count) \
|
|
298
|
-
max(sizeof(t), offsetof(t, f[0]) + count * sizeof(((t*)0)->f[0]))
|
|
298
|
+
max(sizeof(t), offsetof(t, f[0]) + (count) * sizeof(((t*)0)->f[0]))
|
|
299
299
|
|
|
300
300
|
/**
|
|
301
301
|
* Check if pointer has a const qualifier.
|
|
@@ -73,7 +73,7 @@ struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct S
|
|
|
73
73
|
|
|
74
74
|
SELVA_EXPORT
|
|
75
75
|
inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
|
|
76
|
-
#
|
|
76
|
+
#ifndef __zig
|
|
77
77
|
{
|
|
78
78
|
return te->blocks->block_capacity;
|
|
79
79
|
}
|
|
@@ -87,7 +87,7 @@ inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
|
|
|
87
87
|
SELVA_EXPORT
|
|
88
88
|
__attribute__((nonnull, pure))
|
|
89
89
|
inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
|
|
90
|
-
#
|
|
90
|
+
#ifndef __zig
|
|
91
91
|
{
|
|
92
92
|
return &te->ns;
|
|
93
93
|
}
|
|
@@ -98,7 +98,7 @@ inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEn
|
|
|
98
98
|
SELVA_EXPORT
|
|
99
99
|
__attribute__((nonnull, pure))
|
|
100
100
|
inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
|
|
101
|
-
#
|
|
101
|
+
#ifndef __zig
|
|
102
102
|
{
|
|
103
103
|
if (field >= fields_schema->nr_fields) {
|
|
104
104
|
return nullptr;
|
|
@@ -116,7 +116,7 @@ inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct
|
|
|
116
116
|
SELVA_EXPORT
|
|
117
117
|
__attribute__((nonnull, pure))
|
|
118
118
|
inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
|
|
119
|
-
#
|
|
119
|
+
#ifndef __zig
|
|
120
120
|
{
|
|
121
121
|
return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
|
|
122
122
|
}
|
|
@@ -130,7 +130,7 @@ inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct Selv
|
|
|
130
130
|
SELVA_EXPORT
|
|
131
131
|
__attribute__((nonnull, pure))
|
|
132
132
|
inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
|
|
133
|
-
#
|
|
133
|
+
#ifndef __zig
|
|
134
134
|
{
|
|
135
135
|
return get_fs_by_fields_schema_field(&ns->fields_schema, field);
|
|
136
136
|
}
|
|
@@ -144,7 +144,7 @@ inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct Selv
|
|
|
144
144
|
SELVA_EXPORT
|
|
145
145
|
__attribute__((nonnull, pure))
|
|
146
146
|
inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
|
|
147
|
-
#
|
|
147
|
+
#ifndef __zig
|
|
148
148
|
{
|
|
149
149
|
struct SelvaTypeEntry *type;
|
|
150
150
|
|
|
@@ -164,7 +164,7 @@ SELVA_EXPORT
|
|
|
164
164
|
[[reproducible]]
|
|
165
165
|
#endif
|
|
166
166
|
inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
|
|
167
|
-
#
|
|
167
|
+
#ifndef __zig
|
|
168
168
|
{
|
|
169
169
|
return fs->type;
|
|
170
170
|
}
|
|
@@ -181,7 +181,7 @@ inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
|
|
|
181
181
|
SELVA_EXPORT
|
|
182
182
|
__attribute__((nonnull))
|
|
183
183
|
inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
|
|
184
|
-
#
|
|
184
|
+
#ifndef __zig
|
|
185
185
|
{
|
|
186
186
|
return (fs->type == SELVA_FIELD_TYPE_REFERENCE || fs->type == SELVA_FIELD_TYPE_REFERENCES)
|
|
187
187
|
? &fs->edge_constraint
|
|
@@ -310,7 +310,7 @@ size_t selva_node_count(const struct SelvaTypeEntry *type) __attribute__((nonnul
|
|
|
310
310
|
SELVA_EXPORT
|
|
311
311
|
__attribute__((nonnull, pure))
|
|
312
312
|
inline node_id_t selva_get_node_id(const struct SelvaNode *node)
|
|
313
|
-
#
|
|
313
|
+
#ifndef __zig
|
|
314
314
|
{
|
|
315
315
|
return node->node_id;
|
|
316
316
|
}
|
|
@@ -324,7 +324,7 @@ inline node_id_t selva_get_node_id(const struct SelvaNode *node)
|
|
|
324
324
|
SELVA_EXPORT
|
|
325
325
|
__attribute__((nonnull, pure))
|
|
326
326
|
inline node_type_t selva_get_node_type(const struct SelvaNode *node)
|
|
327
|
-
#
|
|
327
|
+
#ifndef __zig
|
|
328
328
|
{
|
|
329
329
|
return node->type;
|
|
330
330
|
}
|
|
@@ -346,7 +346,7 @@ SELVA_EXPORT
|
|
|
346
346
|
selva_hash128_t selva_node_hash_update(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node, struct XXH3_state_s *tmp_hash_state);
|
|
347
347
|
|
|
348
348
|
SELVA_EXPORT
|
|
349
|
-
selva_hash128_t
|
|
349
|
+
selva_hash128_t selva_node_hash(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node);
|
|
350
350
|
|
|
351
351
|
SELVA_EXPORT
|
|
352
352
|
selva_hash128_t selva_node_hash_range(struct SelvaDb *db, struct SelvaTypeEntry *type, node_id_t start, node_id_t end) __attribute__((nonnull));
|