@based/db 0.0.70 → 0.1.0
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/LICENSE +201 -0
- package/README.md +105 -77
- package/dist/lib/darwin_aarch64/include/libdeflate.h +23 -0
- package/dist/lib/darwin_aarch64/include/selva/db.h +0 -41
- package/dist/lib/darwin_aarch64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/darwin_aarch64/include/selva/fields.h +52 -37
- package/dist/lib/darwin_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/darwin_aarch64/include/selva/hll.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/darwin_aarch64/include/selva/selva_string.h +8 -5
- package/dist/lib/darwin_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +18 -4
- 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-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/libselva.dylib +0 -0
- package/dist/lib/darwin_aarch64/libxxhash.dylib +0 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +23 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +0 -41
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/linux_aarch64/include/selva/fields.h +52 -37
- package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +1 -1
- package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +8 -5
- package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +18 -4
- package/dist/lib/linux_aarch64/libdeflate.so +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/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +23 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +0 -41
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +6 -2
- package/dist/lib/linux_x86_64/include/selva/fields.h +52 -37
- package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +1 -1
- package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +8 -5
- package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +18 -4
- package/dist/lib/linux_x86_64/libdeflate.so +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/libselva.so +0 -0
- package/dist/src/client/index.d.ts +16 -21
- package/dist/src/client/index.js +48 -59
- package/dist/src/client/modify/Ctx.d.ts +38 -0
- package/dist/src/client/modify/Ctx.js +30 -0
- package/dist/src/client/modify/Tmp.d.ts +19 -0
- package/dist/src/client/modify/Tmp.js +67 -0
- package/dist/src/client/modify/create/index.d.ts +6 -0
- package/dist/src/client/modify/create/index.js +191 -0
- package/dist/src/client/modify/create/mark.d.ts +7 -0
- package/dist/src/client/modify/create/mark.js +42 -0
- package/dist/src/client/modify/cursor.d.ts +10 -0
- package/dist/src/client/modify/cursor.js +48 -0
- package/dist/src/client/modify/delete/index.d.ts +2 -0
- package/dist/src/client/modify/delete/index.js +39 -0
- package/dist/src/client/modify/drain.d.ts +7 -0
- package/dist/src/client/modify/drain.js +77 -0
- package/dist/src/client/modify/edges/binary.d.ts +3 -0
- package/dist/src/client/modify/edges/binary.js +28 -0
- package/dist/src/client/modify/edges/cardinality.d.ts +3 -0
- package/dist/src/client/modify/edges/cardinality.js +15 -0
- package/dist/src/client/modify/edges/header.d.ts +5 -0
- package/dist/src/client/modify/edges/header.js +21 -0
- package/dist/src/client/modify/edges/index.d.ts +3 -0
- package/dist/src/client/modify/edges/index.js +128 -0
- package/dist/src/client/modify/edges/reference.d.ts +3 -0
- package/dist/src/client/modify/edges/reference.js +31 -0
- package/dist/src/client/modify/edges/references.d.ts +3 -0
- package/dist/src/client/modify/edges/references.js +38 -0
- package/dist/src/client/modify/edges/separate.d.ts +3 -0
- package/dist/src/client/modify/edges/separate.js +24 -0
- package/dist/src/client/modify/edges/string.d.ts +3 -0
- package/dist/src/client/modify/edges/string.js +30 -0
- package/dist/src/client/modify/error.d.ts +7 -0
- package/dist/src/client/modify/error.js +68 -0
- package/dist/src/client/modify/expire/index.d.ts +2 -0
- package/dist/src/client/modify/expire/index.js +31 -0
- package/dist/src/client/modify/props/alias.d.ts +3 -0
- package/dist/src/client/modify/props/alias.js +26 -0
- package/dist/src/client/modify/props/binary.d.ts +5 -0
- package/dist/src/client/modify/props/binary.js +52 -0
- package/dist/src/client/modify/props/cardinality.d.ts +4 -0
- package/dist/src/client/modify/props/cardinality.js +46 -0
- package/dist/src/client/modify/props/delete.d.ts +3 -0
- package/dist/src/client/modify/props/delete.js +13 -0
- package/dist/src/client/modify/props/fixed.d.ts +4 -0
- package/dist/src/client/modify/props/fixed.js +105 -0
- package/dist/src/client/modify/props/increment.d.ts +3 -0
- package/dist/src/client/modify/props/increment.js +28 -0
- package/dist/src/client/modify/props/json.d.ts +3 -0
- package/dist/src/client/modify/props/json.js +5 -0
- package/dist/src/client/modify/props/main.d.ts +4 -0
- package/dist/src/client/modify/props/main.js +22 -0
- package/dist/src/client/modify/props/object.d.ts +3 -0
- package/dist/src/client/modify/props/object.js +37 -0
- package/dist/src/client/modify/props/reference.d.ts +6 -0
- package/dist/src/client/modify/props/reference.js +92 -0
- package/dist/src/client/modify/props/references.d.ts +3 -0
- package/dist/src/client/modify/props/references.js +231 -0
- package/dist/src/client/modify/props/separate.d.ts +3 -0
- package/dist/src/client/modify/props/separate.js +43 -0
- package/dist/src/client/modify/props/string.d.ts +5 -0
- package/dist/src/client/modify/props/string.js +51 -0
- package/dist/src/client/modify/props/text.d.ts +3 -0
- package/dist/src/client/modify/props/text.js +35 -0
- package/dist/src/client/modify/props/vector.d.ts +3 -0
- package/dist/src/client/modify/props/vector.js +30 -0
- package/dist/src/client/modify/resize.d.ts +3 -0
- package/dist/src/client/modify/resize.js +20 -0
- package/dist/src/client/modify/types.d.ts +3 -4
- package/dist/src/client/modify/types.js +2 -1
- package/dist/src/client/modify/uint.d.ts +7 -0
- package/dist/src/client/modify/uint.js +27 -0
- package/dist/src/client/modify/update/index.d.ts +3 -0
- package/dist/src/client/modify/update/index.js +75 -0
- package/dist/src/client/modify/upsert/index.d.ts +3 -0
- package/dist/src/client/modify/{upsert.js → upsert/index.js} +4 -4
- package/dist/src/client/modify/validate.d.ts +6 -0
- package/dist/src/client/modify/validate.js +24 -0
- package/dist/src/client/query/BasedDbQuery.d.ts +18 -15
- package/dist/src/client/query/BasedDbQuery.js +93 -96
- package/dist/src/client/query/{BasedIterable.d.ts → BasedQueryResponse.d.ts} +5 -4
- package/dist/src/client/query/{BasedIterable.js → BasedQueryResponse.js} +15 -10
- package/dist/src/client/query/aggregates/aggregation.d.ts +5 -3
- package/dist/src/client/query/aggregates/aggregation.js +105 -48
- package/dist/src/client/query/aggregates/types.d.ts +34 -12
- package/dist/src/client/query/aggregates/types.js +30 -12
- package/dist/src/client/query/debug.js +1 -1
- package/dist/src/client/query/display.d.ts +1 -1
- package/dist/src/client/query/display.js +21 -4
- package/dist/src/client/query/filter/FilterBranch.js +2 -2
- package/dist/src/client/query/filter/convertFilter.d.ts +3 -2
- package/dist/src/client/query/filter/convertFilter.js +13 -1
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +16 -30
- package/dist/src/client/query/filter/createReferenceFilter.js +6 -20
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +15 -32
- package/dist/src/client/query/filter/parseFilterValue.js +3 -11
- package/dist/src/client/query/filter/primitiveFilter.js +1 -1
- package/dist/src/client/query/filter/toBuffer.js +9 -15
- package/dist/src/client/query/filter/types.d.ts +6 -6
- package/dist/src/client/query/filter/types.js +8 -8
- package/dist/src/client/query/include/include.d.ts +3 -0
- package/dist/src/client/query/include/include.js +58 -0
- package/dist/src/client/query/include/props.d.ts +7 -7
- package/dist/src/client/query/include/props.js +26 -21
- package/dist/src/client/query/include/toByteCode.js +188 -0
- package/dist/src/client/query/include/utils.d.ts +3 -1
- package/dist/src/client/query/include/utils.js +13 -0
- package/dist/src/client/query/include/walk.d.ts +2 -2
- package/dist/src/client/query/include/walk.js +38 -23
- package/dist/src/client/query/query.d.ts +2 -3
- package/dist/src/client/query/query.js +2 -3
- package/dist/src/client/query/queryDef.d.ts +4 -2
- package/dist/src/client/query/queryDef.js +3 -5
- package/dist/src/client/query/queryDefToReadSchema.d.ts +3 -0
- package/dist/src/client/query/queryDefToReadSchema.js +126 -0
- package/dist/src/client/query/registerQuery.js +15 -4
- package/dist/src/client/query/search/index.d.ts +2 -1
- package/dist/src/client/query/search/index.js +9 -2
- package/dist/src/client/query/sort.js +3 -0
- package/dist/src/client/query/subscription/index.d.ts +1 -1
- package/dist/src/client/query/subscription/index.js +2 -2
- package/dist/src/client/query/subscription/types.d.ts +1 -1
- package/dist/src/client/query/thresholds.d.ts +1 -1
- package/dist/src/client/query/thresholds.js +1 -1
- package/dist/src/client/query/toByteCode/{toBuffer.js → toByteCode.js} +8 -8
- package/dist/src/client/query/types.d.ts +40 -25
- package/dist/src/client/query/types.js +2 -6
- package/dist/src/client/query/validation.d.ts +6 -0
- package/dist/src/client/query/validation.js +32 -8
- package/dist/src/client/setLocalClientSchema.js +6 -10
- package/dist/src/client/string.d.ts +3 -7
- package/dist/src/client/string.js +18 -47
- package/dist/src/hooks.d.ts +2 -3
- package/dist/src/hooks.js +14 -9
- package/dist/src/index.d.ts +3 -5
- package/dist/src/index.js +4 -6
- package/dist/src/native.d.ts +3 -2
- package/dist/src/native.js +9 -8
- package/dist/src/server/IoWorker.js +2 -3
- package/dist/src/server/QueryWorker.js +1 -1
- package/dist/src/server/blocks.js +5 -4
- package/dist/src/server/dbHash.js +1 -1
- package/dist/src/server/index.d.ts +4 -6
- package/dist/src/server/index.js +63 -96
- package/dist/src/server/migrate/index.d.ts +2 -4
- package/dist/src/server/migrate/index.js +31 -16
- package/dist/src/server/migrate/worker.js +2 -27
- package/dist/src/server/save.js +10 -8
- package/dist/src/server/schema.js +17 -25
- package/dist/src/server/start.d.ts +1 -0
- package/dist/src/server/start.js +18 -10
- package/dist/src/server/tree.d.ts +20 -0
- package/dist/src/server/tree.js +17 -2
- package/dist/src/server/workers/DbWorker.d.ts +1 -0
- package/dist/src/server/workers/DbWorker.js +8 -1
- package/dist/src/server/workers/io_worker.js +1 -1
- package/dist/src/server/workers/worker.js +9 -4
- package/dist/src/table.d.ts +4 -0
- package/dist/src/table.js +97 -0
- package/dist/src/types.d.ts +1 -1
- package/package.json +18 -17
- package/dist/lib/darwin_aarch64/include/selva/worker_ctx.h +0 -29
- package/dist/lib/linux_aarch64/include/selva/worker_ctx.h +0 -29
- package/dist/lib/linux_x86_64/include/selva/worker_ctx.h +0 -29
- package/dist/src/client/flushModify.d.ts +0 -36
- package/dist/src/client/flushModify.js +0 -197
- package/dist/src/client/modify/ModifyRes.d.ts +0 -23
- package/dist/src/client/modify/ModifyRes.js +0 -101
- package/dist/src/client/modify/alias.d.ts +0 -4
- package/dist/src/client/modify/alias.js +0 -57
- package/dist/src/client/modify/binary.d.ts +0 -6
- package/dist/src/client/modify/binary.js +0 -80
- package/dist/src/client/modify/cardinality.d.ts +0 -6
- package/dist/src/client/modify/cardinality.js +0 -63
- package/dist/src/client/modify/create.d.ts +0 -5
- package/dist/src/client/modify/create.js +0 -228
- package/dist/src/client/modify/delete.d.ts +0 -4
- package/dist/src/client/modify/delete.js +0 -47
- package/dist/src/client/modify/expire.d.ts +0 -3
- package/dist/src/client/modify/expire.js +0 -25
- package/dist/src/client/modify/fixed.d.ts +0 -5
- package/dist/src/client/modify/fixed.js +0 -235
- package/dist/src/client/modify/index.d.ts +0 -4
- package/dist/src/client/modify/index.js +0 -4
- package/dist/src/client/modify/json.d.ts +0 -4
- package/dist/src/client/modify/json.js +0 -26
- package/dist/src/client/modify/modify.d.ts +0 -5
- package/dist/src/client/modify/modify.js +0 -134
- package/dist/src/client/modify/references/appendEdgeRefs.d.ts +0 -4
- package/dist/src/client/modify/references/appendEdgeRefs.js +0 -33
- package/dist/src/client/modify/references/edge.d.ts +0 -5
- package/dist/src/client/modify/references/edge.js +0 -322
- package/dist/src/client/modify/references/getEdgeSize.d.ts +0 -3
- package/dist/src/client/modify/references/getEdgeSize.js +0 -27
- package/dist/src/client/modify/references/reference.d.ts +0 -11
- package/dist/src/client/modify/references/reference.js +0 -112
- package/dist/src/client/modify/references/references.d.ts +0 -16
- package/dist/src/client/modify/references/references.js +0 -308
- package/dist/src/client/modify/setCursor.d.ts +0 -5
- package/dist/src/client/modify/setCursor.js +0 -33
- package/dist/src/client/modify/string.d.ts +0 -5
- package/dist/src/client/modify/string.js +0 -71
- package/dist/src/client/modify/text.d.ts +0 -8
- package/dist/src/client/modify/text.js +0 -69
- package/dist/src/client/modify/update.d.ts +0 -6
- package/dist/src/client/modify/update.js +0 -90
- package/dist/src/client/modify/upsert.d.ts +0 -3
- package/dist/src/client/modify/vector.d.ts +0 -4
- package/dist/src/client/modify/vector.js +0 -53
- package/dist/src/client/query/include/toBuffer.js +0 -123
- package/dist/src/client/query/read/read.d.ts +0 -9
- package/dist/src/client/query/read/read.js +0 -483
- /package/dist/src/client/query/include/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
- /package/dist/src/client/query/toByteCode/{toBuffer.d.ts → toByteCode.d.ts} +0 -0
|
@@ -15,15 +15,6 @@ struct selva_string;
|
|
|
15
15
|
#include "selva/types.h"
|
|
16
16
|
#include "selva_lang_code.h"
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Reserved (N/A) field id.
|
|
20
|
-
* Can be used to mark that a field doesn't exist.
|
|
21
|
-
* E.g. if created and updated fields don't exist their ids can be set to this
|
|
22
|
-
* value.
|
|
23
|
-
* Technically fields 251..255 are all reserved.
|
|
24
|
-
*/
|
|
25
|
-
#define SELVA_FIELDS_RESERVED 255
|
|
26
|
-
|
|
27
18
|
struct XXH3_state_s; /* RFE Not good? */
|
|
28
19
|
|
|
29
20
|
#ifndef __zig
|
|
@@ -33,17 +24,51 @@ struct SelvaTextField {
|
|
|
33
24
|
} __packed;
|
|
34
25
|
#endif
|
|
35
26
|
|
|
36
|
-
struct
|
|
27
|
+
struct SelvaNodeSmallReference {
|
|
28
|
+
struct SelvaNode *dst;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
struct SelvaNodeLargeReference {
|
|
37
32
|
struct SelvaNode *dst;
|
|
38
33
|
struct SelvaFields *meta;
|
|
39
34
|
};
|
|
40
35
|
|
|
36
|
+
enum SelvaNodeReferenceType {
|
|
37
|
+
SELVA_NODE_REFERENCE_NULL = 0,
|
|
38
|
+
SELVA_NODE_REFERENCE_SMALL = 1,
|
|
39
|
+
SELVA_NODE_REFERENCE_LARGE = 2,
|
|
40
|
+
} __packed;
|
|
41
|
+
|
|
42
|
+
struct SelvaNodeReferenceAny {
|
|
43
|
+
enum SelvaNodeReferenceType type;
|
|
44
|
+
union {
|
|
45
|
+
void *any;
|
|
46
|
+
struct SelvaNodeSmallReference *small;
|
|
47
|
+
struct SelvaNodeLargeReference *large;
|
|
48
|
+
}
|
|
49
|
+
#ifdef __zig
|
|
50
|
+
p
|
|
51
|
+
#endif
|
|
52
|
+
;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
static_assert(offsetof(struct SelvaNodeLargeReference, dst) == offsetof(struct SelvaNodeSmallReference, dst));
|
|
56
|
+
|
|
41
57
|
struct SelvaNodeReferences {
|
|
42
58
|
uint32_t nr_refs;
|
|
43
59
|
uint16_t offset;
|
|
44
|
-
|
|
60
|
+
enum SelvaNodeReferenceType size;
|
|
61
|
+
|
|
62
|
+
union {
|
|
63
|
+
void *any;
|
|
64
|
+
struct SelvaNodeLargeReference *large __pcounted_by(nr_refs);
|
|
65
|
+
struct SelvaNodeSmallReference *small __pcounted_by(nr_refs);
|
|
66
|
+
};
|
|
45
67
|
node_id_t *index __pcounted_by(nr_refs); /*!< Sorted index of all nodes in `.refs`. */
|
|
46
68
|
};
|
|
69
|
+
static_assert(offsetof(struct SelvaNodeReferences, any) == offsetof(struct SelvaNodeReferences, small));
|
|
70
|
+
static_assert(offsetof(struct SelvaNodeReferences, any) == offsetof(struct SelvaNodeReferences, large));
|
|
71
|
+
static_assert(offsetof(struct SelvaNodeReferences, small) == offsetof(struct SelvaNodeReferences, large));
|
|
47
72
|
|
|
48
73
|
struct SelvaNodeWeakReference {
|
|
49
74
|
/* The type can be found from the schema. */
|
|
@@ -59,23 +84,6 @@ struct SelvaNodeWeakReferences {
|
|
|
59
84
|
struct SelvaNodeWeakReference *refs __pcounted_by(nr_refs);
|
|
60
85
|
};
|
|
61
86
|
|
|
62
|
-
/**
|
|
63
|
-
* Type helper to determine the size of statically (constant/fixed) sized fields.
|
|
64
|
-
*/
|
|
65
|
-
union SelvaStaticFields {
|
|
66
|
-
bool boolean; /*!< SELVA_FIELD_TYPE_BOOLEAN */
|
|
67
|
-
double number; /*!< SELVA_FIELD_TYPE_NUMBER */
|
|
68
|
-
struct selva_string *string; /*!< SELVA_FIELD_TYPE_STRING */
|
|
69
|
-
int8_t int8; /* SELVA_FIELD_TYPE_INT8 */
|
|
70
|
-
uint8_t uint8; /*!< SELVA_FIELD_TYPE_UINT8 */
|
|
71
|
-
int16_t int16; /*!< SELVA_FIELD_TYPE_INT16 */
|
|
72
|
-
uint16_t uint16; /*!< SELVA_FIELD_TYPE_UINT16 */
|
|
73
|
-
int32_t int32; /*!< SELVA_FIELD_TYPE_INT32 */
|
|
74
|
-
uint32_t uint32; /*!< SELVA_FIELD_TYPE_UINT32 */
|
|
75
|
-
uint8_t enu; /*!< SELVA_FIELD_TYPE_ENUM */
|
|
76
|
-
struct SelvaNodeWeakReference weak_reference; /*!< SELVA_FIELD_TYPE_WEAK_REFERENCE */
|
|
77
|
-
};
|
|
78
|
-
|
|
79
87
|
struct SelvaFieldsPointer {
|
|
80
88
|
uint8_t *ptr;
|
|
81
89
|
size_t off;
|
|
@@ -111,7 +119,7 @@ struct SelvaFields *selva_fields_node2fields(struct SelvaNode *node);
|
|
|
111
119
|
void selva_fields_ensure_ref_meta(
|
|
112
120
|
struct SelvaDb *db,
|
|
113
121
|
struct SelvaNode *node,
|
|
114
|
-
struct
|
|
122
|
+
struct SelvaNodeLargeReference *ref,
|
|
115
123
|
const struct EdgeFieldConstraint *efc)
|
|
116
124
|
__attribute__((nonnull));
|
|
117
125
|
|
|
@@ -140,7 +148,7 @@ struct selva_string *selva_fields_ensure_string2(
|
|
|
140
148
|
struct SelvaDb *db,
|
|
141
149
|
struct SelvaNode *node,
|
|
142
150
|
const struct EdgeFieldConstraint *efc,
|
|
143
|
-
struct
|
|
151
|
+
struct SelvaNodeLargeReference *ref,
|
|
144
152
|
const struct SelvaFieldSchema *fs,
|
|
145
153
|
size_t initial_len);
|
|
146
154
|
|
|
@@ -153,7 +161,7 @@ int selva_fields_reference_set(
|
|
|
153
161
|
struct SelvaNode * restrict src,
|
|
154
162
|
const struct SelvaFieldSchema *fs_src,
|
|
155
163
|
struct SelvaNode * restrict dst,
|
|
156
|
-
struct
|
|
164
|
+
struct SelvaNodeReferenceAny *ref_out,
|
|
157
165
|
selva_dirty_node_cb_t dirty_cb,
|
|
158
166
|
void *dirty_ctx);
|
|
159
167
|
// __attribute__((access(write_only, 5), access(write_only, 6)));
|
|
@@ -171,7 +179,7 @@ int selva_fields_references_insert(
|
|
|
171
179
|
bool reorder,
|
|
172
180
|
struct SelvaTypeEntry *te_dst,
|
|
173
181
|
struct SelvaNode * restrict dst,
|
|
174
|
-
struct
|
|
182
|
+
struct SelvaNodeReferenceAny *ref_out)
|
|
175
183
|
__attribute__((access(write_only, 8)));
|
|
176
184
|
|
|
177
185
|
/**
|
|
@@ -179,7 +187,7 @@ int selva_fields_references_insert(
|
|
|
179
187
|
* @returns nr_refs.
|
|
180
188
|
*/
|
|
181
189
|
SELVA_EXPORT
|
|
182
|
-
size_t selva_fields_prealloc_refs(struct SelvaNode *node, const struct SelvaFieldSchema *fs, size_t nr_refs_min);
|
|
190
|
+
size_t selva_fields_prealloc_refs(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs, size_t nr_refs_min);
|
|
183
191
|
|
|
184
192
|
SELVA_EXPORT
|
|
185
193
|
int selva_fields_references_insert_tail_wupsert(
|
|
@@ -219,7 +227,7 @@ SELVA_EXPORT
|
|
|
219
227
|
int selva_fields_set_reference_meta(
|
|
220
228
|
struct SelvaDb *db,
|
|
221
229
|
struct SelvaNode *node,
|
|
222
|
-
struct
|
|
230
|
+
struct SelvaNodeLargeReference *ref,
|
|
223
231
|
const struct EdgeFieldConstraint *efc,
|
|
224
232
|
const struct SelvaFieldSchema *efs,
|
|
225
233
|
const void *value, size_t len);
|
|
@@ -228,7 +236,7 @@ SELVA_EXPORT
|
|
|
228
236
|
int selva_fields_get_reference_meta_mutable_string(
|
|
229
237
|
struct SelvaDb *db,
|
|
230
238
|
struct SelvaNode *node,
|
|
231
|
-
struct
|
|
239
|
+
struct SelvaNodeLargeReference *ref,
|
|
232
240
|
const struct EdgeFieldConstraint *efc,
|
|
233
241
|
const struct SelvaFieldSchema *efs,
|
|
234
242
|
size_t len,
|
|
@@ -266,6 +274,13 @@ int selva_fields_set_text(
|
|
|
266
274
|
const char *str,
|
|
267
275
|
size_t len);
|
|
268
276
|
|
|
277
|
+
int selva_fields_get_mutable_text(
|
|
278
|
+
struct SelvaNode *node,
|
|
279
|
+
const struct SelvaFieldSchema *fs,
|
|
280
|
+
enum selva_lang_code lang,
|
|
281
|
+
size_t len,
|
|
282
|
+
struct selva_string **out);
|
|
283
|
+
|
|
269
284
|
/**
|
|
270
285
|
* Get text field translation.
|
|
271
286
|
*
|
|
@@ -302,7 +317,7 @@ SELVA_EXPORT
|
|
|
302
317
|
int selva_fields_set_weak_references(struct SelvaNode *node, const struct SelvaFieldSchema *fs, node_id_t dst[], size_t nr_dsts);
|
|
303
318
|
|
|
304
319
|
SELVA_EXPORT
|
|
305
|
-
struct
|
|
320
|
+
struct SelvaNodeLargeReference *selva_fields_get_reference(struct SelvaDb *db, struct SelvaNode *node, const struct SelvaFieldSchema *fs)
|
|
306
321
|
__attribute__((nonnull));
|
|
307
322
|
|
|
308
323
|
SELVA_EXPORT
|
|
@@ -325,7 +340,7 @@ struct SelvaNode *selva_fields_resolve_weak_reference(
|
|
|
325
340
|
__attribute__((nonnull));
|
|
326
341
|
|
|
327
342
|
SELVA_EXPORT
|
|
328
|
-
struct selva_string *selva_fields_get_selva_string3(struct
|
|
343
|
+
struct selva_string *selva_fields_get_selva_string3(struct SelvaDb *db, struct SelvaNodeLargeReference *ref, const struct SelvaFieldSchema *fs)
|
|
329
344
|
__attribute__((nonnull));
|
|
330
345
|
|
|
331
346
|
SELVA_EXPORT
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*******************************************************************************
|
|
3
|
+
* @file gmtime.h
|
|
4
|
+
* @author Olli Vanhoja
|
|
5
|
+
* @brief Calendar calculations.
|
|
6
|
+
* @section LICENSE
|
|
7
|
+
* Copyright (c) 2025 Saulx
|
|
8
|
+
* SPDX-License-Identifier: MIT
|
|
9
|
+
*******************************************************************************
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
#pragma once
|
|
13
|
+
#include <stdint.h>
|
|
14
|
+
#include "selva/_export.h"
|
|
15
|
+
|
|
16
|
+
#define SELVA_TM_SUNDAY 0
|
|
17
|
+
#define SELVA_TM_MONDAY 1
|
|
18
|
+
#define SELVA_TM_TUESDAY 2
|
|
19
|
+
#define SELVA_TM_WEDNESDAY 3
|
|
20
|
+
#define SELVA_TM_THURSDAY 4
|
|
21
|
+
#define SELVA_TM_FRIDAY 5
|
|
22
|
+
#define SELVA_TM_SATURDAY 6
|
|
23
|
+
|
|
24
|
+
#define SELVA_TM_JANUARY 0
|
|
25
|
+
#define SELVA_TM_FEBRUARY 1
|
|
26
|
+
#define SELVA_TM_MARCH 2
|
|
27
|
+
#define SELVA_TM_APRIL 3
|
|
28
|
+
#define SELVA_TM_MAY 4
|
|
29
|
+
#define SELVA_TM_JUNE 5
|
|
30
|
+
#define SELVA_TM_JULY 6
|
|
31
|
+
#define SELVA_TM_AUGUST 7
|
|
32
|
+
#define SELVA_TM_SEPTEMBER 8
|
|
33
|
+
#define SELVA_TM_OCTOBER 9
|
|
34
|
+
#define SELVA_TM_NOVEMBER 10
|
|
35
|
+
#define SELVA_TM_DECEMBER 11
|
|
36
|
+
|
|
37
|
+
#define SELVA_EPOCH_YEAR 1970
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Gregorian Calendar.
|
|
41
|
+
*/
|
|
42
|
+
struct selva_tm {
|
|
43
|
+
int32_t tm_sec; /*!< Seconds [0,60]. */
|
|
44
|
+
int32_t tm_min; /*!< Minutes [0,59]. */
|
|
45
|
+
int32_t tm_hour; /*!< Hour [0,23]. */
|
|
46
|
+
int32_t tm_mday; /*!< Day of month [1,31]. */
|
|
47
|
+
int32_t tm_mon; /*!< Month of year [0,11]. */
|
|
48
|
+
int32_t tm_year; /*!< Year. */
|
|
49
|
+
int32_t tm_wday; /*!< Day of week [0,6] (Sunday =0). */
|
|
50
|
+
int32_t tm_yday; /*!< Day of year [0,365]. */
|
|
51
|
+
bool tm_yleap; /*!< Is leap year. */
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* ISO-8601 Week Date.
|
|
56
|
+
*/
|
|
57
|
+
struct selva_iso_week {
|
|
58
|
+
int32_t iso_year; /*!< ISO year. */
|
|
59
|
+
int32_t iso_week; /*!< ISO week [1,54]. */
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
static inline int32_t selva_gmtime_wday2iso_wday(int32_t wday)
|
|
63
|
+
{
|
|
64
|
+
/* Same as (tm.tm_wday + 6) % 7 + 1 but fewer instructions. */
|
|
65
|
+
return wday ? wday : 7;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Calculate struct selva_tm from ts and tmz in Gregorian calendar.
|
|
70
|
+
* @param ts in ms.
|
|
71
|
+
* @param tmz in minutes.
|
|
72
|
+
*/
|
|
73
|
+
SELVA_EXPORT
|
|
74
|
+
void selva_gmtime(struct selva_tm *result, int64_t ts, int64_t tmz);
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Calculate Gregorian year from ts and tmz.
|
|
78
|
+
* @param ts in ms.
|
|
79
|
+
* @param tmz in minutes.
|
|
80
|
+
* @returns Gregorian year.
|
|
81
|
+
*/
|
|
82
|
+
SELVA_EXPORT
|
|
83
|
+
int32_t selva_gmtime_year(int64_t ts, int64_t tmz);
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Calculate Gregorian month from ts and tmz.
|
|
87
|
+
* @param ts in ms.
|
|
88
|
+
* @param tmz in minutes.
|
|
89
|
+
* @returns Gregorian month of year [0,11].
|
|
90
|
+
*/
|
|
91
|
+
SELVA_EXPORT
|
|
92
|
+
int32_t selva_gmtime_mon(int64_t ts, int64_t tmz);
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Calculate Gregorian day of year from ts and tmz.
|
|
96
|
+
* @param ts in ms.
|
|
97
|
+
* @param tmz in minutes.
|
|
98
|
+
* @returns Gregorian day of year [0,365].
|
|
99
|
+
*/
|
|
100
|
+
SELVA_EXPORT
|
|
101
|
+
int32_t selva_gmtime_yday(int64_t ts, int64_t tmz);
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Calculate Gregorian day of week from ts and tmz.
|
|
105
|
+
* @param ts in ms.
|
|
106
|
+
* @param tmz in minutes.
|
|
107
|
+
* @returns Gregorian day of week [0,6] (Sunday =0).
|
|
108
|
+
*/
|
|
109
|
+
SELVA_EXPORT
|
|
110
|
+
int32_t selva_gmtime_wday(int64_t ts, int64_t tmz);
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Calculate Gregorian day of month from ts and tmz.
|
|
114
|
+
* @param ts in ms.
|
|
115
|
+
* @param tmz in minutes.
|
|
116
|
+
* @returns Gregorian day of month [1,31].
|
|
117
|
+
*/
|
|
118
|
+
SELVA_EXPORT
|
|
119
|
+
int32_t selva_gmtime_mday(int64_t ts, int64_t tmz);
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Calculate hour from ts and tmz.
|
|
123
|
+
* @param ts in ms.
|
|
124
|
+
* @param tmz in minutes.
|
|
125
|
+
* @returns Hour [0, 23].
|
|
126
|
+
*/
|
|
127
|
+
SELVA_EXPORT
|
|
128
|
+
int32_t selva_gmtime_hour(int64_t ts, int64_t tmz);
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Calculate the ISO-8601 week date from ts and tmz.
|
|
132
|
+
* @param ts in ms.
|
|
133
|
+
* @param tmz in minutes.
|
|
134
|
+
* @returns wyear.
|
|
135
|
+
*/
|
|
136
|
+
SELVA_EXPORT
|
|
137
|
+
struct selva_iso_week *selva_gmtime_iso_wyear(struct selva_iso_week *wyear, int64_t ts, int64_t tmz);
|
|
@@ -19,7 +19,7 @@ uint8_t *hll_count(struct selva_string *hllss);
|
|
|
19
19
|
SELVA_EXPORT
|
|
20
20
|
void hll_array_union(struct selva_string *res, struct selva_string *hll_array, size_t count);
|
|
21
21
|
SELVA_EXPORT
|
|
22
|
-
void hll_union(
|
|
22
|
+
void hll_union(struct selva_string *, struct selva_string *);
|
|
23
23
|
|
|
24
24
|
// size_t actual_cols[13] = { 79, 159, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200 };
|
|
25
25
|
// float raw_estimate_data[13][200] =
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2025 SAULX
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
#pragma once
|
|
6
|
+
#include "selva/_export.h"
|
|
7
|
+
#include <stdint.h>
|
|
8
|
+
|
|
9
|
+
/***
|
|
10
|
+
* Get the length of multibyte char.
|
|
11
|
+
*/
|
|
12
|
+
SELVA_EXPORT
|
|
13
|
+
#if defined(__clang__)
|
|
14
|
+
/*
|
|
15
|
+
* optnone is needed at least on clang to not optimize out the clz.
|
|
16
|
+
* Otherwise this function will always return 0.
|
|
17
|
+
*/
|
|
18
|
+
__attribute__((optnone))
|
|
19
|
+
#endif
|
|
20
|
+
inline unsigned selva_mblen(char first_byte)
|
|
21
|
+
#ifndef __zig
|
|
22
|
+
{
|
|
23
|
+
uint8_t x = first_byte;
|
|
24
|
+
unsigned l = 0;
|
|
25
|
+
|
|
26
|
+
if (x & 0x80) {
|
|
27
|
+
#if __has_builtin(__builtin_clzg)
|
|
28
|
+
l = __builtin_clzg((uint8_t)~x, 0) - 1;
|
|
29
|
+
#elif __has_builtin(__builtin_clz)
|
|
30
|
+
l = __builtin_clz((unsigned)(~x << 24)) - 1;
|
|
31
|
+
#else
|
|
32
|
+
#error "No luck"
|
|
33
|
+
#endif
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return l;
|
|
37
|
+
}
|
|
38
|
+
#else
|
|
39
|
+
;
|
|
40
|
+
#endif /* __zig */
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
struct finalizer;
|
|
12
12
|
struct selva_string;
|
|
13
|
+
struct libdeflate_compressor;
|
|
14
|
+
struct libdeflate_decompressor;
|
|
13
15
|
|
|
14
16
|
/**
|
|
15
17
|
* Selva string flags.
|
|
@@ -165,8 +167,8 @@ struct selva_string *selva_string_fread(FILE *fp, size_t size, enum selva_string
|
|
|
165
167
|
*/
|
|
166
168
|
[[nodiscard]]
|
|
167
169
|
SELVA_EXPORT
|
|
168
|
-
struct selva_string *selva_string_createz(const char *in_str, size_t in_len, enum selva_string_flags flags)
|
|
169
|
-
__attribute__((access(read_only,
|
|
170
|
+
struct selva_string *selva_string_createz(struct libdeflate_compressor *compressor, const char *in_str, size_t in_len, enum selva_string_flags flags)
|
|
171
|
+
__attribute__((access(read_only, 2, 3)));
|
|
170
172
|
|
|
171
173
|
/**
|
|
172
174
|
* Decompress a compressed string.
|
|
@@ -178,8 +180,8 @@ struct selva_string *selva_string_createz(const char *in_str, size_t in_len, enu
|
|
|
178
180
|
* SELVA_EINVAL if the string cannot be decompressed.
|
|
179
181
|
*/
|
|
180
182
|
SELVA_EXPORT
|
|
181
|
-
int selva_string_decompress(const struct selva_string * restrict s, char * restrict buf)
|
|
182
|
-
__attribute__((access(read_only,
|
|
183
|
+
int selva_string_decompress(struct libdeflate_decompressor *decompressor, const struct selva_string * restrict s, char * restrict buf)
|
|
184
|
+
__attribute__((access(read_only, 2), access(write_only, 3)));
|
|
183
185
|
|
|
184
186
|
/**
|
|
185
187
|
* Duplicate a string.
|
|
@@ -395,6 +397,7 @@ void selva_string_set_compress(struct selva_string *s)
|
|
|
395
397
|
/**
|
|
396
398
|
* Compare two strings.
|
|
397
399
|
* This function works correctly with compressed strings.
|
|
400
|
+
* @param decompress can be nullptr if strings are not compressed.
|
|
398
401
|
* @param a is a pointer to the first string to be compared.
|
|
399
402
|
* @param b is a pointer to the second strings to be compared.
|
|
400
403
|
* @returns < 0 if the first character that does not match has a lower value in ptr1 than in ptr2;
|
|
@@ -402,7 +405,7 @@ void selva_string_set_compress(struct selva_string *s)
|
|
|
402
405
|
* > 0 if the first character that does not match has a greater value in ptr1 than in ptr2.
|
|
403
406
|
*/
|
|
404
407
|
SELVA_EXPORT
|
|
405
|
-
int selva_string_cmp(const struct selva_string *a, const struct selva_string *b)
|
|
408
|
+
int selva_string_cmp(struct libdeflate_decompressor *decompressor, const struct selva_string *a, const struct selva_string *b)
|
|
406
409
|
__attribute__((access(read_only, 1), access(read_only, 2)));
|
|
407
410
|
|
|
408
411
|
/**
|
|
@@ -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
|
|
@@ -8,11 +8,21 @@
|
|
|
8
8
|
#include <stdint.h>
|
|
9
9
|
#include "selva/_export.h"
|
|
10
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
|
+
|
|
11
22
|
typedef uint32_t block_id_t;
|
|
12
23
|
typedef uint8_t field_t;
|
|
13
24
|
typedef uint32_t node_id_t;
|
|
14
25
|
typedef uint16_t node_type_t;
|
|
15
|
-
typedef int32_t cursor_id_t;
|
|
16
26
|
#ifndef __zig
|
|
17
27
|
typedef unsigned _BitInt(128) selva_hash128_t;
|
|
18
28
|
#else
|
|
@@ -81,14 +91,18 @@ struct SelvaFieldSchema {
|
|
|
81
91
|
} __designated_init;
|
|
82
92
|
|
|
83
93
|
struct SelvaFieldsSchema {
|
|
84
|
-
field_t nr_fields; /*!< The total number of fields
|
|
85
|
-
field_t nr_fixed_fields; /*!<
|
|
94
|
+
field_t nr_fields; /*!< The total number of fields in this schema. */
|
|
95
|
+
field_t nr_fixed_fields; /*!< The number of fixed fields that are always allocated. */
|
|
96
|
+
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. */
|
|
97
|
+
/**
|
|
98
|
+
* Template for fields->fields_map.
|
|
99
|
+
*/
|
|
86
100
|
struct {
|
|
87
101
|
void *buf;
|
|
88
102
|
size_t len;
|
|
89
103
|
size_t fixed_data_size;
|
|
90
104
|
} field_map_template;
|
|
91
|
-
struct SelvaFieldSchema field_schemas[
|
|
105
|
+
struct SelvaFieldSchema field_schemas[SELVA_FIELDS_MAX];
|
|
92
106
|
};
|
|
93
107
|
|
|
94
108
|
struct SelvaNodeSchema {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -212,6 +212,29 @@ libdeflate_decompress_ex(struct libdeflate_decompressor *decompressor,
|
|
|
212
212
|
size_t *actual_in_nbytes_ret,
|
|
213
213
|
size_t *actual_out_nbytes_ret);
|
|
214
214
|
|
|
215
|
+
/**
|
|
216
|
+
* Decompress a small number of bytes into out.
|
|
217
|
+
* The size of the output buffer doesn't need to align with the block size of
|
|
218
|
+
* the compressed input, unlike with the block decompression API. The downside
|
|
219
|
+
* of this decompression function is that it's much slower for longer output
|
|
220
|
+
* sizes. However, it can be much faster to use this function to extract a
|
|
221
|
+
* small number of bytes (e.g. 16 bytes) rather than decompressing a full block
|
|
222
|
+
* and then extracting a few bytes from it. This is interesting also because a
|
|
223
|
+
* deflate block can be at least theoretically be extremely long, and they
|
|
224
|
+
* are typically >= 1kB in size in the wild. Whereas, with this function the
|
|
225
|
+
* output buffer can be even fitted in the stack as it's small and it's size
|
|
226
|
+
* can be hard-coded.
|
|
227
|
+
* @param in is a pointer to the compressed data.
|
|
228
|
+
* @param in_nbytes is the size of in.
|
|
229
|
+
* @param out_nbytes_avail is the size of the out buffer.
|
|
230
|
+
* @param actual_out_nbytes_ret returns the actual number of bytes decompressed.
|
|
231
|
+
*/
|
|
232
|
+
LIBDEFLATEEXPORT enum libdeflate_result
|
|
233
|
+
libdeflate_decompress_short(struct libdeflate_decompressor *decompressor,
|
|
234
|
+
const void *in, size_t in_nbytes,
|
|
235
|
+
void *out, size_t out_nbytes_avail,
|
|
236
|
+
size_t *actual_out_nbytes_ret);
|
|
237
|
+
|
|
215
238
|
/**
|
|
216
239
|
* ctrl libdeflate_decompress_block() stop condition
|
|
217
240
|
*/
|
|
@@ -292,47 +292,6 @@ struct SelvaNode *selva_prev_node(struct SelvaTypeEntry *type, struct SelvaNode
|
|
|
292
292
|
SELVA_EXPORT
|
|
293
293
|
struct SelvaNode *selva_next_node(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
|
|
294
294
|
|
|
295
|
-
/**
|
|
296
|
-
* \addtogroup db_cursor
|
|
297
|
-
* @{
|
|
298
|
-
*/
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Create a new cursor pointing to node.
|
|
302
|
-
* If the node is deleted later then the cursor is updated to point to the next
|
|
303
|
-
* node using selva_next_node().
|
|
304
|
-
*/
|
|
305
|
-
SELVA_EXPORT
|
|
306
|
-
cursor_id_t selva_cursor_new(struct SelvaTypeEntry *type, struct SelvaNode *node) __attribute__((nonnull));
|
|
307
|
-
|
|
308
|
-
/**
|
|
309
|
-
* Get a pointer to the node from a cursor.
|
|
310
|
-
*/
|
|
311
|
-
SELVA_EXPORT
|
|
312
|
-
struct SelvaNode *selva_cursor_get(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__((nonnull));
|
|
313
|
-
|
|
314
|
-
/**
|
|
315
|
-
* Update a cursor to point to a new node.
|
|
316
|
-
*/
|
|
317
|
-
SELVA_EXPORT
|
|
318
|
-
int selva_cursor_update(struct SelvaTypeEntry *type, cursor_id_t id, struct SelvaNode *node) __attribute__((nonnull));
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Delete a cursor.
|
|
322
|
-
*/
|
|
323
|
-
SELVA_EXPORT
|
|
324
|
-
void selva_cursor_del(struct SelvaTypeEntry *type, cursor_id_t id) __attribute__((nonnull));
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Total count of cursors of type.
|
|
328
|
-
*/
|
|
329
|
-
SELVA_EXPORT
|
|
330
|
-
size_t selva_cursor_count(const struct SelvaTypeEntry *type) __attribute__((nonnull));
|
|
331
|
-
|
|
332
|
-
/**
|
|
333
|
-
* @}
|
|
334
|
-
*/
|
|
335
|
-
|
|
336
295
|
/**
|
|
337
296
|
* Total count of nodes of type.
|
|
338
297
|
*/
|
|
@@ -8,7 +8,8 @@
|
|
|
8
8
|
#include "selva/types.h"
|
|
9
9
|
|
|
10
10
|
struct SelvaNode;
|
|
11
|
-
struct
|
|
11
|
+
struct SelvaNodeSmallReference;
|
|
12
|
+
struct SelvaNodeLargeReference;
|
|
12
13
|
|
|
13
14
|
SELVA_EXPORT
|
|
14
15
|
ssize_t fast_linear_search_uint32(const uint32_t arr[], size_t len, uint32_t x);
|
|
@@ -20,4 +21,7 @@ SELVA_EXPORT
|
|
|
20
21
|
ssize_t fast_linear_search_node(const struct SelvaNode *arr[], size_t len, const struct SelvaNode *x);
|
|
21
22
|
|
|
22
23
|
SELVA_EXPORT
|
|
23
|
-
ssize_t
|
|
24
|
+
ssize_t fast_linear_search_references_small(const struct SelvaNodeSmallReference *arr, size_t len, const struct SelvaNode *x);
|
|
25
|
+
|
|
26
|
+
SELVA_EXPORT
|
|
27
|
+
ssize_t fast_linear_search_references_large(const struct SelvaNodeLargeReference *arr, size_t len, const struct SelvaNode *x);
|