@based/db 0.0.18 → 0.0.20

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 (107) hide show
  1. package/dist/lib/darwin_aarch64/include/selva/db.h +89 -6
  2. package/dist/lib/darwin_aarch64/include/selva/fields.h +28 -39
  3. package/dist/lib/darwin_aarch64/include/selva/types.h +0 -10
  4. package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
  5. package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
  6. package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
  7. package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
  8. package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
  9. package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
  10. package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
  11. package/dist/lib/linux_aarch64/include/selva/db.h +89 -6
  12. package/dist/lib/linux_aarch64/include/selva/fields.h +28 -39
  13. package/dist/lib/linux_aarch64/include/selva/types.h +0 -10
  14. package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
  15. package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
  16. package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
  17. package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
  18. package/dist/lib/linux_aarch64/libselva.so +0 -0
  19. package/dist/lib/linux_x86_64/include/selva/db.h +89 -6
  20. package/dist/lib/linux_x86_64/include/selva/fields.h +28 -39
  21. package/dist/lib/linux_x86_64/include/selva/types.h +0 -10
  22. package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
  23. package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
  24. package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
  25. package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
  26. package/dist/lib/linux_x86_64/libselva.so +0 -0
  27. package/dist/src/client/index.d.ts +1 -1
  28. package/dist/src/client/index.js +8 -3
  29. package/dist/src/client/modify/ModifyRes.d.ts +1 -1
  30. package/dist/src/client/modify/ModifyRes.js +1 -1
  31. package/dist/src/client/modify/alias.d.ts +1 -1
  32. package/dist/src/client/modify/binary.d.ts +1 -1
  33. package/dist/src/client/modify/cardinality.d.ts +1 -1
  34. package/dist/src/client/modify/cardinality.js +1 -1
  35. package/dist/src/client/modify/create.js +2 -2
  36. package/dist/src/client/modify/delete.js +1 -1
  37. package/dist/src/client/modify/expire.js +1 -1
  38. package/dist/src/client/modify/fixed.d.ts +1 -1
  39. package/dist/src/client/modify/fixed.js +1 -1
  40. package/dist/src/client/modify/json.d.ts +1 -1
  41. package/dist/src/client/modify/modify.d.ts +1 -1
  42. package/dist/src/client/modify/modify.js +1 -1
  43. package/dist/src/client/modify/references/edge.d.ts +1 -1
  44. package/dist/src/client/modify/references/edge.js +1 -1
  45. package/dist/src/client/modify/references/reference.d.ts +1 -1
  46. package/dist/src/client/modify/references/references.d.ts +1 -1
  47. package/dist/src/client/modify/references/references.js +1 -1
  48. package/dist/src/client/modify/setCursor.d.ts +1 -1
  49. package/dist/src/client/modify/string.d.ts +1 -1
  50. package/dist/src/client/modify/text.d.ts +1 -1
  51. package/dist/src/client/modify/text.js +6 -0
  52. package/dist/src/client/modify/update.js +1 -1
  53. package/dist/src/client/modify/upsert.js +1 -1
  54. package/dist/src/client/modify/vector.d.ts +1 -1
  55. package/dist/src/client/operations.d.ts +2 -1
  56. package/dist/src/client/operations.js +1 -0
  57. package/dist/src/client/query/BasedDbQuery.js +1 -1
  58. package/dist/src/client/query/debug.js +1 -1
  59. package/dist/src/client/query/display.d.ts +1 -1
  60. package/dist/src/client/query/display.js +1 -1
  61. package/dist/src/client/query/filter/createFixedFilterBuffer.d.ts +1 -1
  62. package/dist/src/client/query/filter/createFixedFilterBuffer.js +1 -2
  63. package/dist/src/client/query/filter/createReferenceFilter.d.ts +1 -1
  64. package/dist/src/client/query/filter/createVariableFilterBuffer.d.ts +1 -1
  65. package/dist/src/client/query/filter/createVariableFilterBuffer.js +1 -1
  66. package/dist/src/client/query/filter/filter.d.ts +1 -1
  67. package/dist/src/client/query/filter/filter.js +1 -1
  68. package/dist/src/client/query/filter/parseFilterValue.d.ts +1 -1
  69. package/dist/src/client/query/filter/parseFilterValue.js +1 -1
  70. package/dist/src/client/query/filter/primitiveFilter.d.ts +1 -1
  71. package/dist/src/client/query/filter/primitiveFilter.js +4 -1
  72. package/dist/src/client/query/include/props.d.ts +1 -1
  73. package/dist/src/client/query/include/props.js +1 -1
  74. package/dist/src/client/query/include/utils.d.ts +1 -1
  75. package/dist/src/client/query/include/utils.js +1 -1
  76. package/dist/src/client/query/include/walk.js +1 -1
  77. package/dist/src/client/query/read/read.js +1 -1
  78. package/dist/src/client/query/search/index.js +1 -1
  79. package/dist/src/client/query/subscription/markers.d.ts +1 -1
  80. package/dist/src/client/query/types.d.ts +1 -1
  81. package/dist/src/client/query/validation.d.ts +1 -1
  82. package/dist/src/client/query/validation.js +9 -8
  83. package/dist/src/index.d.ts +0 -1
  84. package/dist/src/index.js +0 -1
  85. package/dist/src/server/index.d.ts +3 -5
  86. package/dist/src/server/index.js +11 -5
  87. package/dist/src/server/migrate/worker.js +1 -1
  88. package/dist/src/server/start.d.ts +0 -1
  89. package/dist/src/server/start.js +1 -1
  90. package/dist/src/server/tree.d.ts +1 -1
  91. package/package.json +2 -2
  92. package/dist/lib/darwin_aarch64/libxxhash.0.8.2.dylib +0 -0
  93. package/dist/lib/darwin_aarch64/libxxhash.0.dylib +0 -0
  94. package/dist/lib/linux_aarch64/libxxhash.so +0 -0
  95. package/dist/lib/linux_aarch64/libxxhash.so.0.8.2 +0 -0
  96. package/dist/lib/linux_x86_64/libxxhash.so +0 -0
  97. package/dist/lib/linux_x86_64/libxxhash.so.0.8.2 +0 -0
  98. package/dist/src/server/schema/schema.d.ts +0 -3
  99. package/dist/src/server/schema/schema.js +0 -4
  100. package/dist/src/server/schema/selvaBuffer.d.ts +0 -4
  101. package/dist/src/server/schema/selvaBuffer.js +0 -112
  102. package/dist/src/server/schema/typeDef.d.ts +0 -6
  103. package/dist/src/server/schema/typeDef.js +0 -337
  104. package/dist/src/server/schema/types.d.ts +0 -140
  105. package/dist/src/server/schema/types.js +0 -121
  106. package/dist/src/server/schema/utils.d.ts +0 -7
  107. package/dist/src/server/schema/utils.js +0 -34
@@ -75,28 +75,92 @@ struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct S
75
75
  * Get the node schema for type.
76
76
  */
77
77
  SELVA_EXPORT
78
- const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te) __attribute__((nonnull, pure));
78
+ __attribute__((nonnull, pure))
79
+ inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
80
+ #if !__zig
81
+ {
82
+ return &te->ns;
83
+ }
84
+ #else
85
+ ;
86
+ #endif
79
87
 
80
88
  SELVA_EXPORT
81
- const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field) __attribute__((nonnull, pure));
89
+ __attribute__((nonnull, pure))
90
+ inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
91
+ #if !__zig
92
+ {
93
+ if (field >= fields_schema->nr_fields) {
94
+ return nullptr;
95
+ }
96
+
97
+ return &fields_schema->field_schemas[field];
98
+ }
99
+ #else
100
+ ;
101
+ #endif
82
102
 
83
103
  /**
84
104
  * Get the field schema for field.
85
105
  */
86
106
  SELVA_EXPORT
87
- const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field) __attribute__((nonnull, pure));
107
+ __attribute__((nonnull, pure))
108
+ inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
109
+ #if !__zig
110
+ {
111
+ return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
112
+ }
113
+ #else
114
+ ;
115
+ #endif
88
116
 
89
117
  /**
90
118
  * Get the field schema for field.
91
119
  */
92
120
  SELVA_EXPORT
93
- const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field) __attribute__((nonnull, pure));
121
+ __attribute__((nonnull, pure))
122
+ inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
123
+ #if !__zig
124
+ {
125
+ return get_fs_by_fields_schema_field(&ns->fields_schema, field);
126
+ }
127
+ #else
128
+ ;
129
+ #endif
130
+
131
+ /**
132
+ * Get the field schema for field.
133
+ */
134
+ SELVA_EXPORT
135
+ __attribute__((nonnull, pure))
136
+ inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
137
+ #if !__zig
138
+ {
139
+ struct SelvaTypeEntry *type;
140
+
141
+ type = selva_get_type_by_node(db, node);
142
+ if (!type) {
143
+ return nullptr;
144
+ }
145
+
146
+ return selva_get_fs_by_ns_field(&type->ns, field);
147
+ }
148
+ #else
149
+ ;
150
+ #endif
94
151
 
95
152
  SELVA_EXPORT
96
153
  #if __has_c_attribute(reproducible)
97
154
  [[reproducible]]
98
155
  #endif
99
- enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs);
156
+ inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
157
+ #if !__zig
158
+ {
159
+ return fs->type;
160
+ }
161
+ #else
162
+ ;
163
+ #endif
100
164
 
101
165
  /**
102
166
  * Get the EdgeFieldConstraint from a ref field schema.
@@ -105,7 +169,17 @@ enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs);
105
169
  * struct SelvaFieldSchema *dst_fs = selva_get_fs_by_node(db, dst, efc->inverse_field);
106
170
  */
107
171
  SELVA_EXPORT
108
- const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs) __attribute__((nonnull));
172
+ __attribute__((nonnull))
173
+ inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
174
+ #if !__zig
175
+ {
176
+ return (fs->type == SELVA_FIELD_TYPE_REFERENCE || fs->type == SELVA_FIELD_TYPE_REFERENCES)
177
+ ? &fs->edge_constraint
178
+ : nullptr;
179
+ }
180
+ #else
181
+ ;
182
+ #endif
109
183
 
110
184
  SELVA_EXPORT
111
185
  const struct SelvaFieldsSchema *selva_get_edge_field_fields_schema(struct SelvaDb *db, const struct EdgeFieldConstraint *efc);
@@ -173,6 +247,11 @@ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode
173
247
  SELVA_EXPORT
174
248
  struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
175
249
 
250
+ /**
251
+ * \addtogroup db_cursor
252
+ * @{
253
+ */
254
+
176
255
  /**
177
256
  * Create a new cursor pointing to node.
178
257
  * If the node is deleted later then the cursor is updated to point to the next
@@ -205,6 +284,10 @@ void selva_cursor_del(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__
205
284
  SELVA_EXPORT
206
285
  size_t selva_cursor_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
207
286
 
287
+ /**
288
+ * @}
289
+ */
290
+
208
291
  /**
209
292
  * Total count of nodes of type.
210
293
  */
@@ -58,37 +58,21 @@ struct SelvaNodeWeakReferences {
58
58
  struct SelvaNodeWeakReference *refs __pcounted_by(nr_refs);
59
59
  };
60
60
 
61
- struct SelvaMicroBuffer {
62
- uint16_t len;
63
- uint8_t data[] __counted_by(len);
64
- } __packed;
65
-
66
- struct SelvaFieldsAny {
67
- enum SelvaFieldType type; /*!< Type of the value. */
68
- union {
69
- bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
70
- double number; /*!< SELVA_FIELD_TYPE_NUMBER */
71
- int64_t timestamp; /*!< SELVA_FIELD_TYPE_TIMESTAMP, should fit time_t */
72
- struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
73
- int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
74
- uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
75
- int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
76
- uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
77
- int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
78
- uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
79
- int64_t int64; /* SELVA_FIELD_TYPE_INT64 */
80
- uint64_t uint64; /*!< SELVA_FIELD_TYPE_UINT64 */
81
- uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
82
- #if 0
83
- struct SelvaTextField *text; /*!< SELVA_FIELD_TYPE_TEXT */
84
- struct SelvaNodeReference *reference; /*!< SELVA_FIELD_TYPE_REFERENCE */
85
- struct SelvaNodeReferences *references; /*!< SELVA_FIELD_TYPE_REFERENCES */
86
- struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
87
- struct SelvaNodeWeakReferences weak_references; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCES */
88
- struct SelvaMicroBuffer *smb; /*!< SELVA_FIELD_TYPE_MICRO_BUFFER */
89
- #endif
90
- // HyperLogLogPlusPlus cardinality; /*!< SELVA_FIELD_TYPE_HLL */
91
- };
61
+ /**
62
+ * Type helper to determine the size of statically (constant/fixed) sized fields.
63
+ */
64
+ union SelvaStaticFields {
65
+ bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
66
+ double number; /*!< SELVA_FIELD_TYPE_NUMBER */
67
+ struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
68
+ int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
69
+ uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
70
+ int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
71
+ uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
72
+ int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
73
+ uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
74
+ uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
75
+ struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
92
76
  };
93
77
 
94
78
  struct SelvaFieldsPointer {
@@ -128,7 +112,6 @@ int selva_fields_get_mutable_string(
128
112
  __attribute__((access(write_only, 4)));
129
113
 
130
114
  /*
131
- * TODO prefix with selva_
132
115
  * TODO Document diff to get_mutable_string
133
116
  */
134
117
  SELVA_EXPORT
@@ -137,6 +120,15 @@ struct selva_string *selva_fields_ensure_string(
137
120
  const struct SelvaFieldSchema *fs,
138
121
  size_t initial_len);
139
122
 
123
+ SELVA_EXPORT
124
+ struct selva_string *selva_fields_ensure_string2(
125
+ struct SelvaDb *db,
126
+ struct SelvaNode *node,
127
+ const struct EdgeFieldConstraint *efc,
128
+ struct SelvaNodeReference *ref,
129
+ const struct SelvaFieldSchema *fs,
130
+ size_t initial_len);
131
+
140
132
  SELVA_EXPORT
141
133
  int selva_fields_reference_set(
142
134
  struct SelvaDb *db,
@@ -274,16 +266,16 @@ int selva_fields_get_text(
274
266
  size_t *len);
275
267
 
276
268
  SELVA_EXPORT
277
- struct SelvaNodeReference *selva_fields_get_reference(struct SelvaNode *node, field_t field);
269
+ struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, field_t field);
278
270
 
279
271
  SELVA_EXPORT
280
- struct SelvaNodeReferences *selva_fields_get_references(struct SelvaNode *node, field_t field);
272
+ struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, struct SelvaNode *node, field_t field);
281
273
 
282
274
  SELVA_EXPORT
283
- struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaFields *fields, field_t field);
275
+ struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
284
276
 
285
277
  SELVA_EXPORT
286
- struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaFields *fields, field_t field);
278
+ struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
287
279
 
288
280
  SELVA_EXPORT
289
281
  struct SelvaNode *selva_fields_resolve_weak_reference(
@@ -333,9 +325,6 @@ void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaField
333
325
  SELVA_EXPORT
334
326
  void selva_fields_destroy(struct SelvaDb *db, struct SelvaNode *node);
335
327
 
336
- SELVA_EXPORT
337
- int selva_fields_get_text_crc(const struct SelvaNode *node, const struct SelvaFieldSchema *fs, enum selva_lang_code lang, uint32_t *crc);
338
-
339
328
  SELVA_EXPORT
340
329
  void selva_fields_hash_update(struct XXH3_state_s *hash_state, struct SelvaDb *db, const struct SelvaFieldsSchema *schema, const struct SelvaFields *fields);
341
330
 
@@ -23,23 +23,13 @@ struct SelvaFieldsSchema;
23
23
 
24
24
  enum SelvaFieldType {
25
25
  SELVA_FIELD_TYPE_NULL = 0,
26
- SELVA_FIELD_TYPE_TIMESTAMP = 1,
27
- #if 0
28
- SELVA_FIELD_TYPE_SPARE1 = 2,
29
- SELVA_FIELD_TYPE_SPARE2 = 3,
30
- #endif
31
26
  SELVA_FIELD_TYPE_NUMBER = 4,
32
- #if 0
33
- SELVA_FIELD_TYPE_SPARE3 = 5,
34
- #endif
35
27
  SELVA_FIELD_TYPE_INT8 = 20,
36
28
  SELVA_FIELD_TYPE_UINT8 = 6,
37
29
  SELVA_FIELD_TYPE_INT16 = 21,
38
30
  SELVA_FIELD_TYPE_UINT16 = 22,
39
31
  SELVA_FIELD_TYPE_INT32 = 23,
40
32
  SELVA_FIELD_TYPE_UINT32 = 7,
41
- SELVA_FIELD_TYPE_INT64 = 24,
42
- SELVA_FIELD_TYPE_UINT64 = 8,
43
33
  SELVA_FIELD_TYPE_BOOLEAN = 9,
44
34
  SELVA_FIELD_TYPE_ENUM = 10,
45
35
  SELVA_FIELD_TYPE_STRING = 11,
@@ -75,28 +75,92 @@ struct SelvaTypeEntry *selva_get_type_by_node(const struct SelvaDb *db, struct S
75
75
  * Get the node schema for type.
76
76
  */
77
77
  SELVA_EXPORT
78
- const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te) __attribute__((nonnull, pure));
78
+ __attribute__((nonnull, pure))
79
+ inline const struct SelvaNodeSchema *selva_get_ns_by_te(const struct SelvaTypeEntry *te)
80
+ #if !__zig
81
+ {
82
+ return &te->ns;
83
+ }
84
+ #else
85
+ ;
86
+ #endif
79
87
 
80
88
  SELVA_EXPORT
81
- const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field) __attribute__((nonnull, pure));
89
+ __attribute__((nonnull, pure))
90
+ inline const struct SelvaFieldSchema *get_fs_by_fields_schema_field(const struct SelvaFieldsSchema *fields_schema, field_t field)
91
+ #if !__zig
92
+ {
93
+ if (field >= fields_schema->nr_fields) {
94
+ return nullptr;
95
+ }
96
+
97
+ return &fields_schema->field_schemas[field];
98
+ }
99
+ #else
100
+ ;
101
+ #endif
82
102
 
83
103
  /**
84
104
  * Get the field schema for field.
85
105
  */
86
106
  SELVA_EXPORT
87
- const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field) __attribute__((nonnull, pure));
107
+ __attribute__((nonnull, pure))
108
+ inline const struct SelvaFieldSchema *selva_get_fs_by_te_field(const struct SelvaTypeEntry *te, field_t field)
109
+ #if !__zig
110
+ {
111
+ return get_fs_by_fields_schema_field(&te->ns.fields_schema, field);
112
+ }
113
+ #else
114
+ ;
115
+ #endif
88
116
 
89
117
  /**
90
118
  * Get the field schema for field.
91
119
  */
92
120
  SELVA_EXPORT
93
- const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field) __attribute__((nonnull, pure));
121
+ __attribute__((nonnull, pure))
122
+ inline const struct SelvaFieldSchema *selva_get_fs_by_ns_field(const struct SelvaNodeSchema *ns, field_t field)
123
+ #if !__zig
124
+ {
125
+ return get_fs_by_fields_schema_field(&ns->fields_schema, field);
126
+ }
127
+ #else
128
+ ;
129
+ #endif
130
+
131
+ /**
132
+ * Get the field schema for field.
133
+ */
134
+ SELVA_EXPORT
135
+ __attribute__((nonnull, pure))
136
+ inline const struct SelvaFieldSchema *selva_get_fs_by_node(struct SelvaDb *db, struct SelvaNode *node, field_t field)
137
+ #if !__zig
138
+ {
139
+ struct SelvaTypeEntry *type;
140
+
141
+ type = selva_get_type_by_node(db, node);
142
+ if (!type) {
143
+ return nullptr;
144
+ }
145
+
146
+ return selva_get_fs_by_ns_field(&type->ns, field);
147
+ }
148
+ #else
149
+ ;
150
+ #endif
94
151
 
95
152
  SELVA_EXPORT
96
153
  #if __has_c_attribute(reproducible)
97
154
  [[reproducible]]
98
155
  #endif
99
- enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs);
156
+ inline enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs)
157
+ #if !__zig
158
+ {
159
+ return fs->type;
160
+ }
161
+ #else
162
+ ;
163
+ #endif
100
164
 
101
165
  /**
102
166
  * Get the EdgeFieldConstraint from a ref field schema.
@@ -105,7 +169,17 @@ enum SelvaFieldType selva_get_fs_type(const struct SelvaFieldSchema *fs);
105
169
  * struct SelvaFieldSchema *dst_fs = selva_get_fs_by_node(db, dst, efc->inverse_field);
106
170
  */
107
171
  SELVA_EXPORT
108
- const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs) __attribute__((nonnull));
172
+ __attribute__((nonnull))
173
+ inline const struct EdgeFieldConstraint *selva_get_edge_field_constraint(const struct SelvaFieldSchema *fs)
174
+ #if !__zig
175
+ {
176
+ return (fs->type == SELVA_FIELD_TYPE_REFERENCE || fs->type == SELVA_FIELD_TYPE_REFERENCES)
177
+ ? &fs->edge_constraint
178
+ : nullptr;
179
+ }
180
+ #else
181
+ ;
182
+ #endif
109
183
 
110
184
  SELVA_EXPORT
111
185
  const struct SelvaFieldsSchema *selva_get_edge_field_fields_schema(struct SelvaDb *db, const struct EdgeFieldConstraint *efc);
@@ -173,6 +247,11 @@ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode
173
247
  SELVA_EXPORT
174
248
  struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
175
249
 
250
+ /**
251
+ * \addtogroup db_cursor
252
+ * @{
253
+ */
254
+
176
255
  /**
177
256
  * Create a new cursor pointing to node.
178
257
  * If the node is deleted later then the cursor is updated to point to the next
@@ -205,6 +284,10 @@ void selva_cursor_del(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__
205
284
  SELVA_EXPORT
206
285
  size_t selva_cursor_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
207
286
 
287
+ /**
288
+ * @}
289
+ */
290
+
208
291
  /**
209
292
  * Total count of nodes of type.
210
293
  */
@@ -58,37 +58,21 @@ struct SelvaNodeWeakReferences {
58
58
  struct SelvaNodeWeakReference *refs __pcounted_by(nr_refs);
59
59
  };
60
60
 
61
- struct SelvaMicroBuffer {
62
- uint16_t len;
63
- uint8_t data[] __counted_by(len);
64
- } __packed;
65
-
66
- struct SelvaFieldsAny {
67
- enum SelvaFieldType type; /*!< Type of the value. */
68
- union {
69
- bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
70
- double number; /*!< SELVA_FIELD_TYPE_NUMBER */
71
- int64_t timestamp; /*!< SELVA_FIELD_TYPE_TIMESTAMP, should fit time_t */
72
- struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
73
- int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
74
- uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
75
- int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
76
- uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
77
- int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
78
- uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
79
- int64_t int64; /* SELVA_FIELD_TYPE_INT64 */
80
- uint64_t uint64; /*!< SELVA_FIELD_TYPE_UINT64 */
81
- uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
82
- #if 0
83
- struct SelvaTextField *text; /*!< SELVA_FIELD_TYPE_TEXT */
84
- struct SelvaNodeReference *reference; /*!< SELVA_FIELD_TYPE_REFERENCE */
85
- struct SelvaNodeReferences *references; /*!< SELVA_FIELD_TYPE_REFERENCES */
86
- struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
87
- struct SelvaNodeWeakReferences weak_references; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCES */
88
- struct SelvaMicroBuffer *smb; /*!< SELVA_FIELD_TYPE_MICRO_BUFFER */
89
- #endif
90
- // HyperLogLogPlusPlus cardinality; /*!< SELVA_FIELD_TYPE_HLL */
91
- };
61
+ /**
62
+ * Type helper to determine the size of statically (constant/fixed) sized fields.
63
+ */
64
+ union SelvaStaticFields {
65
+ bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
66
+ double number; /*!< SELVA_FIELD_TYPE_NUMBER */
67
+ struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
68
+ int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
69
+ uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
70
+ int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
71
+ uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
72
+ int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
73
+ uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
74
+ uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
75
+ struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
92
76
  };
93
77
 
94
78
  struct SelvaFieldsPointer {
@@ -128,7 +112,6 @@ int selva_fields_get_mutable_string(
128
112
  __attribute__((access(write_only, 4)));
129
113
 
130
114
  /*
131
- * TODO prefix with selva_
132
115
  * TODO Document diff to get_mutable_string
133
116
  */
134
117
  SELVA_EXPORT
@@ -137,6 +120,15 @@ struct selva_string *selva_fields_ensure_string(
137
120
  const struct SelvaFieldSchema *fs,
138
121
  size_t initial_len);
139
122
 
123
+ SELVA_EXPORT
124
+ struct selva_string *selva_fields_ensure_string2(
125
+ struct SelvaDb *db,
126
+ struct SelvaNode *node,
127
+ const struct EdgeFieldConstraint *efc,
128
+ struct SelvaNodeReference *ref,
129
+ const struct SelvaFieldSchema *fs,
130
+ size_t initial_len);
131
+
140
132
  SELVA_EXPORT
141
133
  int selva_fields_reference_set(
142
134
  struct SelvaDb *db,
@@ -274,16 +266,16 @@ int selva_fields_get_text(
274
266
  size_t *len);
275
267
 
276
268
  SELVA_EXPORT
277
- struct SelvaNodeReference *selva_fields_get_reference(struct SelvaNode *node, field_t field);
269
+ struct SelvaNodeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, field_t field);
278
270
 
279
271
  SELVA_EXPORT
280
- struct SelvaNodeReferences *selva_fields_get_references(struct SelvaNode *node, field_t field);
272
+ struct SelvaNodeReferences *selva_fields_get_references(struct SelvaDb *db, struct SelvaNode *node, field_t field);
281
273
 
282
274
  SELVA_EXPORT
283
- struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaFields *fields, field_t field);
275
+ struct SelvaNodeWeakReference selva_fields_get_weak_reference(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
284
276
 
285
277
  SELVA_EXPORT
286
- struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaFields *fields, field_t field);
278
+ struct SelvaNodeWeakReferences selva_fields_get_weak_references(struct SelvaDb *db, struct SelvaFields *fields, field_t field);
287
279
 
288
280
  SELVA_EXPORT
289
281
  struct SelvaNode *selva_fields_resolve_weak_reference(
@@ -333,9 +325,6 @@ void selva_fields_init(const struct SelvaFieldsSchema *schema, struct SelvaField
333
325
  SELVA_EXPORT
334
326
  void selva_fields_destroy(struct SelvaDb *db, struct SelvaNode *node);
335
327
 
336
- SELVA_EXPORT
337
- int selva_fields_get_text_crc(const struct SelvaNode *node, const struct SelvaFieldSchema *fs, enum selva_lang_code lang, uint32_t *crc);
338
-
339
328
  SELVA_EXPORT
340
329
  void selva_fields_hash_update(struct XXH3_state_s *hash_state, struct SelvaDb *db, const struct SelvaFieldsSchema *schema, const struct SelvaFields *fields);
341
330
 
@@ -23,23 +23,13 @@ struct SelvaFieldsSchema;
23
23
 
24
24
  enum SelvaFieldType {
25
25
  SELVA_FIELD_TYPE_NULL = 0,
26
- SELVA_FIELD_TYPE_TIMESTAMP = 1,
27
- #if 0
28
- SELVA_FIELD_TYPE_SPARE1 = 2,
29
- SELVA_FIELD_TYPE_SPARE2 = 3,
30
- #endif
31
26
  SELVA_FIELD_TYPE_NUMBER = 4,
32
- #if 0
33
- SELVA_FIELD_TYPE_SPARE3 = 5,
34
- #endif
35
27
  SELVA_FIELD_TYPE_INT8 = 20,
36
28
  SELVA_FIELD_TYPE_UINT8 = 6,
37
29
  SELVA_FIELD_TYPE_INT16 = 21,
38
30
  SELVA_FIELD_TYPE_UINT16 = 22,
39
31
  SELVA_FIELD_TYPE_INT32 = 23,
40
32
  SELVA_FIELD_TYPE_UINT32 = 7,
41
- SELVA_FIELD_TYPE_INT64 = 24,
42
- SELVA_FIELD_TYPE_UINT64 = 8,
43
33
  SELVA_FIELD_TYPE_BOOLEAN = 9,
44
34
  SELVA_FIELD_TYPE_ENUM = 10,
45
35
  SELVA_FIELD_TYPE_STRING = 11,
Binary file