@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,4 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { d as VectorQuantizationMode } from '../schema-OSWaaZzx.js';
|
|
2
|
+
import { A as ArenaSimd } from '../simd-DW5AtJ6B.js';
|
|
3
|
+
import '../adapters-79OIa4xm.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Similarity metric a vector search ranks by.
|
|
7
|
+
*
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
10
|
+
type VectorMetric = 'cosine' | 'dotProduct' | 'euclidean';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Each dimension of a document code holds this many bits.
|
|
14
|
+
*
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
type OsqBits = 1 | 2 | 4 | 8;
|
|
2
18
|
|
|
3
19
|
/**
|
|
4
20
|
* A filter over store ordinals, one bit per ordinal, with the number of set
|
|
@@ -18,74 +34,199 @@ interface OrdinalFilter {
|
|
|
18
34
|
}
|
|
19
35
|
|
|
20
36
|
/**
|
|
21
|
-
*
|
|
37
|
+
* This buffer grows in place, so a typed array built over it without an
|
|
38
|
+
* explicit length reports the new length after every growth, on every thread
|
|
39
|
+
* that holds it.
|
|
22
40
|
*
|
|
23
41
|
* @internal
|
|
24
42
|
*/
|
|
25
|
-
|
|
26
|
-
|
|
43
|
+
type GrowableBuffer = SharedArrayBuffer | ArrayBuffer;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* This geometry gives the byte offset of every region inside one block. A
|
|
47
|
+
* block begins with one query scratch for each thread slot, and the slots
|
|
48
|
+
* follow them, each holding one record of a fixed stride.
|
|
49
|
+
*
|
|
50
|
+
* @internal
|
|
51
|
+
*/
|
|
52
|
+
interface BlockGeometry {
|
|
53
|
+
/** Each thread's query scratch spans this many bytes. */
|
|
54
|
+
scratchStride: number;
|
|
55
|
+
/** The slots start at this byte offset. */
|
|
56
|
+
slotsOffset: number;
|
|
57
|
+
/** Each slot spans this many bytes. */
|
|
58
|
+
slotStride: number;
|
|
59
|
+
/** The block holds this many slots at most. */
|
|
60
|
+
capacity: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* This is the geometry of a block holding float32 vectors, one per slot.
|
|
64
|
+
*
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
interface VectorBlockLayout extends BlockGeometry {
|
|
68
|
+
/** Every vector of the field has this many components. */
|
|
27
69
|
dimension: number;
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* One block keeps its bytes in a shared WebAssembly memory that every thread
|
|
73
|
+
* binds the distance kernels to, in a private WebAssembly memory where the
|
|
74
|
+
* runtime shares no memory, or in plain bytes where the runtime offers no
|
|
75
|
+
* WebAssembly.
|
|
76
|
+
*
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
type VectorBlockStorage = {
|
|
80
|
+
kind: 'shared-memory';
|
|
81
|
+
memory: WebAssembly.Memory;
|
|
82
|
+
} | {
|
|
83
|
+
kind: 'private-memory';
|
|
84
|
+
simd: ArenaSimd;
|
|
85
|
+
} | {
|
|
86
|
+
kind: 'bytes';
|
|
87
|
+
buffer: GrowableBuffer;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* This handle names one block of a field, which every thread holding the
|
|
91
|
+
* field opens on its own side.
|
|
92
|
+
*
|
|
93
|
+
* @internal
|
|
94
|
+
*/
|
|
95
|
+
interface VectorBlockHandle<Layout extends BlockGeometry = BlockGeometry> {
|
|
96
|
+
/** The block follows this layout. */
|
|
97
|
+
layout: Layout;
|
|
98
|
+
/** The block keeps its bytes here. */
|
|
99
|
+
storage: VectorBlockStorage;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* This is the geometry of a block holding one code record per slot: the packed code
|
|
104
|
+
* with its lower, upper, correction, and sum inline, so a comparison reads
|
|
105
|
+
* one contiguous record. Each thread's scratch holds one staged query.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
interface VectorCodeBlockLayout extends BlockGeometry {
|
|
110
|
+
/** Every vector of the field has this many components. */
|
|
111
|
+
dimension: number;
|
|
112
|
+
/** Each level of a document code holds this many bits. */
|
|
113
|
+
bits: OsqBits;
|
|
114
|
+
/** Each level of a query code holds this many bits. */
|
|
115
|
+
queryBits: OsqBits;
|
|
116
|
+
/** A packed document code spans this many bytes. */
|
|
117
|
+
codeBytes: number;
|
|
118
|
+
/** A staged query spans this many bytes. */
|
|
119
|
+
queryBytes: number;
|
|
36
120
|
}
|
|
37
121
|
|
|
38
122
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
123
|
+
* A thread opens these handles so that it can read one field's vectors,
|
|
124
|
+
* codes, and document ids in place. They name the blocks holding the vectors,
|
|
125
|
+
* the blocks holding the code records, the side tables that hold one entry
|
|
126
|
+
* per ordinal, and the checkpoint files that hold the vectors of the
|
|
127
|
+
* ordinals a field on disk has released from memory.
|
|
41
128
|
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* thread
|
|
129
|
+
* The main thread appends ordinals, and because the tables grow in place, a
|
|
130
|
+
* thread that opened the handles once goes on reading the current state.
|
|
131
|
+
* Adding a block, releasing one, or adding a file is a structural change, so
|
|
132
|
+
* the main thread bumps the layout revision and sends the handles again.
|
|
46
133
|
*
|
|
47
134
|
* @internal
|
|
48
135
|
*/
|
|
49
|
-
interface
|
|
50
|
-
/**
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
|
|
136
|
+
interface SharedVectorStoreHandles {
|
|
137
|
+
/** Every vector of the field has this many components. */
|
|
138
|
+
dimension: number;
|
|
139
|
+
/** Each level of a document code holds this many bits, and null where the field keeps no codes. */
|
|
140
|
+
codeBits: OsqBits | null;
|
|
141
|
+
/** Every float block of the field follows this layout. */
|
|
142
|
+
layout: VectorBlockLayout;
|
|
143
|
+
/** Every code block of the field follows this layout, and null where the field keeps no codes. */
|
|
144
|
+
codeLayout: VectorCodeBlockLayout | null;
|
|
145
|
+
/** The main thread raises this on every structural change, so a thread compares it against what it opened. */
|
|
146
|
+
layoutRevision: number;
|
|
147
|
+
/** Every thread reads these counters through atomics. */
|
|
148
|
+
header: Int32Array;
|
|
149
|
+
/** These blocks hold the vectors, in ordinal order, with null where the store released a block to disk or never filled it. */
|
|
150
|
+
blocks: Array<VectorBlockHandle<VectorBlockLayout> | null>;
|
|
151
|
+
/** These blocks hold the code records, in ordinal order. */
|
|
152
|
+
codeBlocks: VectorBlockHandle<VectorCodeBlockLayout>[];
|
|
153
|
+
/** These are the paths of the checkpoint files holding vectors, with an empty string where no ordinal reads a file any more. */
|
|
154
|
+
vectorFiles: string[];
|
|
155
|
+
/** This holds each ordinal's vector magnitude. */
|
|
156
|
+
magnitudes: GrowableBuffer;
|
|
157
|
+
/** This holds one byte per ordinal, which reads 1 where the ordinal holds a live vector. */
|
|
158
|
+
present: GrowableBuffer;
|
|
159
|
+
/** This holds each ordinal's partition, or a negative marker where the store knows none. */
|
|
160
|
+
partitions: GrowableBuffer;
|
|
161
|
+
/** This holds every document id, UTF-8 encoded end to end in ordinal order. */
|
|
162
|
+
docIdBytes: GrowableBuffer;
|
|
163
|
+
/** This holds the byte each ordinal's id starts at, with one closing offset after the last. */
|
|
164
|
+
docIdOffsets: GrowableBuffer;
|
|
165
|
+
/** This holds one byte per ordinal, which reads 1 where the ordinal holds a code record. */
|
|
166
|
+
codePresent: GrowableBuffer;
|
|
167
|
+
/** This holds the index into `vectorFiles` of the file holding each ordinal's vector, or -1 where a block holds it. */
|
|
168
|
+
diskFile: GrowableBuffer;
|
|
169
|
+
/** This holds the byte offset of each ordinal's vector inside its file. */
|
|
170
|
+
diskOffset: GrowableBuffer;
|
|
171
|
+
/** This holds the centroid the quantizer takes every code against. */
|
|
172
|
+
centroid: Float32Array;
|
|
54
173
|
}
|
|
55
174
|
|
|
56
175
|
/**
|
|
57
|
-
*
|
|
176
|
+
* The engine clones a field's vectors to another thread in this form, which
|
|
177
|
+
* it uses where the runtime shares no memory between threads.
|
|
58
178
|
*
|
|
59
179
|
* @internal
|
|
60
180
|
*/
|
|
61
|
-
interface
|
|
62
|
-
/**
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
mMax0: number;
|
|
66
|
-
/** The arrays span this many ordinals. */
|
|
67
|
-
capacity: number;
|
|
68
|
-
/** No node sits at an ordinal at or above this. */
|
|
181
|
+
interface VectorStoreSnapshot {
|
|
182
|
+
/** Every vector of the field has this many components. */
|
|
183
|
+
dimension: number;
|
|
184
|
+
/** The store spans this many ordinals, deleted ones included. */
|
|
69
185
|
slots: number;
|
|
70
|
-
/**
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
186
|
+
/** This holds every vector end to end, `slots * dimension` components long. */
|
|
187
|
+
vectors: Float32Array;
|
|
188
|
+
/** This holds each ordinal's vector length, so a reader takes it from here. */
|
|
189
|
+
magnitudes: Float64Array;
|
|
190
|
+
/** This names the document at each ordinal, and it reads `null` where the ordinal holds none. */
|
|
191
|
+
docIds: Array<string | null>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* A thread opens these handles so that it can search or extend one graph in
|
|
196
|
+
* place. They name the counters every thread reads through atomics, the
|
|
197
|
+
* adjacency arrays that grow without moving, the lock word of every node, and
|
|
198
|
+
* the record of the locks each thread holds, which the main thread reads to
|
|
199
|
+
* release what a dead thread left behind.
|
|
200
|
+
*
|
|
201
|
+
* @internal
|
|
202
|
+
*/
|
|
203
|
+
interface SharedGraphHandles {
|
|
204
|
+
/** This holds the entry point, the layer count, the node counts, the arena cursor, and the graph's shape. */
|
|
205
|
+
header: Int32Array;
|
|
206
|
+
/** This holds each ordinal's top layer plus one, and it reads zero where the graph holds no node there. */
|
|
207
|
+
nodeLevels: GrowableBuffer;
|
|
208
|
+
/** This holds the base layer's neighbours, a count followed by that many neighbours for each ordinal. */
|
|
209
|
+
level0: GrowableBuffer;
|
|
210
|
+
/** This holds where each ordinal's upper layers start plus one, and it reads zero where the ordinal reaches none. */
|
|
211
|
+
upperBase: GrowableBuffer;
|
|
212
|
+
/** This holds every upper layer's neighbours, a count followed by that many neighbours for each layer. */
|
|
213
|
+
upper: GrowableBuffer;
|
|
214
|
+
/** This holds one lock word per ordinal. */
|
|
215
|
+
locks: GrowableBuffer;
|
|
216
|
+
/** This holds one byte per ordinal, which reads 1 once a caller removes the document. */
|
|
217
|
+
tombstones: GrowableBuffer;
|
|
218
|
+
/** This records the node lock and the graph lock each thread slot holds right now. */
|
|
219
|
+
heldLocks: Int32Array;
|
|
80
220
|
}
|
|
81
221
|
|
|
82
222
|
/**
|
|
83
|
-
*
|
|
223
|
+
* This holds a built graph copied out flat, which the engine sends to another
|
|
224
|
+
* thread where the runtime shares no memory.
|
|
84
225
|
*
|
|
85
226
|
* @internal
|
|
86
227
|
*/
|
|
87
228
|
interface HNSWSnapshot {
|
|
88
|
-
/**
|
|
229
|
+
/** Every vector of the field has this many components. */
|
|
89
230
|
dimension: number;
|
|
90
231
|
/** Each node keeps this many neighbours per layer. */
|
|
91
232
|
m: number;
|
|
@@ -93,16 +234,24 @@ interface HNSWSnapshot {
|
|
|
93
234
|
efConstruction: number;
|
|
94
235
|
/** The graph ranks by this metric. */
|
|
95
236
|
metric: VectorMetric;
|
|
96
|
-
/**
|
|
97
|
-
|
|
98
|
-
/**
|
|
237
|
+
/** Every node of the graph lies below this ordinal. */
|
|
238
|
+
slots: number;
|
|
239
|
+
/** The upper-layer arena holds this many entries in use. */
|
|
240
|
+
upperUsed: number;
|
|
241
|
+
/** This holds each ordinal's top layer plus one, and it reads zero where the graph holds no node there. */
|
|
242
|
+
nodeLevels: Uint8Array;
|
|
243
|
+
/** This holds the base layer's neighbours, a count followed by that many neighbours for each ordinal. */
|
|
244
|
+
level0: Int32Array;
|
|
245
|
+
/** This holds where each ordinal's upper layers start plus one, and it reads zero where the ordinal reaches none. */
|
|
246
|
+
upperBase: Int32Array;
|
|
247
|
+
/** This holds every upper layer's neighbours, a count followed by that many neighbours for each layer. */
|
|
248
|
+
upper: Int32Array;
|
|
249
|
+
/** This holds one byte per ordinal, which reads 1 once a caller removes the document. */
|
|
99
250
|
tombstones: Uint8Array;
|
|
100
|
-
/**
|
|
251
|
+
/** The graph holds this many tombstoned ordinals. */
|
|
101
252
|
tombstoneCount: number;
|
|
102
253
|
/** The graph holds this many nodes, tombstoned ones included. */
|
|
103
254
|
nodeCount: number;
|
|
104
|
-
/** The graph's own arrays span this many ordinals. */
|
|
105
|
-
capacity: number;
|
|
106
255
|
/** Every search starts at this ordinal, and it is -1 while the graph is empty. */
|
|
107
256
|
entryPointOrd: number;
|
|
108
257
|
/** The graph reaches this many layers. */
|
|
@@ -110,93 +259,76 @@ interface HNSWSnapshot {
|
|
|
110
259
|
}
|
|
111
260
|
|
|
112
261
|
/**
|
|
113
|
-
*
|
|
262
|
+
* A thread opens these handles so that it can search one vector field in
|
|
263
|
+
* place and place vectors in its graph, and they name the store's shared
|
|
264
|
+
* structures alongside the graph's.
|
|
114
265
|
*
|
|
115
|
-
* The
|
|
116
|
-
*
|
|
117
|
-
*
|
|
266
|
+
* The main thread sends them once, and again only when a block joins the
|
|
267
|
+
* store or a fresh graph replaces the old one, because every other change
|
|
268
|
+
* grows the shared buffers in place.
|
|
118
269
|
*
|
|
119
270
|
* @internal
|
|
120
271
|
*/
|
|
121
|
-
interface
|
|
122
|
-
/**
|
|
272
|
+
interface SharedVectorFieldHandles {
|
|
273
|
+
/** Every vector of the field has this many components. */
|
|
123
274
|
dimension: number;
|
|
124
|
-
/** The
|
|
125
|
-
|
|
126
|
-
/** The
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
|
|
136
|
-
/** The quantised code arena starts at this byte offset. */
|
|
137
|
-
codesOffset: number;
|
|
138
|
-
/** The memory spans this many bytes, a whole number of pages. */
|
|
139
|
-
totalBytes: number;
|
|
275
|
+
/** The threads estimate distances from code records under any mode but `none`. */
|
|
276
|
+
quantization: VectorQuantizationMode;
|
|
277
|
+
/** The quantizer takes the codes under this metric, which the graph also ranks by. */
|
|
278
|
+
metric: VectorMetric;
|
|
279
|
+
/** These are the store's shared structures. */
|
|
280
|
+
store: SharedVectorStoreHandles;
|
|
281
|
+
/** These are the graph's shared structures, and they read null while the field answers by exact comparison. */
|
|
282
|
+
graph: SharedGraphHandles | null;
|
|
283
|
+
/** A thread answers by exact comparison where a filter admits a smaller share of the live vectors than this. */
|
|
284
|
+
filterThreshold: number;
|
|
285
|
+
/** This reads true where searches on the thread answer from the graph, and false while the threads build it. */
|
|
286
|
+
searchable: boolean;
|
|
140
287
|
}
|
|
141
288
|
/**
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
* The typed arrays are views over shared buffers, so posting this to a worker
|
|
145
|
-
* hands over the same bytes rather than a copy, and nothing in it is written
|
|
146
|
-
* after the freeze apart from the per-worker scratch slots inside `memory`.
|
|
289
|
+
* A thread reports this after placing a batch of vectors in a graph.
|
|
147
290
|
*
|
|
148
291
|
* @internal
|
|
149
292
|
*/
|
|
150
|
-
interface
|
|
151
|
-
/**
|
|
152
|
-
|
|
153
|
-
/** The workers compute quantised distances when this reads `sq8`. */
|
|
154
|
-
quantization: 'sq8' | 'none';
|
|
155
|
-
/** The constants every code was derived with, present when quantised. */
|
|
156
|
-
calibration: ScalarQuantizerCalibration | null;
|
|
157
|
-
/** The shared memory holding the scratch slots and both arenas. */
|
|
158
|
-
memory: WebAssembly.Memory;
|
|
159
|
-
/** Where each region sits inside the shared memory. */
|
|
160
|
-
layout: SharedGenerationLayout;
|
|
161
|
-
/** Each ordinal's vector magnitude. */
|
|
162
|
-
magnitudes: Float64Array;
|
|
163
|
-
/** Each ordinal's code sum, present when quantised. */
|
|
164
|
-
codeSums: Float64Array;
|
|
165
|
-
/** Each ordinal's reconstructed code magnitude, present when quantised. */
|
|
166
|
-
codeMagnitudes: Float64Array;
|
|
167
|
-
/** A byte per ordinal, 1 where codes exist, present when quantised. */
|
|
168
|
-
codePresent: Uint8Array;
|
|
169
|
-
/** The built graph, its arrays backed by shared buffers. */
|
|
170
|
-
graph: HNSWSnapshot;
|
|
171
|
-
/**
|
|
172
|
-
* Each ordinal's document id rank in code point order, or
|
|
173
|
-
* the absent-document rank where the ordinal holds no document.
|
|
174
|
-
*/
|
|
175
|
-
rankByOrdinal: Uint32Array;
|
|
293
|
+
interface GraphInsertOutcome {
|
|
294
|
+
/** The thread placed this many vectors the graph did not hold before. */
|
|
295
|
+
placed: number;
|
|
176
296
|
}
|
|
177
297
|
|
|
178
298
|
/**
|
|
179
|
-
*
|
|
180
|
-
* worker
|
|
299
|
+
* The code records of one field copied out flat, which the engine sends to
|
|
300
|
+
* a worker that shares no memory with it.
|
|
301
|
+
*
|
|
302
|
+
* @internal
|
|
303
|
+
*/
|
|
304
|
+
interface WorkerCopyCodes {
|
|
305
|
+
/** The centroid the quantizer takes every record against. */
|
|
306
|
+
centroid: Float32Array;
|
|
307
|
+
/** This holds one record per ordinal, end to end. */
|
|
308
|
+
records: Uint8Array;
|
|
309
|
+
/** This holds one byte per ordinal, which reads 1 where the ordinal holds a record. */
|
|
310
|
+
present: Uint8Array;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The engine clones one vector field's searchable state to a worker in this
|
|
314
|
+
* form, which it uses where the runtime shares no memory.
|
|
181
315
|
*
|
|
182
316
|
* @internal
|
|
183
317
|
*/
|
|
184
318
|
interface WorkerCopySnapshot {
|
|
185
|
-
/**
|
|
319
|
+
/** Every vector of the field has this many components. */
|
|
186
320
|
dimension: number;
|
|
187
|
-
/** The worker
|
|
188
|
-
quantization:
|
|
189
|
-
/**
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
*/
|
|
194
|
-
calibration: ScalarQuantizerCalibration | null;
|
|
321
|
+
/** The worker estimates from code records under any mode but `none`. */
|
|
322
|
+
quantization: VectorQuantizationMode;
|
|
323
|
+
/** The quantizer takes the codes under this metric. */
|
|
324
|
+
metric: VectorMetric;
|
|
325
|
+
/** The records the calling thread wrote, so the worker rewrites none, or null where the field holds no codes. */
|
|
326
|
+
codes: WorkerCopyCodes | null;
|
|
195
327
|
/** This holds every vector and the document id at each ordinal. */
|
|
196
328
|
store: VectorStoreSnapshot;
|
|
197
329
|
/** This holds the built graph. */
|
|
198
330
|
graph: HNSWSnapshot;
|
|
199
|
-
/**
|
|
331
|
+
/** The worker leaves these deleted documents out of every result. */
|
|
200
332
|
tombstones: string[];
|
|
201
333
|
}
|
|
202
334
|
|
|
@@ -220,21 +352,21 @@ interface VectorLoadRequest {
|
|
|
220
352
|
snapshot: WorkerCopySnapshot;
|
|
221
353
|
}
|
|
222
354
|
/**
|
|
223
|
-
* Asks the search worker to open a
|
|
355
|
+
* Asks the search worker to open a field in place under a handle.
|
|
224
356
|
*
|
|
225
357
|
* @internal
|
|
226
358
|
*/
|
|
227
|
-
interface
|
|
228
|
-
/** This marks the message as a shared
|
|
359
|
+
interface SharedFieldLoadRequest {
|
|
360
|
+
/** This marks the message as a shared field load. */
|
|
229
361
|
type: 'loadShared';
|
|
230
362
|
/** The reply carries this back so the engine can match it to its caller. */
|
|
231
363
|
requestId: string;
|
|
232
|
-
/** Later messages name the
|
|
364
|
+
/** Later messages name the field by this handle. */
|
|
233
365
|
handle: string;
|
|
234
366
|
/** The worker writes query scratch into this reserved slot alone. */
|
|
235
367
|
scratchSlot: number;
|
|
236
|
-
/**
|
|
237
|
-
|
|
368
|
+
/** These are the field's shared structures. */
|
|
369
|
+
handles: SharedVectorFieldHandles;
|
|
238
370
|
}
|
|
239
371
|
/**
|
|
240
372
|
* Asks the search worker to release a copy it holds.
|
|
@@ -249,6 +381,21 @@ interface VectorDropRequest {
|
|
|
249
381
|
/** The worker releases the copy held under this handle. */
|
|
250
382
|
handle: string;
|
|
251
383
|
}
|
|
384
|
+
/**
|
|
385
|
+
* Asks the search worker to place vectors in the graph of a field it holds.
|
|
386
|
+
*
|
|
387
|
+
* @internal
|
|
388
|
+
*/
|
|
389
|
+
interface VectorInsertRequest {
|
|
390
|
+
/** This marks the message as a graph insertion. */
|
|
391
|
+
type: 'insertOrdinals';
|
|
392
|
+
/** The reply carries this back so the engine can match it to its caller. */
|
|
393
|
+
requestId: string;
|
|
394
|
+
/** The worker places the vectors in the field held under this handle. */
|
|
395
|
+
handle: string;
|
|
396
|
+
/** The ordinals to place, whose vectors the shared store already holds. */
|
|
397
|
+
ordinals: Int32Array;
|
|
398
|
+
}
|
|
252
399
|
/**
|
|
253
400
|
* Asks the search worker to answer one nearest-neighbour query from a cloned
|
|
254
401
|
* copy.
|
|
@@ -274,19 +421,21 @@ interface VectorSearchRequest {
|
|
|
274
421
|
filter?: OrdinalFilter;
|
|
275
422
|
/** The worker explores this many candidates, or its own default when absent. */
|
|
276
423
|
efSearch?: number;
|
|
424
|
+
/** The worker re-scores this many times the requested count against full precision, or its own default when absent. */
|
|
425
|
+
oversample?: number;
|
|
277
426
|
}
|
|
278
427
|
/**
|
|
279
428
|
* Asks the search worker to answer one nearest-neighbour query from a shared
|
|
280
|
-
*
|
|
429
|
+
* field, returning ordinals for the engine to map back to document ids.
|
|
281
430
|
*
|
|
282
431
|
* @internal
|
|
283
432
|
*/
|
|
284
433
|
interface VectorOrdinalSearchRequest {
|
|
285
|
-
/** This marks the message as a search over a shared
|
|
434
|
+
/** This marks the message as a search over a shared field. */
|
|
286
435
|
type: 'searchOrdinals';
|
|
287
436
|
/** The reply carries this back so the engine can match it to its caller. */
|
|
288
437
|
requestId: string;
|
|
289
|
-
/** The worker searches the
|
|
438
|
+
/** The worker searches the field held under this handle. */
|
|
290
439
|
handle: string;
|
|
291
440
|
/** The worker ranks against this query vector. */
|
|
292
441
|
query: Float32Array;
|
|
@@ -300,13 +449,15 @@ interface VectorOrdinalSearchRequest {
|
|
|
300
449
|
filter?: OrdinalFilter;
|
|
301
450
|
/** The worker explores this many candidates, or its own default when absent. */
|
|
302
451
|
efSearch?: number;
|
|
452
|
+
/** The worker re-scores this many times the requested count against full precision, or its own default when absent. */
|
|
453
|
+
oversample?: number;
|
|
303
454
|
}
|
|
304
455
|
/**
|
|
305
456
|
* Every message the engine posts to the search worker.
|
|
306
457
|
*
|
|
307
458
|
* @internal
|
|
308
459
|
*/
|
|
309
|
-
type VectorWorkerRequest = VectorLoadRequest |
|
|
460
|
+
type VectorWorkerRequest = VectorLoadRequest | SharedFieldLoadRequest | VectorDropRequest | VectorInsertRequest | VectorSearchRequest | VectorOrdinalSearchRequest;
|
|
310
461
|
/**
|
|
311
462
|
* What the search worker returns once a copy is loaded or released.
|
|
312
463
|
*
|
|
@@ -320,6 +471,19 @@ interface VectorAckResponse {
|
|
|
320
471
|
/** This names the copy the acknowledgement belongs to. */
|
|
321
472
|
handle: string;
|
|
322
473
|
}
|
|
474
|
+
/**
|
|
475
|
+
* The search worker returns this once it has placed a batch of vectors.
|
|
476
|
+
*
|
|
477
|
+
* @internal
|
|
478
|
+
*/
|
|
479
|
+
interface VectorInsertResponse {
|
|
480
|
+
/** This marks the message as a completed insertion. */
|
|
481
|
+
type: 'inserted';
|
|
482
|
+
/** This matches the request the engine sent. */
|
|
483
|
+
requestId: string;
|
|
484
|
+
/** This is what the worker observed while placing the batch. */
|
|
485
|
+
outcome: GraphInsertOutcome;
|
|
486
|
+
}
|
|
323
487
|
/**
|
|
324
488
|
* What the search worker returns for a completed search over a cloned copy.
|
|
325
489
|
*
|
|
@@ -336,7 +500,7 @@ interface VectorSearchResponse {
|
|
|
336
500
|
scores: Float64Array;
|
|
337
501
|
}
|
|
338
502
|
/**
|
|
339
|
-
*
|
|
503
|
+
* The search worker returns this for a completed search over a shared field.
|
|
340
504
|
*
|
|
341
505
|
* @internal
|
|
342
506
|
*/
|
|
@@ -368,6 +532,6 @@ interface VectorWorkerError {
|
|
|
368
532
|
*
|
|
369
533
|
* @internal
|
|
370
534
|
*/
|
|
371
|
-
type VectorWorkerMessage = VectorAckResponse | VectorSearchResponse | VectorOrdinalSearchResponse | VectorWorkerError;
|
|
535
|
+
type VectorWorkerMessage = VectorAckResponse | VectorInsertResponse | VectorSearchResponse | VectorOrdinalSearchResponse | VectorWorkerError;
|
|
372
536
|
|
|
373
|
-
export { type
|
|
537
|
+
export { ArenaSimd, type BlockGeometry, type GraphInsertOutcome, type GrowableBuffer, type HNSWSnapshot, type OrdinalFilter, type OsqBits, type SharedFieldLoadRequest, type SharedGraphHandles, type SharedVectorFieldHandles, type SharedVectorStoreHandles, type VectorAckResponse, type VectorBlockHandle, type VectorBlockLayout, type VectorBlockStorage, type VectorCodeBlockLayout, type VectorDropRequest, type VectorInsertRequest, type VectorInsertResponse, type VectorLoadRequest, type VectorMetric, type VectorOrdinalSearchRequest, type VectorOrdinalSearchResponse, type VectorSearchRequest, type VectorSearchResponse, type VectorStoreSnapshot, type VectorWorkerError, type VectorWorkerMessage, type VectorWorkerRequest, type WorkerCopyCodes, type WorkerCopySnapshot };
|