@based/db 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v24.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +320 -0
- package/dist/lib/linux_aarch64/include/jemalloc.h +468 -0
- package/dist/lib/linux_aarch64/include/libdeflate.h +345 -0
- package/dist/lib/linux_aarch64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_aarch64/include/linker_set.h +109 -0
- package/dist/lib/linux_aarch64/include/queue.h +627 -0
- package/dist/lib/linux_aarch64/include/selva/_export.h +7 -0
- package/dist/lib/linux_aarch64/include/selva/align.h +9 -0
- package/dist/lib/linux_aarch64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_aarch64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_aarch64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_aarch64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_aarch64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +430 -0
- package/dist/lib/linux_aarch64/include/selva/endian.h +301 -0
- package/dist/lib/linux_aarch64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_aarch64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_aarch64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +379 -0
- package/dist/lib/linux_aarch64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_aarch64/include/selva/hll.h +85 -0
- package/dist/lib/linux_aarch64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_aarch64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_aarch64/include/selva/membar.h +32 -0
- package/dist/lib/linux_aarch64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_aarch64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_aarch64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_aarch64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_aarch64/include/selva/sort.h +140 -0
- package/dist/lib/linux_aarch64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_aarch64/include/selva/thread.h +37 -0
- package/dist/lib/linux_aarch64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +119 -0
- package/dist/lib/linux_aarch64/include/selva/vector.h +35 -0
- package/dist/lib/linux_aarch64/include/selva_error.h +140 -0
- package/dist/lib/linux_aarch64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_aarch64/include/tree.h +852 -0
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v24.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_aarch64/libxxhash.so.0 +0 -0
- package/dist/lib/linux_x86_64/include/cdefs.h +320 -0
- package/dist/lib/linux_x86_64/include/jemalloc.h +468 -0
- package/dist/lib/linux_x86_64/include/libdeflate.h +345 -0
- package/dist/lib/linux_x86_64/include/libdeflate_strings.h +35 -0
- package/dist/lib/linux_x86_64/include/linker_set.h +109 -0
- package/dist/lib/linux_x86_64/include/queue.h +627 -0
- package/dist/lib/linux_x86_64/include/selva/_export.h +7 -0
- package/dist/lib/linux_x86_64/include/selva/align.h +9 -0
- package/dist/lib/linux_x86_64/include/selva/backoff_timeout.h +29 -0
- package/dist/lib/linux_x86_64/include/selva/bitmap.h +95 -0
- package/dist/lib/linux_x86_64/include/selva/colvec.h +71 -0
- package/dist/lib/linux_x86_64/include/selva/crc32c.h +17 -0
- package/dist/lib/linux_x86_64/include/selva/ctime.h +135 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +430 -0
- package/dist/lib/linux_x86_64/include/selva/endian.h +301 -0
- package/dist/lib/linux_x86_64/include/selva/fast_linear_search.h +27 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memcmp.h +18 -0
- package/dist/lib/linux_x86_64/include/selva/fast_memmem.h +11 -0
- package/dist/lib/linux_x86_64/include/selva/fast_parsei.h +36 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +379 -0
- package/dist/lib/linux_x86_64/include/selva/gmtime.h +137 -0
- package/dist/lib/linux_x86_64/include/selva/hll.h +85 -0
- package/dist/lib/linux_x86_64/include/selva/lpf.h +28 -0
- package/dist/lib/linux_x86_64/include/selva/mblen.h +40 -0
- package/dist/lib/linux_x86_64/include/selva/membar.h +32 -0
- package/dist/lib/linux_x86_64/include/selva/node_id_set.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/poptop.h +114 -0
- package/dist/lib/linux_x86_64/include/selva/selva_hash128.h +49 -0
- package/dist/lib/linux_x86_64/include/selva/selva_lang.h +105 -0
- package/dist/lib/linux_x86_64/include/selva/selva_math.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/selva_string.h +683 -0
- package/dist/lib/linux_x86_64/include/selva/sort.h +140 -0
- package/dist/lib/linux_x86_64/include/selva/strsearch.h +43 -0
- package/dist/lib/linux_x86_64/include/selva/thread.h +37 -0
- package/dist/lib/linux_x86_64/include/selva/timestamp.h +25 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +119 -0
- package/dist/lib/linux_x86_64/include/selva/vector.h +35 -0
- package/dist/lib/linux_x86_64/include/selva_error.h +140 -0
- package/dist/lib/linux_x86_64/include/selva_lang_code.h +160 -0
- package/dist/lib/linux_x86_64/include/tree.h +852 -0
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libjemalloc_selva.so.2 +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v24.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/libxxhash.so.0 +0 -0
- package/dist/src/server/migrate/worker.js +87 -84
- package/package.json +1 -1
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -10,101 +10,104 @@ if (isMainThread) {
|
|
|
10
10
|
console.warn('running worker.ts in mainthread');
|
|
11
11
|
}
|
|
12
12
|
else if (workerData?.isDbMigrateWorker) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
if (prop.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
edge
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
13
|
+
;
|
|
14
|
+
(async () => {
|
|
15
|
+
const { from, to, fromSchema, toSchema, channel, workerState, transformFns, } = workerData;
|
|
16
|
+
const fromCtx = native.externalFromInt(from);
|
|
17
|
+
const toCtx = native.externalFromInt(to);
|
|
18
|
+
native.createThreadCtx(fromCtx, native.getThreadId());
|
|
19
|
+
native.createThreadCtx(toCtx, native.getThreadId());
|
|
20
|
+
const fromDb = new BasedDb({ path: null });
|
|
21
|
+
const toDb = new BasedDb({ path: null });
|
|
22
|
+
fromDb.server.dbCtxExternal = fromCtx;
|
|
23
|
+
toDb.server.dbCtxExternal = toCtx;
|
|
24
|
+
setSchemaOnServer(fromDb.server, deSerialize(fromSchema));
|
|
25
|
+
setSchemaOnServer(toDb.server, deSerialize(toSchema));
|
|
26
|
+
setLocalClientSchema(fromDb.client, fromDb.server.schema);
|
|
27
|
+
setLocalClientSchema(toDb.client, toDb.server.schema);
|
|
28
|
+
try {
|
|
29
|
+
const map = {};
|
|
30
|
+
for (const type in fromDb.server.schemaTypesParsed) {
|
|
31
|
+
const { id, props } = fromDb.server.schemaTypesParsed[type];
|
|
32
|
+
const include = [];
|
|
33
|
+
const includeRaw = [];
|
|
34
|
+
for (const path in props) {
|
|
35
|
+
const prop = props[path];
|
|
36
|
+
if (prop.typeIndex === REFERENCE || prop.typeIndex === REFERENCES) {
|
|
37
|
+
include.push(`${path}.id`);
|
|
38
|
+
if (prop.edges) {
|
|
39
|
+
for (const key in prop.edges) {
|
|
40
|
+
const edge = prop.edges[key];
|
|
41
|
+
if (edge.typeIndex === REFERENCE ||
|
|
42
|
+
edge.typeIndex === REFERENCES) {
|
|
43
|
+
include.push(`${path}.${key}.id`);
|
|
44
|
+
}
|
|
45
|
+
else if (edge.typeIndex === CARDINALITY) {
|
|
46
|
+
includeRaw.push(`${path}.${key}`);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
include.push(`${path}.${key}`);
|
|
50
|
+
}
|
|
48
51
|
}
|
|
49
52
|
}
|
|
50
53
|
}
|
|
54
|
+
else if (prop.typeIndex === CARDINALITY) {
|
|
55
|
+
includeRaw.push(path);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
include.push(path);
|
|
59
|
+
}
|
|
51
60
|
}
|
|
52
|
-
|
|
53
|
-
includeRaw.push(path);
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
include.push(path);
|
|
57
|
-
}
|
|
61
|
+
map[id] = { type, include, includeRaw };
|
|
58
62
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
query.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
toDb.create(type, res || node, { unsafe: true });
|
|
63
|
+
for (const type in transformFns) {
|
|
64
|
+
const fnOrNull = transformFns[type];
|
|
65
|
+
transformFns[type] = eval(`(${fnOrNull})`);
|
|
66
|
+
}
|
|
67
|
+
while (true) {
|
|
68
|
+
let msg;
|
|
69
|
+
while ((msg = receiveMessageOnPort(channel))) {
|
|
70
|
+
const leafData = msg.message;
|
|
71
|
+
const { type, include, includeRaw } = map[leafData.typeId];
|
|
72
|
+
const typeTransformFn = transformFns[type];
|
|
73
|
+
const query = fromDb
|
|
74
|
+
.query(type)
|
|
75
|
+
.range(leafData.start - 1, leafData.end)
|
|
76
|
+
.include(include);
|
|
77
|
+
for (const rawProp of includeRaw) {
|
|
78
|
+
query.include(rawProp, { raw: true });
|
|
79
|
+
}
|
|
80
|
+
const nodes = query._getSync(fromCtx);
|
|
81
|
+
if (typeTransformFn) {
|
|
82
|
+
for (const node of nodes) {
|
|
83
|
+
const res = typeTransformFn(node);
|
|
84
|
+
if (res === null) {
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (Array.isArray(res)) {
|
|
88
|
+
toDb.create(res[0], res[1] || node, { unsafe: true });
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
toDb.create(type, res || node, { unsafe: true });
|
|
92
|
+
}
|
|
90
93
|
}
|
|
91
94
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
95
|
+
else if (type in toDb.server.schemaTypesParsed) {
|
|
96
|
+
for (const node of nodes) {
|
|
97
|
+
toDb.create(type, node, { unsafe: true });
|
|
98
|
+
}
|
|
96
99
|
}
|
|
97
100
|
}
|
|
101
|
+
await toDb.drain();
|
|
102
|
+
native.membarSyncWrite();
|
|
103
|
+
setToSleep(workerState);
|
|
98
104
|
}
|
|
99
|
-
await toDb.drain();
|
|
100
|
-
native.membarSyncWrite();
|
|
101
|
-
setToSleep(workerState);
|
|
102
105
|
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
console.error(e);
|
|
108
|
+
throw e;
|
|
109
|
+
}
|
|
110
|
+
})();
|
|
108
111
|
}
|
|
109
112
|
else {
|
|
110
113
|
console.info('incorrect worker db migrate');
|