@based/db 0.0.26 → 0.0.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/darwin_aarch64/include/cdefs.h +1 -1
- package/dist/lib/darwin_aarch64/include/selva/db.h +11 -11
- package/dist/lib/darwin_aarch64/include/selva/fields.h +47 -12
- package/dist/lib/darwin_aarch64/include/selva/hll.h +59 -0
- package/dist/lib/darwin_aarch64/include/selva/types.h +2 -0
- package/dist/lib/darwin_aarch64/include/tree.h +69 -69
- package/dist/lib/darwin_aarch64/libdeflate.dylib +0 -0
- package/dist/lib/darwin_aarch64/libjemalloc_selva.2.dylib +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v21.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v23.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/cdefs.h +1 -1
- package/dist/lib/linux_aarch64/include/selva/db.h +11 -11
- package/dist/lib/linux_aarch64/include/selva/fields.h +47 -12
- package/dist/lib/linux_aarch64/include/selva/hll.h +59 -0
- package/dist/lib/linux_aarch64/include/selva/types.h +2 -0
- package/dist/lib/linux_aarch64/include/tree.h +69 -69
- package/dist/lib/linux_aarch64/libdeflate.so +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v21.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v23.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/cdefs.h +1 -1
- package/dist/lib/linux_x86_64/include/selva/db.h +11 -11
- package/dist/lib/linux_x86_64/include/selva/fields.h +47 -12
- package/dist/lib/linux_x86_64/include/selva/hll.h +59 -0
- package/dist/lib/linux_x86_64/include/selva/types.h +2 -0
- package/dist/lib/linux_x86_64/include/tree.h +69 -69
- package/dist/lib/linux_x86_64/libdeflate.so +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v21.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v23.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/modify/alias.js +3 -0
- package/dist/src/client/modify/binary.js +1 -1
- package/dist/src/client/modify/cardinality.d.ts +2 -2
- package/dist/src/client/modify/cardinality.js +17 -6
- package/dist/src/client/modify/fixed.js +6 -51
- package/dist/src/client/modify/json.js +15 -1
- package/dist/src/client/modify/references/edge.js +1 -1
- package/dist/src/client/modify/references/references.js +21 -6
- package/dist/src/client/modify/string.js +5 -6
- package/dist/src/client/modify/text.js +0 -11
- package/dist/src/client/modify/vector.js +3 -3
- package/dist/src/client/query/BasedDbQuery.js +6 -1
- package/dist/src/client/query/filter/parseFilterValue.js +2 -4
- package/dist/src/client/query/include/walk.js +1 -0
- package/dist/src/client/query/read/read.js +8 -1
- package/dist/src/client/query/validation.js +3 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +8 -2
- package/dist/src/server/index.js +10 -3
- package/dist/src/server/migrate/index.js +9 -5
- package/dist/src/server/migrate/worker.js +26 -1
- package/dist/src/server/save.js +1 -1
- package/package.json +4 -3
- package/dist/src/client/bitWise.d.ts +0 -6
- package/dist/src/client/bitWise.js +0 -72
- package/dist/src/client/operations.d.ts +0 -32
- package/dist/src/client/operations.js +0 -137
- package/dist/src/client/query/aggregationFn.d.ts +0 -3
- package/dist/src/client/query/aggregationFn.js +0 -9
- package/dist/src/client/tree.d.ts +0 -1
- package/dist/src/client/tree.js +0 -5
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { makeCsmtKeyFromNodeId } from './tree.js';
|
|
2
|
-
export class ModifyCtx {
|
|
3
|
-
constructor(db) {
|
|
4
|
-
this.max = db.maxModifySize;
|
|
5
|
-
this.db = db;
|
|
6
|
-
this.buf = new Uint8Array(db.maxModifySize);
|
|
7
|
-
}
|
|
8
|
-
// default values
|
|
9
|
-
len = 0;
|
|
10
|
-
id = -1;
|
|
11
|
-
hasSortField = -1;
|
|
12
|
-
hasSortText = -1;
|
|
13
|
-
queue = new Map();
|
|
14
|
-
ctx = {}; // maybe make this different?
|
|
15
|
-
payload;
|
|
16
|
-
max;
|
|
17
|
-
buf;
|
|
18
|
-
field;
|
|
19
|
-
prefix0 = -1;
|
|
20
|
-
prefix1 = -1;
|
|
21
|
-
lastMain = -1;
|
|
22
|
-
mergeMain;
|
|
23
|
-
mergeMainSize;
|
|
24
|
-
db;
|
|
25
|
-
dirtyRanges = new Set();
|
|
26
|
-
dirtyTypes = new Map();
|
|
27
|
-
markNodeDirty(schema, nodeId) {
|
|
28
|
-
const key = makeCsmtKeyFromNodeId(schema.id, schema.blockCapacity, nodeId);
|
|
29
|
-
if (this.dirtyRanges.has(key)) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
this.dirtyRanges.add(key);
|
|
33
|
-
this.updateMax();
|
|
34
|
-
}
|
|
35
|
-
markTypeDirty(schema) {
|
|
36
|
-
if (this.dirtyTypes.has(schema.id)) {
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
this.dirtyTypes.set(schema.id, schema.lastId);
|
|
40
|
-
this.updateMax();
|
|
41
|
-
}
|
|
42
|
-
updateMax() {
|
|
43
|
-
// reserve space in the end of the buf [...data, type (16), lastId (32), typesSize (16), ...ranges (64)[], dataLen (32)]
|
|
44
|
-
this.max =
|
|
45
|
-
this.db.maxModifySize -
|
|
46
|
-
4 -
|
|
47
|
-
2 -
|
|
48
|
-
this.dirtyTypes.size * 10 -
|
|
49
|
-
this.dirtyRanges.size * 8;
|
|
50
|
-
}
|
|
51
|
-
getData(lastIds) {
|
|
52
|
-
const rangesSize = this.dirtyRanges.size;
|
|
53
|
-
const typesSize = this.dirtyTypes.size;
|
|
54
|
-
const data = this.buf.subarray(0, this.len + 4 + 2 + typesSize * 10 + rangesSize * 8);
|
|
55
|
-
let i = this.len;
|
|
56
|
-
data[i] = typesSize;
|
|
57
|
-
data[i + 1] = typesSize >>> 8;
|
|
58
|
-
i += 2;
|
|
59
|
-
for (const [id, startId] of this.dirtyTypes) {
|
|
60
|
-
const lastId = this.db.schemaTypesParsedById[id].lastId;
|
|
61
|
-
lastIds[id] = lastId;
|
|
62
|
-
data[i] = id;
|
|
63
|
-
data[i + 1] = id >>> 8;
|
|
64
|
-
i += 2;
|
|
65
|
-
data[i++] = startId;
|
|
66
|
-
data[i++] = startId >>> 8;
|
|
67
|
-
data[i++] = startId >>> 16;
|
|
68
|
-
data[i++] = startId >>> 24;
|
|
69
|
-
data[i++] = lastId;
|
|
70
|
-
data[i++] = lastId >>> 8;
|
|
71
|
-
data[i++] = lastId >>> 16;
|
|
72
|
-
data[i++] = lastId >>> 24;
|
|
73
|
-
}
|
|
74
|
-
const view = new DataView(data.buffer, data.byteOffset);
|
|
75
|
-
for (let key of this.dirtyRanges) {
|
|
76
|
-
view.setFloat64(i, key, true);
|
|
77
|
-
i += 8;
|
|
78
|
-
}
|
|
79
|
-
data[i++] = this.len;
|
|
80
|
-
data[i++] = this.len >>> 8;
|
|
81
|
-
data[i++] = this.len >>> 16;
|
|
82
|
-
data[i++] = this.len >>> 24;
|
|
83
|
-
return data;
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
export const flushBuffer = (db) => {
|
|
87
|
-
const ctx = db.modifyCtx;
|
|
88
|
-
let flushPromise;
|
|
89
|
-
if (ctx.len) {
|
|
90
|
-
const d = Date.now();
|
|
91
|
-
const lastIds = {};
|
|
92
|
-
const data = ctx.getData(lastIds);
|
|
93
|
-
const resCtx = ctx.ctx;
|
|
94
|
-
const queue = ctx.queue;
|
|
95
|
-
flushPromise = db.hooks.flushModify(data).then(({ offsets }) => {
|
|
96
|
-
resCtx.offsets = offsets;
|
|
97
|
-
for (const typeId in lastIds) {
|
|
98
|
-
if (typeId in offsets) {
|
|
99
|
-
const lastId = lastIds[typeId] + offsets[typeId];
|
|
100
|
-
const def = db.schemaTypesParsedById[typeId];
|
|
101
|
-
const delta = lastId - def.lastId;
|
|
102
|
-
if (delta > 0) {
|
|
103
|
-
def.lastId += delta;
|
|
104
|
-
def.total += delta;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
else {
|
|
108
|
-
console.warn('no offset returned, very wrong');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
db.writeTime += Date.now() - d;
|
|
112
|
-
if (queue.size) {
|
|
113
|
-
flushPromise.then(() => {
|
|
114
|
-
for (const [resolve, res] of queue) {
|
|
115
|
-
resolve(res.getId(offsets));
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
});
|
|
120
|
-
ctx.dirtyTypes.clear();
|
|
121
|
-
ctx.dirtyRanges.clear();
|
|
122
|
-
ctx.len = 0;
|
|
123
|
-
ctx.prefix0 = -1;
|
|
124
|
-
ctx.prefix1 = -1;
|
|
125
|
-
ctx.max = db.maxModifySize;
|
|
126
|
-
ctx.ctx = {};
|
|
127
|
-
}
|
|
128
|
-
db.isDraining = false;
|
|
129
|
-
return flushPromise;
|
|
130
|
-
};
|
|
131
|
-
export const startDrain = (db) => {
|
|
132
|
-
db.isDraining = true;
|
|
133
|
-
process.nextTick(() => {
|
|
134
|
-
flushBuffer(db);
|
|
135
|
-
});
|
|
136
|
-
};
|
|
137
|
-
//# sourceMappingURL=operations.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const makeCsmtKeyFromNodeId: (typeId: number, blockCapacity: number, nodeId: number) => number;
|
package/dist/src/client/tree.js
DELETED