@delali/narsil 0.2.4-next.50 → 0.2.4-next.52
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/README.md +27 -25
- package/dist/{capabilities-JrVQOwi4.d.ts → capabilities-CuTSXvbN.d.ts} +2 -2
- package/dist/{chunk-BEIK3EOZ.mjs → chunk-2FO7KZ6K.mjs} +5468 -3837
- package/dist/{chunk-XE6XR2OE.mjs → chunk-3GWP2TO6.mjs} +1 -1
- package/dist/{chunk-KMMJMDUA.mjs → chunk-3L4U6EJQ.mjs} +15 -10
- package/dist/{chunk-MHE7YWAU.mjs → chunk-72AXTIBW.mjs} +2 -2
- package/dist/{chunk-CV5H7XL7.mjs → chunk-EY2ULUMT.mjs} +30 -7
- package/dist/chunk-IFBKLBGB.mjs +7 -0
- package/dist/{chunk-WYJXSLER.mjs → chunk-POWOTUKJ.mjs} +7 -1
- package/dist/chunk-T62YOSGS.mjs +4280 -0
- package/dist/chunk-U36IDJN7.mjs +366 -0
- package/dist/{chunk-ND34I3SV.mjs → chunk-ULJ36FK4.mjs} +3502 -2383
- package/dist/{chunk-RP23PWMV.mjs → chunk-WFKIGEBY.mjs} +3 -3
- package/dist/{chunk-CMVG2UEF.mjs → chunk-WM7IS45M.mjs} +55 -517
- package/dist/chunk-Y3L5MDRV.mjs +96 -0
- package/dist/{chunk-ZHUQKZBE.mjs → chunk-YPYULM5E.mjs} +20 -4
- package/dist/chunk-ZJ4CSAB2.mjs +13 -0
- package/dist/chunk-ZT5BRDFW.mjs +513 -0
- package/dist/{client-CBOVHdjp.d.ts → client-BMJWVxOP.d.ts} +5 -5
- package/dist/client.d.ts +8 -8
- package/dist/{config-OON7IJ_B.d.ts → config-BcYZkdMw.d.ts} +2 -2
- package/dist/{config-Czh2YNDi.d.ts → config-qMLpi5T4.d.ts} +2 -2
- package/dist/direct-executor-UJC36S2D.mjs +12 -0
- package/dist/distribution/coordinator/etcd.d.ts +2 -2
- package/dist/distribution/coordinator/in-memory.d.ts +2 -2
- package/dist/distribution.d.ts +8 -8
- package/dist/distribution.mjs +30 -15
- package/dist/{engine-9PtFY50q.d.ts → engine-zhms1qId.d.ts} +2 -2
- package/dist/index.browser.mjs +12845 -7766
- package/dist/index.d.ts +9 -21
- package/dist/index.mjs +13 -12
- package/dist/{memory-Bzd5xcEW.d.ts → memory-OmgkX_Z2.d.ts} +11 -1
- package/dist/persistence/durability/checkpoint-worker.d.ts +138 -3
- package/dist/persistence/durability/checkpoint-worker.mjs +31 -17
- package/dist/react.d.ts +6 -6
- package/dist/{schema-BqRx9t4E.d.ts → schema-OSWaaZzx.d.ts} +30 -6
- package/dist/serialization/crc32-worker.mjs +2 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +80 -36
- package/dist/simd-DW5AtJ6B.d.ts +41 -0
- package/dist/{tasks-Bn4R1NPN.d.ts → tasks-DiF1c9v2.d.ts} +20 -1
- package/dist/{thread-PZLEO6JL.mjs → thread-TLCX43WV.mjs} +129 -41
- package/dist/{types-DXPxaXPO.d.ts → types-LEzMyjVX.d.ts} +1 -1
- package/dist/vector/search-worker.d.ts +292 -128
- package/dist/vector/search-worker.mjs +70 -54
- package/dist/workers/entry.mjs +10 -7
- package/package.json +52 -31
- package/dist/brute-force-DbHYCTc3.d.ts +0 -8
- package/dist/chunk-CBLS46IE.mjs +0 -10
- package/dist/chunk-PIWKZPP7.mjs +0 -64
- package/dist/chunk-PMBHH44R.mjs +0 -492
- package/dist/chunk-X6YZO4MQ.mjs +0 -1572
- package/dist/direct-executor-OREXU72C.mjs +0 -12
- package/dist/vector/hnsw-build-worker.d.ts +0 -105
- package/dist/vector/hnsw-build-worker.mjs +0 -123
|
@@ -1,5 +1,12 @@
|
|
|
1
|
+
import { NATIVE_CRC32_MIN_BYTES } from './chunk-IFBKLBGB.mjs';
|
|
2
|
+
import * as zlib from 'zlib';
|
|
3
|
+
|
|
4
|
+
var candidate = zlib.crc32;
|
|
5
|
+
var nativeCrc32 = typeof candidate === "function" ? candidate : null;
|
|
6
|
+
|
|
1
7
|
// src/serialization/crc32.ts
|
|
2
8
|
var IEEE_POLYNOMIAL = 3988292384;
|
|
9
|
+
var ALL_BITS = 4294967295;
|
|
3
10
|
var cachedTable = null;
|
|
4
11
|
function buildTable() {
|
|
5
12
|
const table = new Uint32Array(256);
|
|
@@ -18,18 +25,16 @@ function getTable() {
|
|
|
18
25
|
}
|
|
19
26
|
return cachedTable;
|
|
20
27
|
}
|
|
21
|
-
function
|
|
22
|
-
|
|
23
|
-
let crc = 4294967295;
|
|
24
|
-
for (let i = 0; i < data.length; i++) {
|
|
25
|
-
crc = crc >>> 8 ^ table[(crc ^ data[i]) & 255];
|
|
26
|
-
}
|
|
27
|
-
return (crc ^ 4294967295) >>> 0;
|
|
28
|
+
function crc322(data) {
|
|
29
|
+
return crc32Final(crc32Update(crc32Init(), data));
|
|
28
30
|
}
|
|
29
31
|
function crc32Init() {
|
|
30
|
-
return
|
|
32
|
+
return ALL_BITS;
|
|
31
33
|
}
|
|
32
34
|
function crc32Update(state, data) {
|
|
35
|
+
if (nativeCrc32 !== null && data.length >= NATIVE_CRC32_MIN_BYTES) {
|
|
36
|
+
return nativeCrc32(data, (state ^ ALL_BITS) >>> 0) ^ ALL_BITS;
|
|
37
|
+
}
|
|
33
38
|
const table = getTable();
|
|
34
39
|
let crc = state;
|
|
35
40
|
for (let i = 0; i < data.length; i++) {
|
|
@@ -38,7 +43,7 @@ function crc32Update(state, data) {
|
|
|
38
43
|
return crc;
|
|
39
44
|
}
|
|
40
45
|
function crc32Final(state) {
|
|
41
|
-
return (state ^
|
|
46
|
+
return (state ^ ALL_BITS) >>> 0;
|
|
42
47
|
}
|
|
43
48
|
|
|
44
|
-
export { crc32, crc32Final, crc32Init, crc32Update };
|
|
49
|
+
export { crc322 as crc32, crc32Final, crc32Init, crc32Update, nativeCrc32 };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-
|
|
2
|
-
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-
|
|
1
|
+
import { MAX_PARTITION_COUNT, MAX_REPLICATION_FACTOR } from './chunk-U36IDJN7.mjs';
|
|
2
|
+
import { MAX_INDEX_NAME_LENGTH, INDEX_NAME_PATTERN } from './chunk-3GWP2TO6.mjs';
|
|
3
3
|
import { NarsilError, ErrorCodes } from './chunk-P4ELXVJQ.mjs';
|
|
4
4
|
import { encode, decode } from '@msgpack/msgpack';
|
|
5
5
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MAX_SORT_FIELDS } from './chunk-
|
|
1
|
+
import { MAX_SORT_FIELDS } from './chunk-ZT5BRDFW.mjs';
|
|
2
2
|
import { ServerErrorCodes, NarsilError, ErrorCodes } from './chunk-P4ELXVJQ.mjs';
|
|
3
3
|
|
|
4
4
|
// src/server/capabilities.ts
|
|
@@ -217,6 +217,7 @@ var DEFAULT_MAX_BODY_BYTES = 16 * BYTES_PER_MB;
|
|
|
217
217
|
var DEFAULT_MAX_IMPORT_BYTES = 100 * BYTES_PER_MB;
|
|
218
218
|
var DEFAULT_MAX_LINE_BYTES = 4 * BYTES_PER_MB;
|
|
219
219
|
var DEFAULT_IMPORT_BATCH_SIZE = 1e3;
|
|
220
|
+
var IMPORT_FLUSHES_IN_FLIGHT = 4;
|
|
220
221
|
var DEFAULT_MAX_CONCURRENT_REQUESTS = 0;
|
|
221
222
|
var DEFAULT_MAX_RESULT_WINDOW = 1e4;
|
|
222
223
|
var DEFAULT_MAX_FETCH_DOCUMENTS = 1e4;
|
|
@@ -620,7 +621,22 @@ function initAbortHandler(res) {
|
|
|
620
621
|
}
|
|
621
622
|
};
|
|
622
623
|
}
|
|
623
|
-
function
|
|
624
|
+
function declaredBodyBytes(header) {
|
|
625
|
+
return /^\d{1,15}$/.test(header) ? Number(header) : null;
|
|
626
|
+
}
|
|
627
|
+
function bodyWithRoomFor(body, filled, needed, maxBytes) {
|
|
628
|
+
if (needed <= body.length) return body;
|
|
629
|
+
const grown = Buffer.allocUnsafeSlow(Math.min(maxBytes, Math.max(needed, body.length * 2)));
|
|
630
|
+
grown.set(body.subarray(0, filled));
|
|
631
|
+
return grown;
|
|
632
|
+
}
|
|
633
|
+
function bodyOfExactly(body, filled) {
|
|
634
|
+
if (filled === body.length) return body;
|
|
635
|
+
const exact = Buffer.allocUnsafeSlow(filled);
|
|
636
|
+
exact.set(body.subarray(0, filled));
|
|
637
|
+
return exact;
|
|
638
|
+
}
|
|
639
|
+
function readBody(res, maxBytes, abort, declaredBytes = null) {
|
|
624
640
|
return new Promise((resolve, reject) => {
|
|
625
641
|
if (abort.aborted) {
|
|
626
642
|
reject(new Error("aborted"));
|
|
@@ -628,7 +644,9 @@ function readBody(res, maxBytes, abort) {
|
|
|
628
644
|
}
|
|
629
645
|
let done = false;
|
|
630
646
|
let total = 0;
|
|
631
|
-
|
|
647
|
+
let filled = 0;
|
|
648
|
+
let body = null;
|
|
649
|
+
const reserved = declaredBytes !== null && declaredBytes <= maxBytes ? declaredBytes : 0;
|
|
632
650
|
abort.onAbort(() => {
|
|
633
651
|
if (done) return;
|
|
634
652
|
done = true;
|
|
@@ -645,10 +663,14 @@ function readBody(res, maxBytes, abort) {
|
|
|
645
663
|
reject(new Error("payload too large"));
|
|
646
664
|
return;
|
|
647
665
|
}
|
|
648
|
-
|
|
666
|
+
const arrived = new Uint8Array(chunk);
|
|
667
|
+
const firstSize = isLast ? arrived.length : Math.max(reserved, arrived.length);
|
|
668
|
+
body = bodyWithRoomFor(body ?? Buffer.allocUnsafeSlow(firstSize), filled, total, maxBytes);
|
|
669
|
+
body.set(arrived, filled);
|
|
670
|
+
filled = total;
|
|
649
671
|
if (isLast) {
|
|
650
672
|
done = true;
|
|
651
|
-
resolve(
|
|
673
|
+
resolve(bodyOfExactly(body, filled));
|
|
652
674
|
}
|
|
653
675
|
});
|
|
654
676
|
});
|
|
@@ -703,6 +725,7 @@ function createRouteRunner(deps) {
|
|
|
703
725
|
}
|
|
704
726
|
const query = new URLSearchParams(req.getQuery() ?? "");
|
|
705
727
|
const contentType = req.getHeader("content-type");
|
|
728
|
+
const declaredBytes = needsBody ? declaredBodyBytes(req.getHeader("content-length")) : null;
|
|
706
729
|
let hookContext = null;
|
|
707
730
|
if (useHook) {
|
|
708
731
|
const headers = {};
|
|
@@ -728,7 +751,7 @@ function createRouteRunner(deps) {
|
|
|
728
751
|
);
|
|
729
752
|
return;
|
|
730
753
|
}
|
|
731
|
-
const bodyPromise = needsBody ? readBody(res, opts.maxBytes, abort) : Promise.resolve(null);
|
|
754
|
+
const bodyPromise = needsBody ? readBody(res, opts.maxBytes, abort, declaredBytes) : Promise.resolve(null);
|
|
732
755
|
const hookPromise = hookContext !== null && authorize !== void 0 ? authorize(hookContext) : Promise.resolve({ allowed: true });
|
|
733
756
|
Promise.all([bodyPromise, hookPromise]).then(async ([rawBody, authorization]) => {
|
|
734
757
|
if (abort.aborted) return;
|
|
@@ -873,4 +896,4 @@ function childAppOf(app) {
|
|
|
873
896
|
return candidate;
|
|
874
897
|
}
|
|
875
898
|
|
|
876
|
-
export { ASYNC_IMPORT_CAPABILITY, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_RETAINED_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_TASK_PAGE_SIZE, INDEX_LIFECYCLE_CAPABILITY, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, MAIN_THREAD_GATE_SLOT, MAX_INDEX_TOUCH_INTERVAL_MS, REBUILD_ANALYSIS_CAPABILITY, RUNNING_TASK_TTL_MS, SERVER_CAPABILITIES, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, TASK_PROGRESS_WRITE_INTERVAL_MS, TERMINAL_TASK_TTL_MS, acceptorOf, authorizerFor, badRequest, childAppOf, clearGateSlot, corsWriter, createDocumentReadHandlers, createRouteRunner, createSharedGateBuffer, createSharedRequestGate, gateSlotOfWorker, httpStatusForNarsilError, loadUWebSockets, parseJson, parseJsonOptional, parseTaskListQuery, registerServerRoutes, rejectInvalid, resolveCors, respondError, respondJson, sendBinary, sendError, sendRelayed, serializeBatchResult, serializeNarsilError, serverRoutes, validateBatch, validateCreateIndex, validateDocumentBody, validateQuery, validateRebalance, validateSuggest };
|
|
899
|
+
export { ASYNC_IMPORT_CAPABILITY, DEFAULT_IMPORT_BATCH_SIZE, DEFAULT_MAX_BODY_BYTES, DEFAULT_MAX_CONCURRENT_REQUESTS, DEFAULT_MAX_CONCURRENT_TASKS, DEFAULT_MAX_FETCH_DOCUMENTS, DEFAULT_MAX_IMPORT_BYTES, DEFAULT_MAX_IMPORT_ERRORS, DEFAULT_MAX_LINE_BYTES, DEFAULT_MAX_RESULT_WINDOW, DEFAULT_MAX_RETAINED_TASKS, DEFAULT_MAX_TASK_PAGE_SIZE, DEFAULT_TASK_PAGE_SIZE, IMPORT_FLUSHES_IN_FLIGHT, INDEX_LIFECYCLE_CAPABILITY, INDEX_TOUCH_INTERVALS_PER_IDLE_TIMEOUT, MAIN_THREAD_GATE_SLOT, MAX_INDEX_TOUCH_INTERVAL_MS, REBUILD_ANALYSIS_CAPABILITY, RUNNING_TASK_TTL_MS, SERVER_CAPABILITIES, TASK_CANCEL_CAPABILITY, TASK_FILTER_CAPABILITY, TASK_PROGRESS_WRITE_INTERVAL_MS, TERMINAL_TASK_TTL_MS, acceptorOf, authorizerFor, badRequest, childAppOf, clearGateSlot, corsWriter, createDocumentReadHandlers, createRouteRunner, createSharedGateBuffer, createSharedRequestGate, gateSlotOfWorker, httpStatusForNarsilError, loadUWebSockets, parseJson, parseJsonOptional, parseTaskListQuery, registerServerRoutes, rejectInvalid, resolveCors, respondError, respondJson, sendBinary, sendError, sendRelayed, serializeBatchResult, serializeNarsilError, serverRoutes, validateBatch, validateCreateIndex, validateDocumentBody, validateQuery, validateRebalance, validateSuggest };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// src/serialization/constants.ts
|
|
2
|
+
var CHECKSUM_TIMEOUT_MS = 12e4;
|
|
3
|
+
var CHECKSUM_YIELD_CHUNK_BYTES = 4 * 1024 * 1024;
|
|
4
|
+
var NATIVE_CRC32_MIN_BYTES = 16;
|
|
5
|
+
var VALID_HNSW_METRICS = /* @__PURE__ */ new Set(["cosine", "dotProduct", "euclidean"]);
|
|
6
|
+
|
|
7
|
+
export { CHECKSUM_TIMEOUT_MS, CHECKSUM_YIELD_CHUNK_BYTES, NATIVE_CRC32_MIN_BYTES, VALID_HNSW_METRICS };
|
|
@@ -11,6 +11,7 @@ var KNOWN_ACTION_TYPES = [
|
|
|
11
11
|
"createIndex",
|
|
12
12
|
"loadVectorCopy",
|
|
13
13
|
"dropVectorCopy",
|
|
14
|
+
"insertVectorOrdinals",
|
|
14
15
|
"serveRequests",
|
|
15
16
|
"stopServing",
|
|
16
17
|
"dropIndex",
|
|
@@ -57,4 +58,9 @@ function isValidWorkerResponse(msg) {
|
|
|
57
58
|
return true;
|
|
58
59
|
}
|
|
59
60
|
|
|
60
|
-
|
|
61
|
+
// src/workers/thread-slot.ts
|
|
62
|
+
function threadSlotOfWorker(workerId) {
|
|
63
|
+
return workerId + 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export { createRequestId, isValidWorkerAction, isValidWorkerResponse, threadSlotOfWorker };
|