@delali/narsil 0.3.1-next.85 → 0.3.1-next.87
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/browser/chunk-3BXQPIXK.mjs +602 -0
- package/dist/browser/chunk-3ZRMZIH4.mjs +3959 -0
- package/dist/browser/chunk-BBDAYUCO.mjs +2703 -0
- package/dist/browser/chunk-FHFFWLEK.mjs +669 -0
- package/dist/browser/chunk-HOZW3PKP.mjs +9 -0
- package/dist/browser/chunk-NQW2YXEX.mjs +346 -0
- package/dist/browser/chunk-TBMNPGFO.mjs +22910 -0
- package/dist/browser/durability-wiring-7RUN7LNS.mjs +3250 -0
- package/dist/browser/module-E25UDADM.mjs +2766 -0
- package/dist/browser/snapshot-A42DRERF.mjs +888 -0
- package/dist/browser/write-4U6Q26TJ.mjs +206 -0
- package/dist/{capabilities-CAdkp2P-.d.ts → capabilities-SJPttcgQ.d.ts} +2 -2
- package/dist/chunk-37CD3OKS.mjs +87 -0
- package/dist/chunk-AQU2QHSY.mjs +7247 -0
- package/dist/{chunk-OLXM65YH.mjs → chunk-AV4IJKD2.mjs} +1 -18
- package/dist/{chunk-4D6OH4EF.mjs → chunk-AXDAS2VA.mjs} +7 -5
- package/dist/{chunk-LS5IRM23.mjs → chunk-BVOJIYRV.mjs} +2 -25
- package/dist/chunk-C7SLA6CM.mjs +19 -0
- package/dist/{chunk-KJ7LB3TR.mjs → chunk-CVQWQVFX.mjs} +3 -22
- package/dist/chunk-DJHHF2L5.mjs +17 -0
- package/dist/chunk-FGMGUDHX.mjs +21 -0
- package/dist/chunk-IKST36MA.mjs +614 -0
- package/dist/{chunk-2453RJYK.mjs → chunk-J2BPXTD7.mjs} +167 -176
- package/dist/chunk-JFJBA3PD.mjs +522 -0
- package/dist/chunk-K4OWQ2M3.mjs +462 -0
- package/dist/chunk-L5ORED7V.mjs +25 -0
- package/dist/chunk-MKK4OZ5W.mjs +703 -0
- package/dist/chunk-MXS5HWIH.mjs +515 -0
- package/dist/chunk-P36MUFEJ.mjs +10 -0
- package/dist/chunk-PR4O7CAP.mjs +18 -0
- package/dist/{chunk-4VBG6PEH.mjs → chunk-PSUJCOSE.mjs} +3 -2
- package/dist/{chunk-ZCKPRCYI.mjs → chunk-Q5DC6WAB.mjs} +1 -1
- package/dist/{chunk-NFF5TDRG.mjs → chunk-QZN3MIJ3.mjs} +1 -16
- package/dist/chunk-R7OSDAFK.mjs +44 -0
- package/dist/chunk-RVM7AODE.mjs +73 -0
- package/dist/{chunk-XYDP7CCJ.mjs → chunk-SYRFSF6V.mjs} +6 -4
- package/dist/{chunk-SREPGC6O.mjs → chunk-T6CNO72J.mjs} +1 -1
- package/dist/chunk-T7DMUVTL.mjs +1714 -0
- package/dist/chunk-UKSUENHK.mjs +997 -0
- package/dist/{chunk-NIWDQTZB.mjs → chunk-ULRPNYAG.mjs} +1220 -2311
- package/dist/{chunk-GNYXCLJS.mjs → chunk-URGLSNKR.mjs} +4 -3
- package/dist/chunk-WQSHDZ7Z.mjs +631 -0
- package/dist/{chunk-RCSXJCI5.mjs → chunk-XBXKPWMR.mjs} +20 -2664
- package/dist/{chunk-RM6FRYEC.mjs → chunk-XSZVS4S3.mjs} +3 -2
- package/dist/chunk-Y2F66IQJ.mjs +74 -0
- package/dist/chunk-YCJLVNWR.mjs +262 -0
- package/dist/{client-CKUtkLz3.d.ts → client-BMK53IR2.d.ts} +3 -3
- package/dist/client.d.ts +8 -8
- package/dist/{config-CSDEPraV.d.ts → config-BUR-7eVQ.d.ts} +2 -2
- package/dist/{config-BuIkeM5C.d.ts → config-UJx1dyX1.d.ts} +2 -2
- package/dist/direct-executor-LD6JW57R.mjs +18 -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/durability-wiring-5S32KDDC.mjs +2797 -0
- package/dist/{engine-DMNZJAUq.d.ts → engine-9X6W5naj.d.ts} +2 -2
- package/dist/{index-DzONZUKE.d.ts → index-vCMu8OeQ.d.ts} +1 -1
- package/dist/index.browser.mjs +2 -38121
- package/dist/index.d.ts +23 -9
- package/dist/index.mjs +18 -14
- package/dist/{memory-BPKNx9Tl.d.ts → memory-CV9NAxLY.d.ts} +1 -1
- package/dist/module-WIDYIJLY.mjs +1819 -0
- package/dist/partial-words.mjs +5 -3
- package/dist/pattern.mjs +3 -2
- package/dist/persistence/durability/checkpoint-worker.d.ts +1 -1
- package/dist/persistence/durability/checkpoint-worker.mjs +23 -13
- package/dist/react.d.ts +7 -7
- package/dist/{schema-DgyDijhf.d.ts → schema-DtsgmNfU.d.ts} +1 -1
- package/dist/server.d.ts +10 -10
- package/dist/server.mjs +14 -9
- package/dist/snapshot-6BYSUPWL.mjs +469 -0
- package/dist/{tasks-DGyz586z.d.ts → tasks-BGaZJyoY.d.ts} +1 -1
- package/dist/{thread-EUUNJNKU.mjs → thread-GS65E6RM.mjs} +12 -9
- package/dist/vector/search-worker.d.ts +30 -3
- package/dist/vector/search-worker.mjs +6 -2
- package/dist/workers/entry.mjs +5 -3
- package/dist/write-HLEZTL2L.mjs +233 -0
- package/package.json +11 -7
- package/dist/chunk-67MQF5CV.mjs +0 -15198
- package/dist/direct-executor-NY7ZTZIH.mjs +0 -19
- package/dist/simd-DW5AtJ6B.d.ts +0 -41
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { setNestedValue, KEYWORD_SEGMENT_ENVELOPE_VERSION, decodeKeywordSegment } from './chunk-3BXQPIXK.mjs';
|
|
2
|
+
import { decodeStoredDocument, openChecksummedEnvelope, NUMBER_TAG, DATE_TAG, BYTES_TAG, encodeBase64, startsWithTagPrefix, OBJECT_TAG, MILLISECONDS_PER_SECOND, NANOSECONDS_PER_MILLISECOND, DOCUMENT_EXPORT_VERSION, DOCUMENT_EXPORT_FORMAT } from './chunk-TBMNPGFO.mjs';
|
|
3
|
+
import { decodeVectorFilePayload, isDead, bytesToVectors } from './chunk-NQW2YXEX.mjs';
|
|
4
|
+
import { EXPORT_CHUNK_BYTES, NarsilError, ErrorCodes } from './chunk-FHFFWLEK.mjs';
|
|
5
|
+
import { decode } from '@msgpack/msgpack';
|
|
6
|
+
|
|
7
|
+
// src/engine/export/json-line.ts
|
|
8
|
+
function refuse(path, kind, docId) {
|
|
9
|
+
throw new NarsilError(
|
|
10
|
+
ErrorCodes.DOC_VALIDATION_FAILED,
|
|
11
|
+
`Document "${docId}" holds ${kind} at "${path || "(document)"}", which a document export cannot carry as JSON`,
|
|
12
|
+
{ docId, field: path }
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
function encodeNumber(value, path, target) {
|
|
16
|
+
if (Number.isFinite(value)) return Object.is(value, -0) ? "-0" : JSON.stringify(value);
|
|
17
|
+
if (!target.tagged) refuse(path, String(value), target.docId);
|
|
18
|
+
return `{"${NUMBER_TAG}":"${String(value)}"}`;
|
|
19
|
+
}
|
|
20
|
+
function encodeDate(value, path, target) {
|
|
21
|
+
const milliseconds = value.getTime();
|
|
22
|
+
if (!target.tagged || Number.isNaN(milliseconds)) refuse(path, "a date", target.docId);
|
|
23
|
+
const seconds = Math.floor(milliseconds / MILLISECONDS_PER_SECOND);
|
|
24
|
+
const nanoseconds = (milliseconds - seconds * MILLISECONDS_PER_SECOND) * NANOSECONDS_PER_MILLISECOND;
|
|
25
|
+
return `{"${DATE_TAG}":[${seconds},${nanoseconds}]}`;
|
|
26
|
+
}
|
|
27
|
+
function encodeBytes(value, path, target) {
|
|
28
|
+
if (!target.tagged) refuse(path, "bytes", target.docId);
|
|
29
|
+
return `{"${BYTES_TAG}":"${encodeBase64(value)}"}`;
|
|
30
|
+
}
|
|
31
|
+
function encodeList(value, path, target) {
|
|
32
|
+
target.parts.push("[");
|
|
33
|
+
for (let at = 0; at < value.length; at++) {
|
|
34
|
+
if (at > 0) target.parts.push(",");
|
|
35
|
+
encodeValue(value[at], `${path}[${at}]`, target);
|
|
36
|
+
}
|
|
37
|
+
target.parts.push("]");
|
|
38
|
+
}
|
|
39
|
+
function encodeMap(value, path, target) {
|
|
40
|
+
const proto = Object.getPrototypeOf(value);
|
|
41
|
+
if (proto !== Object.prototype && proto !== null) refuse(path, "a value other than a plain object", target.docId);
|
|
42
|
+
const entries = Object.entries(value).filter(([, entry]) => entry !== void 0);
|
|
43
|
+
const wrapped = target.tagged && entries.length === 1 && startsWithTagPrefix(entries[0][0]);
|
|
44
|
+
target.parts.push(wrapped ? `{"${OBJECT_TAG}":{` : "{");
|
|
45
|
+
for (let at = 0; at < entries.length; at++) {
|
|
46
|
+
const [key, entry] = entries[at];
|
|
47
|
+
if (at > 0) target.parts.push(",");
|
|
48
|
+
target.parts.push(JSON.stringify(key), ":");
|
|
49
|
+
encodeValue(entry, path === "" ? key : `${path}.${key}`, target);
|
|
50
|
+
}
|
|
51
|
+
target.parts.push(wrapped ? "}}" : "}");
|
|
52
|
+
}
|
|
53
|
+
function encodeValue(value, path, target) {
|
|
54
|
+
if (value === null) {
|
|
55
|
+
target.parts.push("null");
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
switch (typeof value) {
|
|
59
|
+
case "string":
|
|
60
|
+
target.parts.push(JSON.stringify(value));
|
|
61
|
+
return;
|
|
62
|
+
case "boolean":
|
|
63
|
+
target.parts.push(value ? "true" : "false");
|
|
64
|
+
return;
|
|
65
|
+
case "number":
|
|
66
|
+
target.parts.push(encodeNumber(value, path, target));
|
|
67
|
+
return;
|
|
68
|
+
case "object":
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
refuse(path, `a ${typeof value}`, target.docId);
|
|
72
|
+
}
|
|
73
|
+
if (Array.isArray(value)) encodeList(value, path, target);
|
|
74
|
+
else if (value instanceof Date) target.parts.push(encodeDate(value, path, target));
|
|
75
|
+
else if (value instanceof Uint8Array) target.parts.push(encodeBytes(value, path, target));
|
|
76
|
+
else encodeMap(value, path, target);
|
|
77
|
+
}
|
|
78
|
+
function encodeExactJson(value, docId) {
|
|
79
|
+
const target = { docId, tagged: false, parts: [] };
|
|
80
|
+
encodeValue(value, "", target);
|
|
81
|
+
return target.parts.join("");
|
|
82
|
+
}
|
|
83
|
+
function encodeDocumentJson(document, docId) {
|
|
84
|
+
const target = { docId, tagged: true, parts: [] };
|
|
85
|
+
encodeValue(document, "", target);
|
|
86
|
+
return target.parts.join("");
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/engine/export/write.ts
|
|
90
|
+
var VECTOR_FILE_ENVELOPE_VERSION = 2;
|
|
91
|
+
var FLOAT32_BYTES = 4;
|
|
92
|
+
async function locateVectors(checkpoint) {
|
|
93
|
+
const located = /* @__PURE__ */ new Map();
|
|
94
|
+
for (const field of checkpoint.manifest.vectors) {
|
|
95
|
+
const byDocId = /* @__PURE__ */ new Map();
|
|
96
|
+
for (const ref of field.files) {
|
|
97
|
+
const { payload } = await openChecksummedEnvelope(await checkpoint.readFile(ref), {
|
|
98
|
+
envelopeFormatVersion: VECTOR_FILE_ENVELOPE_VERSION,
|
|
99
|
+
what: `vector file "${ref.key}"`,
|
|
100
|
+
allowsCompression: false
|
|
101
|
+
});
|
|
102
|
+
const decoded = decodeVectorFilePayload(decode(payload));
|
|
103
|
+
for (let position = 0; position < decoded.docIds.length; position++) {
|
|
104
|
+
if (isDead(ref.dead, position)) continue;
|
|
105
|
+
byDocId.set(decoded.docIds[position], { ref, position, dimension: decoded.dimension });
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
located.set(field.fieldPath, byDocId);
|
|
109
|
+
}
|
|
110
|
+
return located;
|
|
111
|
+
}
|
|
112
|
+
async function readVector(checkpoint, location) {
|
|
113
|
+
const width = location.dimension * FLOAT32_BYTES;
|
|
114
|
+
const offset = location.ref.bytes - (location.ref.count - location.position) * width;
|
|
115
|
+
return Array.from(bytesToVectors((await checkpoint.readRange(location.ref, offset, width)).slice()));
|
|
116
|
+
}
|
|
117
|
+
async function readSegment(checkpoint, ref) {
|
|
118
|
+
const { payload } = await openChecksummedEnvelope(await checkpoint.readFile(ref), {
|
|
119
|
+
envelopeFormatVersion: KEYWORD_SEGMENT_ENVELOPE_VERSION,
|
|
120
|
+
what: `segment "${ref.key}"`,
|
|
121
|
+
allowsCompression: true
|
|
122
|
+
});
|
|
123
|
+
return decodeKeywordSegment(payload, false);
|
|
124
|
+
}
|
|
125
|
+
var decoder = new TextDecoder();
|
|
126
|
+
function idAt(contents, ordinal) {
|
|
127
|
+
const ids = contents.arrays.idTable;
|
|
128
|
+
return decoder.decode(ids.blob.subarray(ids.offsets[ordinal], ids.offsets[ordinal + 1]));
|
|
129
|
+
}
|
|
130
|
+
async function winnersOf(checkpoint, partition) {
|
|
131
|
+
const winners = /* @__PURE__ */ new Map();
|
|
132
|
+
for (let at = 0; at < partition.segments.length; at++) {
|
|
133
|
+
const contents = await readSegment(checkpoint, partition.segments[at]);
|
|
134
|
+
for (const docId of contents.tombstones) winners.delete(docId);
|
|
135
|
+
for (let ordinal = 0; ordinal < contents.arrays.documentCount; ordinal++) winners.set(idAt(contents, ordinal), at);
|
|
136
|
+
}
|
|
137
|
+
return winners;
|
|
138
|
+
}
|
|
139
|
+
async function* documentLines(checkpoint) {
|
|
140
|
+
const vectors = await locateVectors(checkpoint);
|
|
141
|
+
for (const partition of checkpoint.manifest.partitions) {
|
|
142
|
+
const winners = await winnersOf(checkpoint, partition);
|
|
143
|
+
for (let at = 0; at < partition.segments.length; at++) {
|
|
144
|
+
const contents = await readSegment(checkpoint, partition.segments[at]);
|
|
145
|
+
const table = contents.arrays.documentTable;
|
|
146
|
+
for (let ordinal = 0; ordinal < contents.arrays.documentCount; ordinal++) {
|
|
147
|
+
const docId = idAt(contents, ordinal);
|
|
148
|
+
if (winners.get(docId) !== at) continue;
|
|
149
|
+
const stored = decodeStoredDocument(
|
|
150
|
+
table.blob.subarray(table.offsets[ordinal], table.offsets[ordinal + 1]),
|
|
151
|
+
table.discardedFields
|
|
152
|
+
);
|
|
153
|
+
const document = { id: docId, ...stored };
|
|
154
|
+
document.id = docId;
|
|
155
|
+
for (const [fieldPath, located] of vectors) {
|
|
156
|
+
const location = located.get(docId);
|
|
157
|
+
if (location !== void 0) setNestedValue(document, fieldPath, await readVector(checkpoint, location));
|
|
158
|
+
}
|
|
159
|
+
yield `${encodeDocumentJson(document, docId)}
|
|
160
|
+
`;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function* exportLines(header, checkpoint) {
|
|
166
|
+
yield `${encodeExactJson({ format: DOCUMENT_EXPORT_FORMAT, version: DOCUMENT_EXPORT_VERSION, index: header }, "")}
|
|
167
|
+
`;
|
|
168
|
+
yield* documentLines(checkpoint);
|
|
169
|
+
}
|
|
170
|
+
function documentExportStream(header, checkpoint) {
|
|
171
|
+
const lines = exportLines(header, checkpoint);
|
|
172
|
+
const encoder = new TextEncoder();
|
|
173
|
+
let released = false;
|
|
174
|
+
const release = () => {
|
|
175
|
+
if (released) return;
|
|
176
|
+
released = true;
|
|
177
|
+
checkpoint.release();
|
|
178
|
+
};
|
|
179
|
+
return new ReadableStream({
|
|
180
|
+
async pull(controller) {
|
|
181
|
+
try {
|
|
182
|
+
let text = "";
|
|
183
|
+
while (text.length < EXPORT_CHUNK_BYTES) {
|
|
184
|
+
const step = await lines.next();
|
|
185
|
+
if (step.done) {
|
|
186
|
+
if (text.length > 0) controller.enqueue(encoder.encode(text));
|
|
187
|
+
release();
|
|
188
|
+
controller.close();
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
text += step.value;
|
|
192
|
+
}
|
|
193
|
+
controller.enqueue(encoder.encode(text));
|
|
194
|
+
} catch (error) {
|
|
195
|
+
release();
|
|
196
|
+
controller.error(error);
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
async cancel() {
|
|
200
|
+
release();
|
|
201
|
+
await lines.return(void 0);
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
export { documentExportStream };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { E as EmbeddingAdapter } from './adapters-79OIa4xm.js';
|
|
2
|
-
import { C as ClusterNamespace } from './config-
|
|
3
|
-
import { h as TaskStore } from './tasks-
|
|
2
|
+
import { C as ClusterNamespace } from './config-UJx1dyX1.js';
|
|
3
|
+
import { h as TaskStore } from './tasks-BGaZJyoY.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Context handed to {@link OnRequestHook} for every inbound request, captured
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/vector/osq/record.ts
|
|
2
|
+
var OSQ_RECORD_TRAILER_BYTES = 16;
|
|
3
|
+
var TRAILER_LOWER = 0;
|
|
4
|
+
var TRAILER_UPPER = 4;
|
|
5
|
+
var TRAILER_CORRECTION = 8;
|
|
6
|
+
var TRAILER_SUM = 12;
|
|
7
|
+
var QUERY_PLANES_FOR_NARROW_CODES = 4;
|
|
8
|
+
var LEVELS_IN_A_TWO_BIT_BYTE = 4;
|
|
9
|
+
function osqCodeBytes(dimension, bits) {
|
|
10
|
+
return Math.ceil(dimension * bits / 8);
|
|
11
|
+
}
|
|
12
|
+
function osqRecordBytes(dimension, bits) {
|
|
13
|
+
return osqCodeBytes(dimension, bits) + OSQ_RECORD_TRAILER_BYTES;
|
|
14
|
+
}
|
|
15
|
+
function packLevels(levels, bits, target, offset) {
|
|
16
|
+
const dimension = levels.length;
|
|
17
|
+
if (bits === 8) {
|
|
18
|
+
target.set(levels, offset);
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const perByte = 8 / bits;
|
|
22
|
+
target.fill(0, offset, offset + osqCodeBytes(dimension, bits));
|
|
23
|
+
for (let i = 0; i < dimension; i++) {
|
|
24
|
+
const value = levels[i];
|
|
25
|
+
if (value === 0) continue;
|
|
26
|
+
target[offset + Math.floor(i / perByte)] |= value << i % perByte * bits;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function unpackLevels(bytes, offset, dimension, bits) {
|
|
30
|
+
const levels = new Uint8Array(dimension);
|
|
31
|
+
if (bits === 8) {
|
|
32
|
+
levels.set(bytes.subarray(offset, offset + dimension));
|
|
33
|
+
return levels;
|
|
34
|
+
}
|
|
35
|
+
const perByte = 8 / bits;
|
|
36
|
+
const mask = (1 << bits) - 1;
|
|
37
|
+
for (let i = 0; i < dimension; i++) {
|
|
38
|
+
levels[i] = bytes[offset + Math.floor(i / perByte)] >> i % perByte * bits & mask;
|
|
39
|
+
}
|
|
40
|
+
return levels;
|
|
41
|
+
}
|
|
42
|
+
function osqStagedQueryBytes(dimension, documentBits) {
|
|
43
|
+
if (documentBits === 8) return dimension;
|
|
44
|
+
if (documentBits === 4) return osqCodeBytes(dimension, 4);
|
|
45
|
+
return QUERY_PLANES_FOR_NARROW_CODES * osqCodeBytes(dimension, documentBits);
|
|
46
|
+
}
|
|
47
|
+
function stageQueryLevels(levels, documentBits, target) {
|
|
48
|
+
if (documentBits === 8 || documentBits === 4) {
|
|
49
|
+
packLevels(levels, documentBits, target, 0);
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const planeBytes = osqCodeBytes(levels.length, documentBits);
|
|
53
|
+
target.fill(0, 0, QUERY_PLANES_FOR_NARROW_CODES * planeBytes);
|
|
54
|
+
if (documentBits === 2) {
|
|
55
|
+
for (let i = 0; i < levels.length; i++) {
|
|
56
|
+
target[i % LEVELS_IN_A_TWO_BIT_BYTE * planeBytes + Math.floor(i / LEVELS_IN_A_TWO_BIT_BYTE)] = levels[i];
|
|
57
|
+
}
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
for (let i = 0; i < levels.length; i++) {
|
|
61
|
+
const value = levels[i];
|
|
62
|
+
if (value === 0) continue;
|
|
63
|
+
const byte = i >> 3;
|
|
64
|
+
const bit = 1 << (i & 7);
|
|
65
|
+
for (let plane = 0; plane < QUERY_PLANES_FOR_NARROW_CODES; plane++) {
|
|
66
|
+
if (value >> plane & 1) target[plane * planeBytes + byte] |= bit;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function writeRecord(target, offset, code, bits, trailer = new DataView(target.buffer, target.byteOffset, target.byteLength)) {
|
|
71
|
+
packLevels(code.levels, bits, target, offset);
|
|
72
|
+
const at = offset + osqCodeBytes(code.levels.length, bits);
|
|
73
|
+
trailer.setFloat32(at + TRAILER_LOWER, code.lower, true);
|
|
74
|
+
trailer.setFloat32(at + TRAILER_UPPER, code.upper, true);
|
|
75
|
+
trailer.setFloat32(at + TRAILER_CORRECTION, code.correction, true);
|
|
76
|
+
trailer.setUint32(at + TRAILER_SUM, code.sum, true);
|
|
77
|
+
}
|
|
78
|
+
function readTrailer(trailer, codeOffset, codeBytes, into) {
|
|
79
|
+
const at = codeOffset + codeBytes;
|
|
80
|
+
into.lower = trailer.getFloat32(at + TRAILER_LOWER, true);
|
|
81
|
+
into.upper = trailer.getFloat32(at + TRAILER_UPPER, true);
|
|
82
|
+
into.correction = trailer.getFloat32(at + TRAILER_CORRECTION, true);
|
|
83
|
+
into.sum = trailer.getUint32(at + TRAILER_SUM, true);
|
|
84
|
+
return into;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export { osqCodeBytes, osqRecordBytes, osqStagedQueryBytes, readTrailer, stageQueryLevels, unpackLevels, writeRecord };
|