@based/db 0.0.15 → 0.0.17
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/selva/db.h +3 -0
- package/dist/lib/darwin_aarch64/include/selva/fields.h +1 -2
- package/dist/lib/darwin_aarch64/include/selva/history.h +16 -1
- package/dist/lib/darwin_aarch64/include/selva/hll.h +2 -1
- package/dist/lib/darwin_aarch64/include/selva/types.h +4 -0
- package/dist/lib/darwin_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/darwin_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/darwin_aarch64/libselva.dylib +0 -0
- package/dist/lib/linux_aarch64/include/selva/db.h +3 -0
- package/dist/lib/linux_aarch64/include/selva/fields.h +1 -2
- package/dist/lib/linux_aarch64/include/selva/history.h +16 -1
- package/dist/lib/linux_aarch64/include/selva/hll.h +2 -1
- package/dist/lib/linux_aarch64/include/selva/types.h +4 -0
- package/dist/lib/linux_aarch64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_aarch64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_aarch64/libselva.so +0 -0
- package/dist/lib/linux_x86_64/include/selva/db.h +3 -0
- package/dist/lib/linux_x86_64/include/selva/fields.h +1 -2
- package/dist/lib/linux_x86_64/include/selva/history.h +16 -1
- package/dist/lib/linux_x86_64/include/selva/hll.h +2 -1
- package/dist/lib/linux_x86_64/include/selva/types.h +4 -0
- package/dist/lib/linux_x86_64/libnode-v20.11.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v20.18.1.node +0 -0
- package/dist/lib/linux_x86_64/libnode-v22.13.0.node +0 -0
- package/dist/lib/linux_x86_64/libselva.so +0 -0
- package/dist/src/client/bitWise.js +1 -0
- package/dist/src/client/crc32.js +0 -276
- package/dist/src/client/modify/ModifyRes.d.ts +4 -2
- package/dist/src/client/modify/ModifyRes.js +11 -6
- package/dist/src/client/modify/alias.js +2 -2
- package/dist/src/client/modify/cardinality.js +14 -10
- package/dist/src/client/modify/create.js +8 -9
- package/dist/src/client/modify/references/reference.js +14 -7
- package/dist/src/client/modify/references/references.js +10 -4
- package/dist/src/client/modify/string.js +2 -2
- package/dist/src/client/modify/text.js +1 -1
- package/dist/src/client/modify/types.d.ts +3 -1
- package/dist/src/client/modify/types.js +2 -0
- package/dist/src/client/modify/update.js +1 -1
- package/dist/src/client/operations.d.ts +2 -2
- package/dist/src/client/operations.js +19 -3
- package/dist/src/client/query/BasedDbQuery.d.ts +5 -4
- package/dist/src/client/query/BasedDbQuery.js +28 -13
- package/dist/src/client/query/BasedIterable.js +3 -10
- package/dist/src/client/query/display.d.ts +6 -0
- package/dist/src/client/query/display.js +63 -4
- package/dist/src/client/query/filter/FilterBranch.js +8 -3
- package/dist/src/client/query/filter/convertFilter.d.ts +4 -0
- package/dist/src/client/query/filter/convertFilter.js +56 -0
- package/dist/src/client/query/filter/createFixedFilterBuffer.js +9 -8
- package/dist/src/client/query/filter/createReferenceFilter.js +5 -4
- package/dist/src/client/query/filter/createVariableFilterBuffer.js +6 -10
- package/dist/src/client/query/filter/filter.d.ts +1 -2
- package/dist/src/client/query/filter/filter.js +5 -56
- package/dist/src/client/query/filter/primitiveFilter.d.ts +2 -2
- package/dist/src/client/query/filter/primitiveFilter.js +5 -1
- package/dist/src/client/query/filter/toBuffer.js +1 -6
- package/dist/src/client/query/filter/types.d.ts +2 -1
- package/dist/src/client/query/filter/types.js +23 -12
- package/dist/src/client/query/include/props.js +14 -6
- package/dist/src/client/query/include/utils.js +2 -2
- package/dist/src/client/query/include/walk.js +1 -7
- package/dist/src/client/query/queryDef.d.ts +1 -1
- package/dist/src/client/query/queryDef.js +4 -3
- package/dist/src/client/query/read/read.js +21 -32
- package/dist/src/client/query/read/types.d.ts +4 -0
- package/dist/src/client/query/read/types.js +5 -0
- package/dist/src/client/query/registerQuery.js +1 -0
- package/dist/src/client/query/search/index.js +12 -6
- package/dist/src/client/query/sort.js +7 -6
- package/dist/src/client/query/thresholds.d.ts +0 -1
- package/dist/src/client/query/thresholds.js +0 -8
- package/dist/src/client/query/toBuffer.js +0 -3
- package/dist/src/client/query/types.d.ts +2 -0
- package/dist/src/client/query/validation.d.ts +39 -1
- package/dist/src/client/query/validation.js +299 -93
- package/dist/src/client/xxHash64.d.ts +1 -1
- package/dist/src/client/xxHash64.js +7 -2
- package/dist/src/index.d.ts +6 -1
- package/dist/src/index.js +31 -1
- package/dist/src/native.d.ts +3 -1
- package/dist/src/native.js +8 -2
- package/dist/src/server/index.d.ts +8 -6
- package/dist/src/server/index.js +56 -30
- package/dist/src/server/migrate/index.js +10 -2
- package/dist/src/server/migrate/worker.js +1 -1
- package/dist/src/server/schema/typeDef.js +35 -25
- package/dist/src/server/schema/types.d.ts +10 -5
- package/dist/src/server/schema/types.js +1 -1
- package/dist/src/server/schema/utils.d.ts +1 -0
- package/dist/src/server/schema/utils.js +18 -5
- package/package.json +5 -3
package/dist/src/server/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import native from '../native.js';
|
|
2
2
|
import { rm, writeFile } from 'node:fs/promises';
|
|
3
3
|
import { dirname, join } from 'node:path';
|
|
4
|
-
import { getPropType } from '@based/schema';
|
|
4
|
+
import { getPropType, langCodesMap, } from '@based/schema';
|
|
5
5
|
import { genRootId } from './schema/utils.js';
|
|
6
6
|
import { updateTypeDefs } from './schema/typeDef.js';
|
|
7
7
|
import { schemaToSelvaBuffer } from './schema/selvaBuffer.js';
|
|
8
8
|
import { start } from './start.js';
|
|
9
|
-
import { foreachDirtyBlock, makeCsmtKey } from './tree.js';
|
|
9
|
+
import { foreachDirtyBlock, makeCsmtKey, makeCsmtKeyFromNodeId, } from './tree.js';
|
|
10
10
|
import { save } from './save.js';
|
|
11
11
|
import { Worker, MessageChannel } from 'node:worker_threads';
|
|
12
12
|
import { fileURLToPath } from 'node:url';
|
|
@@ -112,14 +112,16 @@ export class DbServer {
|
|
|
112
112
|
for (const type in this.sortIndexes) {
|
|
113
113
|
for (const field in this.sortIndexes[type]) {
|
|
114
114
|
for (const start in this.sortIndexes[type][field]) {
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
115
|
+
for (const lang in this.sortIndexes[type][field][start]) {
|
|
116
|
+
const sortIndex = this.sortIndexes[type][field][start][lang];
|
|
117
|
+
sortIndex.cnt /= 2;
|
|
118
|
+
if (sortIndex.cnt < 1) {
|
|
119
|
+
native.destroySortIndex(sortIndex.buf, this.dbCtxExternal);
|
|
120
|
+
delete this.sortIndexes[type][field][start][lang];
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
remaining = true;
|
|
124
|
+
}
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
}
|
|
@@ -130,33 +132,41 @@ export class DbServer {
|
|
|
130
132
|
}, 60e3);
|
|
131
133
|
}
|
|
132
134
|
}
|
|
133
|
-
createSortIndex(type, field) {
|
|
135
|
+
createSortIndex(type, field, lang = 'none') {
|
|
134
136
|
const t = this.schemaTypesParsed[type];
|
|
135
137
|
const prop = t.props[field];
|
|
138
|
+
const langCode = langCodesMap.get(lang ?? Object.keys(this.schema?.locales ?? 'en')[0]) ??
|
|
139
|
+
0;
|
|
136
140
|
let types = this.sortIndexes[t.id];
|
|
137
141
|
if (!types) {
|
|
138
142
|
types = this.sortIndexes[t.id] = {};
|
|
139
143
|
}
|
|
140
|
-
let
|
|
144
|
+
let f = types[prop.prop];
|
|
145
|
+
if (!f) {
|
|
146
|
+
f = types[prop.prop] = {};
|
|
147
|
+
}
|
|
148
|
+
let fields = f[prop.start];
|
|
141
149
|
if (!fields) {
|
|
142
|
-
fields =
|
|
150
|
+
fields = f[prop.start] = {};
|
|
143
151
|
}
|
|
144
|
-
let sortIndex = fields[
|
|
152
|
+
let sortIndex = fields[langCode];
|
|
145
153
|
if (sortIndex) {
|
|
146
154
|
return sortIndex;
|
|
147
155
|
}
|
|
148
156
|
const buf = Buffer.allocUnsafe(8);
|
|
149
|
-
// size [2 type] [1 field]
|
|
157
|
+
// size [2 type] [1 field] [2 start] [2 len] [propIndex] [lang]
|
|
158
|
+
// call createSortBuf here
|
|
150
159
|
buf.writeUint16LE(t.id, 0);
|
|
151
160
|
buf[2] = prop.prop;
|
|
152
161
|
buf.writeUint16LE(prop.start, 3);
|
|
153
162
|
buf.writeUint16LE(prop.len, 5);
|
|
154
163
|
buf[7] = prop.typeIndex;
|
|
164
|
+
buf[8] = langCode;
|
|
155
165
|
sortIndex = new SortIndex(buf, this.dbCtxExternal);
|
|
156
|
-
fields[
|
|
166
|
+
fields[langCode] = sortIndex;
|
|
157
167
|
return sortIndex;
|
|
158
168
|
}
|
|
159
|
-
destroySortIndex(type, field) {
|
|
169
|
+
destroySortIndex(type, field, lang = 'none') {
|
|
160
170
|
const t = this.schemaTypesParsed[type];
|
|
161
171
|
const prop = t.props[field];
|
|
162
172
|
let types = this.sortIndexes[t.id];
|
|
@@ -169,30 +179,37 @@ export class DbServer {
|
|
|
169
179
|
}
|
|
170
180
|
let sortIndex = fields[prop.start];
|
|
171
181
|
if (sortIndex) {
|
|
172
|
-
|
|
182
|
+
// [2 type] [1 field] [2 start] [1 lang]
|
|
183
|
+
const buf = Buffer.allocUnsafe(6);
|
|
173
184
|
buf.writeUint16LE(t.id, 0);
|
|
174
185
|
buf[2] = prop.prop;
|
|
175
186
|
buf.writeUint16LE(prop.start, 3);
|
|
187
|
+
buf[5] =
|
|
188
|
+
langCodesMap.get(lang ?? Object.keys(this.schema?.locales ?? 'en')[0]) ?? 0;
|
|
176
189
|
native.destroySortIndex(buf, this.dbCtxExternal);
|
|
177
190
|
delete fields[prop.start];
|
|
178
191
|
}
|
|
179
192
|
}
|
|
180
|
-
getSortIndex(typeId, field, start) {
|
|
193
|
+
getSortIndex(typeId, field, start, lang) {
|
|
181
194
|
let types = this.sortIndexes[typeId];
|
|
182
195
|
if (!types) {
|
|
183
196
|
types = this.sortIndexes[typeId] = {};
|
|
184
197
|
}
|
|
185
|
-
let
|
|
198
|
+
let f = types[field];
|
|
199
|
+
if (!f) {
|
|
200
|
+
f = types[field] = {};
|
|
201
|
+
}
|
|
202
|
+
let fields = f[start];
|
|
186
203
|
if (!fields) {
|
|
187
|
-
fields =
|
|
204
|
+
fields = f[start] = {};
|
|
188
205
|
}
|
|
189
|
-
return fields[
|
|
206
|
+
return fields[lang];
|
|
190
207
|
}
|
|
191
208
|
migrateSchema(schema, transform) {
|
|
192
209
|
return migrate(this, schema, transform);
|
|
193
210
|
}
|
|
194
|
-
createSortIndexBuffer(typeId, field, start) {
|
|
195
|
-
const buf = Buffer.allocUnsafe(
|
|
211
|
+
createSortIndexBuffer(typeId, field, start, lang) {
|
|
212
|
+
const buf = Buffer.allocUnsafe(9);
|
|
196
213
|
buf.writeUint16LE(typeId, 0);
|
|
197
214
|
buf[2] = field;
|
|
198
215
|
buf.writeUint16LE(start, 3);
|
|
@@ -219,11 +236,13 @@ export class DbServer {
|
|
|
219
236
|
}
|
|
220
237
|
buf.writeUint16LE(prop.len, 5);
|
|
221
238
|
buf[7] = prop.typeIndex;
|
|
239
|
+
buf[8] = lang;
|
|
222
240
|
// put in modify stuff
|
|
223
|
-
const sortIndex =
|
|
241
|
+
const sortIndex = this.getSortIndex(typeId, prop.prop, prop.start, lang) ??
|
|
242
|
+
new SortIndex(buf, this.dbCtxExternal);
|
|
224
243
|
const types = this.sortIndexes[typeId];
|
|
225
244
|
const fields = types[field];
|
|
226
|
-
fields[start] = sortIndex;
|
|
245
|
+
fields[start][lang] = sortIndex;
|
|
227
246
|
return sortIndex;
|
|
228
247
|
}
|
|
229
248
|
updateMerkleTree() {
|
|
@@ -360,11 +379,18 @@ export class DbServer {
|
|
|
360
379
|
#modify(buf) {
|
|
361
380
|
const end = buf.length - 4;
|
|
362
381
|
const dataLen = buf.readUint32LE(end);
|
|
363
|
-
|
|
382
|
+
let typesSize = buf.readUint16LE(dataLen);
|
|
364
383
|
const typesLen = typesSize * 10;
|
|
365
384
|
const types = buf.subarray(dataLen + 2, dataLen + typesLen + 2);
|
|
366
385
|
const data = buf.subarray(0, dataLen);
|
|
367
|
-
let i = dataLen + 2
|
|
386
|
+
let i = dataLen + 2;
|
|
387
|
+
while (typesSize--) {
|
|
388
|
+
const typeId = buf.readUint16LE(i);
|
|
389
|
+
const def = this.schemaTypesParsedById[typeId];
|
|
390
|
+
const key = makeCsmtKeyFromNodeId(def.id, def.blockCapacity, def.lastId);
|
|
391
|
+
this.dirtyRanges.add(key);
|
|
392
|
+
i += 10;
|
|
393
|
+
}
|
|
368
394
|
while (i < end) {
|
|
369
395
|
const key = buf.readDoubleLE(i);
|
|
370
396
|
this.dirtyRanges.add(key);
|
|
@@ -388,14 +414,14 @@ export class DbServer {
|
|
|
388
414
|
const sort = buf.slice(s + 2, s + 2 + sortLen);
|
|
389
415
|
const field = sort[1];
|
|
390
416
|
const start = sort.readUint16LE(2 + 1);
|
|
391
|
-
let sortIndex = this.getSortIndex(typeId, field, start);
|
|
417
|
+
let sortIndex = this.getSortIndex(typeId, field, start, 0);
|
|
392
418
|
if (!sortIndex) {
|
|
393
419
|
if (this.processingQueries) {
|
|
394
420
|
return new Promise((resolve) => {
|
|
395
421
|
this.queryQueue.set(resolve, buf);
|
|
396
422
|
});
|
|
397
423
|
}
|
|
398
|
-
sortIndex = this.createSortIndexBuffer(typeId, field, start);
|
|
424
|
+
sortIndex = this.createSortIndexBuffer(typeId, field, start, sort[sort.byteLength - 1]);
|
|
399
425
|
}
|
|
400
426
|
// increment
|
|
401
427
|
sortIndex.cnt++;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { BasedDb } from '../../index.js';
|
|
2
2
|
import { dirname, join } from 'path';
|
|
3
3
|
import { tmpdir } from 'os';
|
|
4
|
-
import { Worker, MessageChannel } from 'node:worker_threads';
|
|
4
|
+
import { Worker, MessageChannel, receiveMessageOnPort, } from 'node:worker_threads';
|
|
5
5
|
import native from '../../native.js';
|
|
6
6
|
import './worker.js';
|
|
7
7
|
import { foreachDirtyBlock } from '../tree.js';
|
|
@@ -99,7 +99,15 @@ export const migrate = async (fromDbServer, toSchema, transform) => {
|
|
|
99
99
|
}
|
|
100
100
|
}
|
|
101
101
|
if (!abort()) {
|
|
102
|
-
|
|
102
|
+
let msg;
|
|
103
|
+
let schema;
|
|
104
|
+
let schemaTypesParsed;
|
|
105
|
+
while ((msg = receiveMessageOnPort(port1))) {
|
|
106
|
+
;
|
|
107
|
+
[schema, schemaTypesParsed] = msg.message;
|
|
108
|
+
}
|
|
109
|
+
fromDbServer.schema = schema;
|
|
110
|
+
fromDbServer.schemaTypesParsed = schemaTypesParsed;
|
|
103
111
|
fromDbServer.dbCtxExternal = toCtx;
|
|
104
112
|
toDb.server.dbCtxExternal = fromCtx;
|
|
105
113
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isPropType, getPropType, } from '@based/schema';
|
|
2
2
|
import { setByPath } from '@saulx/utils';
|
|
3
3
|
import { hashObjectIgnoreKeyOrder } from '@saulx/hash';
|
|
4
|
-
import { SIZE_MAP, TYPE_INDEX_MAP, } from './types.js';
|
|
4
|
+
import { SIZE_MAP, TYPE_INDEX_MAP, STRING, ALIAS, CARDINALITY, } from './types.js';
|
|
5
5
|
import { genId } from './utils.js';
|
|
6
6
|
import { DEFAULT_BLOCK_CAPACITY } from '../start.js';
|
|
7
7
|
const addEdges = (prop, refProp) => {
|
|
@@ -95,9 +95,21 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
|
95
95
|
tree: {},
|
|
96
96
|
total: 0,
|
|
97
97
|
lastId: 0,
|
|
98
|
-
stringPropsSize: 0,
|
|
99
|
-
stringPropsLoop: [],
|
|
100
98
|
main: {},
|
|
99
|
+
hasSeperateSort: false,
|
|
100
|
+
seperateSort: {
|
|
101
|
+
size: 0,
|
|
102
|
+
props: [],
|
|
103
|
+
buffer: Buffer.allocUnsafe(0),
|
|
104
|
+
bufferTmp: Buffer.allocUnsafe(0),
|
|
105
|
+
},
|
|
106
|
+
hasSeperateTextSort: false,
|
|
107
|
+
seperateTextSort: {
|
|
108
|
+
size: 0,
|
|
109
|
+
props: [],
|
|
110
|
+
buffer: Buffer.allocUnsafe(0),
|
|
111
|
+
bufferTmp: Buffer.allocUnsafe(0),
|
|
112
|
+
},
|
|
101
113
|
}, path = [], top = true) => {
|
|
102
114
|
if (result.id == 0 && top) {
|
|
103
115
|
if ('id' in type) {
|
|
@@ -112,7 +124,8 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
|
112
124
|
result.idUint8[1] = result.id >> 8;
|
|
113
125
|
const encoder = new TextEncoder();
|
|
114
126
|
const target = type.props;
|
|
115
|
-
let
|
|
127
|
+
let separateSortProps = 0;
|
|
128
|
+
let separateSortText = 0;
|
|
116
129
|
for (const key in target) {
|
|
117
130
|
const schemaProp = target[key];
|
|
118
131
|
const propPath = [...path, key];
|
|
@@ -124,9 +137,7 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
|
124
137
|
let len = SIZE_MAP[propType];
|
|
125
138
|
if (isPropType('string', schemaProp) ||
|
|
126
139
|
isPropType('alias', schemaProp) ||
|
|
127
|
-
isPropType('
|
|
128
|
-
isPropType('cardinality', schemaProp) // TODO: maieutica
|
|
129
|
-
) {
|
|
140
|
+
isPropType('cardinality', schemaProp)) {
|
|
130
141
|
if (typeof schemaProp === 'object') {
|
|
131
142
|
if (schemaProp.maxBytes < 61) {
|
|
132
143
|
len = schemaProp.maxBytes + 1;
|
|
@@ -135,18 +146,13 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
|
135
146
|
len = schemaProp.max * 2 + 1;
|
|
136
147
|
}
|
|
137
148
|
else {
|
|
138
|
-
|
|
149
|
+
separateSortProps++;
|
|
139
150
|
}
|
|
140
151
|
}
|
|
141
152
|
else {
|
|
142
|
-
|
|
153
|
+
separateSortProps++;
|
|
143
154
|
}
|
|
144
155
|
}
|
|
145
|
-
else if (isPropType('text', schemaProp) ||
|
|
146
|
-
isPropType('cardinality', schemaProp)) {
|
|
147
|
-
// TODO: maieutica
|
|
148
|
-
stringFields++;
|
|
149
|
-
}
|
|
150
156
|
else if (isPropType('vector', schemaProp)) {
|
|
151
157
|
len = 4 * schemaProp.size;
|
|
152
158
|
}
|
|
@@ -290,27 +296,31 @@ export const createSchemaTypeDef = (typeName, type, parsed, locales, result = {
|
|
|
290
296
|
result.propNames.set(f, lastWritten + 1);
|
|
291
297
|
lastWritten += f.byteLength + 1;
|
|
292
298
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
result.hasStringProp = true;
|
|
299
|
+
if (separateSortProps > 0) {
|
|
300
|
+
result.hasSeperateSort = true;
|
|
296
301
|
let max = 0;
|
|
297
302
|
for (const f of result.separate) {
|
|
298
|
-
|
|
303
|
+
// Does not only need to be on string can also be HLL
|
|
304
|
+
if (f.typeIndex === STRING ||
|
|
305
|
+
f.typeIndex === ALIAS ||
|
|
306
|
+
f.typeIndex === CARDINALITY) {
|
|
299
307
|
if (f.prop > max) {
|
|
300
308
|
max = f.prop;
|
|
301
309
|
}
|
|
302
310
|
}
|
|
303
311
|
}
|
|
304
|
-
result.
|
|
312
|
+
result.seperateSort.buffer = Buffer.allocUnsafe(max + 1);
|
|
305
313
|
for (const f of result.separate) {
|
|
306
|
-
if (f.typeIndex ===
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
result.
|
|
314
|
+
if (f.typeIndex === STRING ||
|
|
315
|
+
f.typeIndex === ALIAS ||
|
|
316
|
+
f.typeIndex === CARDINALITY) {
|
|
317
|
+
result.seperateSort.buffer[f.prop] = 1;
|
|
318
|
+
result.seperateSort.props.push(f);
|
|
319
|
+
result.seperateSort.size++;
|
|
310
320
|
}
|
|
311
321
|
}
|
|
312
|
-
result.
|
|
313
|
-
result.
|
|
322
|
+
result.seperateSort.bufferTmp = Buffer.allocUnsafe(max + 1);
|
|
323
|
+
result.seperateSort.buffer.copy(result.seperateSort.bufferTmp);
|
|
314
324
|
}
|
|
315
325
|
for (const p in result.props) {
|
|
316
326
|
const x = result.props[p];
|
|
@@ -94,6 +94,12 @@ export type PropDefEdge = Partial<PropDef> & {
|
|
|
94
94
|
export type SchemaPropTree = {
|
|
95
95
|
[key: string]: SchemaPropTree | PropDef;
|
|
96
96
|
};
|
|
97
|
+
export type SchemaSortUndefinedHandler = {
|
|
98
|
+
size: number;
|
|
99
|
+
buffer: Buffer;
|
|
100
|
+
bufferTmp: Buffer;
|
|
101
|
+
props: PropDef[];
|
|
102
|
+
};
|
|
97
103
|
export type SchemaTypeDef = {
|
|
98
104
|
cnt: number;
|
|
99
105
|
checksum: number;
|
|
@@ -117,11 +123,10 @@ export type SchemaTypeDef = {
|
|
|
117
123
|
[start: string]: PropDef;
|
|
118
124
|
};
|
|
119
125
|
tree: SchemaPropTree;
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
stringPropsLoop: PropDef[];
|
|
126
|
+
hasSeperateSort: boolean;
|
|
127
|
+
seperateSort: SchemaSortUndefinedHandler;
|
|
128
|
+
hasSeperateTextSort: boolean;
|
|
129
|
+
seperateTextSort: SchemaSortUndefinedHandler;
|
|
125
130
|
createTs?: PropDef[];
|
|
126
131
|
updateTs?: PropDef[];
|
|
127
132
|
locales: Partial<SchemaLocales>;
|
|
@@ -4,7 +4,7 @@ export const TIMESTAMP = 1;
|
|
|
4
4
|
export const CREATED = 2;
|
|
5
5
|
export const UPDATED = 3;
|
|
6
6
|
export const NUMBER = 4;
|
|
7
|
-
export const CARDINALITY = 5;
|
|
7
|
+
export const CARDINALITY = 5;
|
|
8
8
|
export const INT8 = 20;
|
|
9
9
|
export const UINT8 = 6;
|
|
10
10
|
export const INT16 = 21;
|
|
@@ -2,5 +2,6 @@ import { DbClient } from '../../client/index.js';
|
|
|
2
2
|
import { DbServer } from '../index.js';
|
|
3
3
|
import { PropDef, PropDefEdge } from './types.js';
|
|
4
4
|
export declare const propIsSigned: (prop: PropDef | PropDefEdge) => boolean;
|
|
5
|
+
export declare const propIsNumerical: (prop: PropDef | PropDefEdge) => boolean;
|
|
5
6
|
export declare const genRootId: () => number;
|
|
6
7
|
export declare const genId: (db: DbServer | DbClient) => number;
|
|
@@ -1,9 +1,22 @@
|
|
|
1
|
-
import { INT16, INT32, INT64, INT8 } from './types.js';
|
|
1
|
+
import { INT16, INT32, INT64, INT8, UINT16, UINT32, UINT8, NUMBER, TIMESTAMP, } from './types.js';
|
|
2
2
|
export const propIsSigned = (prop) => {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
const t = prop.typeIndex;
|
|
4
|
+
if (t === INT16 || t === INT32 || t === INT64 || t === INT8) {
|
|
5
|
+
return true;
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
8
|
+
};
|
|
9
|
+
export const propIsNumerical = (prop) => {
|
|
10
|
+
const t = prop.typeIndex;
|
|
11
|
+
if (t === INT16 ||
|
|
12
|
+
t === INT32 ||
|
|
13
|
+
t === INT64 ||
|
|
14
|
+
t === INT8 ||
|
|
15
|
+
t === UINT8 ||
|
|
16
|
+
t === UINT16 ||
|
|
17
|
+
t === UINT32 ||
|
|
18
|
+
t === NUMBER ||
|
|
19
|
+
t === TIMESTAMP) {
|
|
7
20
|
return true;
|
|
8
21
|
}
|
|
9
22
|
return false;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@based/db",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.17",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/src/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"test": "npm run build && LOCPATH=../locale/locale-x86_64-gnu/locale lldb -b -o run --one-line-on-crash bt -o \"script import os; os._exit(0)\" node ./scripts/test.js",
|
|
18
18
|
"test-gdb": "npm run build && LOCPATH=../locale/locale-x86_64-gnu/locale gdb -ex run --args node ./scripts/test.js",
|
|
19
19
|
"test-fast": "LOCPATH=../locale/locale-x86_64-gnu/locale node ./scripts/test.js",
|
|
20
|
-
"test-zig": "npm run build-zig && tsc && npm run test-fast",
|
|
20
|
+
"test-zig": "npm run build-zig -- debug && tsc && npm run test-fast",
|
|
21
21
|
"test-ts": "tsc && node ./scripts/test.js",
|
|
22
22
|
"perf": "npm run build && node benchmarks/references.js && node benchmarks/transfermarkt/transfermarkt-based.js"
|
|
23
23
|
},
|
|
@@ -35,12 +35,14 @@
|
|
|
35
35
|
"@saulx/hash": "^3.0.0",
|
|
36
36
|
"@saulx/utils": "^4.3.2",
|
|
37
37
|
"exit-hook": "^4.0.0",
|
|
38
|
-
"picocolors": "^1.1.0"
|
|
38
|
+
"picocolors": "^1.1.0",
|
|
39
|
+
"@based/crc32c": "^1.0.0"
|
|
39
40
|
},
|
|
40
41
|
"optionalDependencies": {
|
|
41
42
|
"@based/locale-x86-64-gnu": "*"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
45
|
+
"@based/crc32c": "^1.0.0",
|
|
44
46
|
"@types/node": "^22.5.3",
|
|
45
47
|
"axios": "^1.7.9",
|
|
46
48
|
"rimraf": "^3.0.2",
|