@based/db 0.0.25 → 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.
Files changed (88) hide show
  1. package/dist/lib/darwin_aarch64/include/cdefs.h +1 -1
  2. package/dist/lib/darwin_aarch64/include/selva/db.h +45 -11
  3. package/dist/lib/darwin_aarch64/include/selva/fields.h +48 -13
  4. package/dist/lib/darwin_aarch64/include/selva/hll.h +59 -0
  5. package/dist/lib/darwin_aarch64/include/selva/types.h +2 -0
  6. package/dist/lib/darwin_aarch64/include/tree.h +69 -69
  7. package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
  8. package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
  9. package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
  10. package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
  11. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  12. package/dist/lib/linux_aarch64/include/cdefs.h +1 -1
  13. package/dist/lib/linux_aarch64/include/selva/db.h +45 -11
  14. package/dist/lib/linux_aarch64/include/selva/fields.h +48 -13
  15. package/dist/lib/linux_aarch64/include/selva/hll.h +59 -0
  16. package/dist/lib/linux_aarch64/include/selva/types.h +2 -0
  17. package/dist/lib/linux_aarch64/include/tree.h +69 -69
  18. package/dist/lib/linux_aarch64/libdeflate.so +0 -0
  19. package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
  20. package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
  21. package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
  22. package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
  23. package/dist/lib/linux_aarch64/libselva.so +0 -0
  24. package/dist/lib/linux_x86_64/include/cdefs.h +1 -1
  25. package/dist/lib/linux_x86_64/include/selva/db.h +45 -11
  26. package/dist/lib/linux_x86_64/include/selva/fields.h +48 -13
  27. package/dist/lib/linux_x86_64/include/selva/hll.h +59 -0
  28. package/dist/lib/linux_x86_64/include/selva/types.h +2 -0
  29. package/dist/lib/linux_x86_64/include/tree.h +69 -69
  30. package/dist/lib/linux_x86_64/libdeflate.so +0 -0
  31. package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
  32. package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
  33. package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
  34. package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
  35. package/dist/lib/linux_x86_64/libselva.so +0 -0
  36. package/dist/src/client/flushModify.js +5 -1
  37. package/dist/src/client/index.d.ts +12 -6
  38. package/dist/src/client/index.js +33 -1
  39. package/dist/src/client/modify/alias.js +3 -0
  40. package/dist/src/client/modify/binary.js +1 -1
  41. package/dist/src/client/modify/cardinality.d.ts +2 -2
  42. package/dist/src/client/modify/cardinality.js +17 -6
  43. package/dist/src/client/modify/create.js +17 -1
  44. package/dist/src/client/modify/fixed.js +27 -23
  45. package/dist/src/client/modify/json.js +15 -1
  46. package/dist/src/client/modify/modify.js +3 -1
  47. package/dist/src/client/modify/references/edge.js +4 -2
  48. package/dist/src/client/modify/references/references.js +21 -6
  49. package/dist/src/client/modify/string.js +5 -6
  50. package/dist/src/client/modify/text.js +0 -11
  51. package/dist/src/client/modify/upsert.js +1 -1
  52. package/dist/src/client/modify/vector.js +3 -3
  53. package/dist/src/client/query/BasedDbQuery.js +9 -1
  54. package/dist/src/client/query/BasedIterable.js +10 -3
  55. package/dist/src/client/query/aggregation.d.ts +3 -0
  56. package/dist/src/client/query/aggregation.js +9 -0
  57. package/dist/src/client/query/display.js +12 -2
  58. package/dist/src/client/query/filter/parseFilterValue.js +2 -4
  59. package/dist/src/client/query/filter/toBuffer.js +2 -2
  60. package/dist/src/client/query/include/walk.js +1 -0
  61. package/dist/src/client/query/query.d.ts +1 -1
  62. package/dist/src/client/query/query.js +1 -1
  63. package/dist/src/client/query/queryDef.js +0 -1
  64. package/dist/src/client/query/read/read.js +17 -5
  65. package/dist/src/client/query/toBuffer.js +2 -2
  66. package/dist/src/client/query/types.d.ts +4 -3
  67. package/dist/src/client/query/validation.js +8 -1
  68. package/dist/src/client/string.js +1 -1
  69. package/dist/src/index.d.ts +7 -1
  70. package/dist/src/index.js +19 -4
  71. package/dist/src/native.d.ts +1 -1
  72. package/dist/src/native.js +2 -2
  73. package/dist/src/server/csmt/tree.js +2 -2
  74. package/dist/src/server/index.d.ts +1 -1
  75. package/dist/src/server/index.js +36 -4
  76. package/dist/src/server/migrate/index.js +9 -5
  77. package/dist/src/server/migrate/worker.js +26 -1
  78. package/dist/src/server/save.js +20 -12
  79. package/dist/src/server/start.js +0 -2
  80. package/dist/src/utils.d.ts +6 -0
  81. package/dist/src/utils.js +81 -9
  82. package/package.json +4 -3
  83. package/dist/src/client/bitWise.d.ts +0 -6
  84. package/dist/src/client/bitWise.js +0 -72
  85. package/dist/src/client/query/aggregationFn.d.ts +0 -3
  86. package/dist/src/client/query/aggregationFn.js +0 -9
  87. package/dist/src/client/tree.d.ts +0 -1
  88. 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
- { NULL }
80
+ { nullptr }
81
81
 
82
82
  #define SPLAY_INIT(root) do { \
83
- (root)->sph_root = NULL; \
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) == NULL)
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(NULL); \
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 (NULL); \
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) != NULL) { \
153
+ if (SPLAY_RIGHT(elm, field) != nullptr) { \
154
154
  elm = SPLAY_RIGHT(elm, field); \
155
- while (SPLAY_LEFT(elm, field) != NULL) { \
155
+ while (SPLAY_LEFT(elm, field) != nullptr) { \
156
156
  elm = SPLAY_LEFT(elm, field); \
157
157
  } \
158
158
  } else \
159
- elm = NULL; \
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) = NULL; \
178
+ SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = nullptr; \
179
179
  } else { \
180
- __typeof(cmp(NULL, NULL)) __comp; \
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) = NULL; \
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) = NULL; \
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 (NULL); \
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 (NULL); \
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) == NULL) { \
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 (NULL); \
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(NULL, NULL)) __comp; \
223
+ __typeof(cmp((void *)1, (void *)1)) __comp; \
224
224
  \
225
- SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL;\
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 == NULL) \
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) == NULL)\
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 == NULL) \
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) == NULL)\
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) = NULL;\
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 == NULL) \
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) == NULL)\
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 == NULL) \
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) == NULL)\
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) ? NULL \
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) ? NULL \
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) != NULL; \
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
- { NULL }
314
+ { nullptr }
315
315
 
316
316
  #define RB_INIT(root) do { \
317
- (root)->rbh_root = NULL; \
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) == NULL)
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) = NULL; \
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) == NULL ? 0 : \
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) == NULL) \
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)) != NULL) { \
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)) != NULL) { \
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)) != NULL); \
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 == NULL) \
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)) != NULL); \
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) == NULL) \
619
+ if (RB_LEFT(elm, field) == nullptr) \
620
620
  elm = child = right; \
621
- else if (right == NULL) \
621
+ else if (right == nullptr) \
622
622
  elm = child = RB_LEFT(elm, field); \
623
623
  else { \
624
- if ((child = RB_LEFT(right, field)) == NULL) { \
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)) != NULL); \
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 != NULL) \
641
+ if (child != nullptr) \
642
642
  RB_SET_PARENT(child, parent, field); \
643
- if (parent != NULL) \
643
+ if (parent != nullptr) \
644
644
  name##_RB_REMOVE_COLOR(head, parent, child); \
645
- while (parent != NULL) { \
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 != NULL) name##_RB_INSERT_COLOR(head, parent, elm); \
661
- while (elm != NULL) { \
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 NULL; \
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 = NULL; \
676
- while ((tmp = *tmpp) != NULL) { \
675
+ struct type *parent = nullptr; \
676
+ while ((tmp = *tmpp) != nullptr) { \
677
677
  parent = tmp; \
678
- __typeof(cmp(NULL, NULL)) comp = (cmp)(elm, parent); \
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) != NULL) { \
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(NULL, NULL)) comp; \
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 (NULL); \
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 = NULL; \
725
- __typeof(cmp(NULL, NULL)) comp; \
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 = NULL; \
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)) != NULL && \
797
+ if (((cmpelm = RB_PREV(name, head, elm)) != nullptr && \
798
798
  cmp(cmpelm, elm) >= 0) || \
799
- ((cmpelm = RB_NEXT(name, head, elm)) != NULL && \
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 (NULL); \
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) != NULL; \
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) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
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) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \
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) != NULL; \
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) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
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) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \
849
+ ((x) != nullptr) && ((y) = name##_RB_PREV(x), (x) != nullptr); \
850
850
  (x) = (y))
851
851
 
852
852
  #endif /* _SYS_TREE_H_ */
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.
@@ -71,13 +71,23 @@ struct SelvaTypeEntry *selva_get_type_by_index(const struct SelvaDb *db, node_ty
71
71
  SELVA_EXPORT
72
72
  struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct SelvaNode *node) __attribute__((nonnull, pure));
73
73
 
74
+ SELVA_EXPORT
75
+ inline block_id_t selva_get_block_capacity(const struct SelvaTypeEntry *te)
76
+ #ifndef __zig
77
+ {
78
+ return te->blocks->block_capacity;
79
+ }
80
+ #else
81
+ ;
82
+ #endif
83
+
74
84
  /**
75
85
  * Get the node schema for type.
76
86
  */
77
87
  SELVA_EXPORT
78
88
  __attribute__((nonnull, pure))
79
89
  inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
80
- #if !__zig
90
+ #ifndef __zig
81
91
  {
82
92
  return &te->ns;
83
93
  }
@@ -88,7 +98,7 @@ inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEn
88
98
  SELVA_EXPORT
89
99
  __attribute__((nonnull, pure))
90
100
  inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
91
- #if !__zig
101
+ #ifndef __zig
92
102
  {
93
103
  if (field >= fields_schema->nr_fields) {
94
104
  return nullptr;
@@ -106,7 +116,7 @@ inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct
106
116
  SELVA_EXPORT
107
117
  __attribute__((nonnull, pure))
108
118
  inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
109
- #if !__zig
119
+ #ifndef __zig
110
120
  {
111
121
  return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
112
122
  }
@@ -120,7 +130,7 @@ inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct Selv
120
130
  SELVA_EXPORT
121
131
  __attribute__((nonnull, pure))
122
132
  inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
123
- #if !__zig
133
+ #ifndef __zig
124
134
  {
125
135
  return get_fs_by_fields_schema_field(&ns->fields_schema, field);
126
136
  }
@@ -134,7 +144,7 @@ inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct Selv
134
144
  SELVA_EXPORT
135
145
  __attribute__((nonnull, pure))
136
146
  inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
137
- #if !__zig
147
+ #ifndef __zig
138
148
  {
139
149
  struct SelvaTypeEntry *type;
140
150
 
@@ -154,7 +164,7 @@ SELVA_EXPORT
154
164
  [[reproducible]]
155
165
  #endif
156
166
  inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
157
- #if !__zig
167
+ #ifndef __zig
158
168
  {
159
169
  return fs->type;
160
170
  }
@@ -171,7 +181,7 @@ inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
171
181
  SELVA_EXPORT
172
182
  __attribute__((nonnull))
173
183
  inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
174
- #if !__zig
184
+ #ifndef __zig
175
185
  {
176
186
  return (fs->type == SELVA_FIELD_TYPE_REFERENCE || fs->type == SELVA_FIELD_TYPE_REFERENCES)
177
187
  ? &fs->edge_constraint
@@ -298,7 +308,29 @@ size_t selva_node_count(const struct SelvaTypeEntry *type) __attribute__((nonnul
298
308
  * Get the node id of of node.
299
309
  */
300
310
  SELVA_EXPORT
301
- node_id_t selva_get_node_id(const struct SelvaNode *node) __attribute__((nonnull, pure));
311
+ __attribute__((nonnull, pure))
312
+ inline node_id_t selva_get_node_id(const struct SelvaNode *node)
313
+ #ifndef __zig
314
+ {
315
+ return node->node_id;
316
+ }
317
+ #else
318
+ ;
319
+ #endif
320
+
321
+ /**
322
+ * Get the type of of node.
323
+ */
324
+ SELVA_EXPORT
325
+ __attribute__((nonnull, pure))
326
+ inline node_type_t selva_get_node_type(const struct SelvaNode *node)
327
+ #ifndef __zig
328
+ {
329
+ return node->type;
330
+ }
331
+ #else
332
+ ;
333
+ #endif
302
334
 
303
335
  /**
304
336
  * \addtogroup node_hash
@@ -314,7 +346,7 @@ SELVA_EXPORT
314
346
  selva_hash128_t selva_node_hash_update(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node, struct XXH3_state_s *tmp_hash_state);
315
347
 
316
348
  SELVA_EXPORT
317
- selva_hash128_t selva_node_hash_update2(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node);
349
+ selva_hash128_t selva_node_hash(struct SelvaDb *db, struct SelvaTypeEntry *type, struct SelvaNode *node);
318
350
 
319
351
  SELVA_EXPORT
320
352
  selva_hash128_t selva_node_hash_range(struct SelvaDb *db, struct SelvaTypeEntry *type, node_id_t start, node_id_t end) __attribute__((nonnull));
@@ -332,15 +364,17 @@ size_t selva_alias_count(const struct SelvaAliases *aliases);
332
364
  /**
333
365
  * Set new alias.
334
366
  * @param name is copied.
367
+ * @returns the previous node_id the alias was pointing to; Otherwise 0.
335
368
  */
336
369
  SELVA_EXPORT
337
- void selva_set_alias(struct SelvaAliases *aliases, node_id_t dest, const char *name_str, size_t name_len);
370
+ node_id_t selva_set_alias(struct SelvaAliases *aliases, node_id_t dest, const char *name_str, size_t name_len);
338
371
 
339
372
  /**
340
373
  * Delete alias by name.
374
+ * @return the destination node_id the alias was pointing to; 0 if SELVA_ENOENT.
341
375
  */
342
376
  SELVA_EXPORT
343
- int selva_del_alias_by_name(struct SelvaAliases *aliases, const char *name_str, size_t name_len);
377
+ node_id_t selva_del_alias_by_name(struct SelvaAliases *aliases, const char *name_str, size_t name_len);
344
378
 
345
379
  /**
346
380
  * Delete all aliases pointing to dest.