@elaraai/e3-api-server 1.0.97 → 1.0.98
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 +57 -4
- package/dist/src/handlers/dataflow.d.ts +9 -1
- package/dist/src/handlers/dataflow.d.ts.map +1 -1
- package/dist/src/handlers/dataflow.js +19 -4
- package/dist/src/handlers/dataflow.js.map +1 -1
- package/dist/src/handlers/dataset-batches.d.ts +203 -0
- package/dist/src/handlers/dataset-batches.d.ts.map +1 -0
- package/dist/src/handlers/dataset-batches.js +442 -0
- package/dist/src/handlers/dataset-batches.js.map +1 -0
- package/dist/src/handlers/dataset-place.d.ts +104 -0
- package/dist/src/handlers/dataset-place.d.ts.map +1 -0
- package/dist/src/handlers/dataset-place.js +282 -0
- package/dist/src/handlers/dataset-place.js.map +1 -0
- package/dist/src/handlers/dataset-reads.d.ts +205 -0
- package/dist/src/handlers/dataset-reads.d.ts.map +1 -0
- package/dist/src/handlers/dataset-reads.js +350 -0
- package/dist/src/handlers/dataset-reads.js.map +1 -0
- package/dist/src/handlers/datasets.d.ts +19 -30
- package/dist/src/handlers/datasets.d.ts.map +1 -1
- package/dist/src/handlers/datasets.js +84 -549
- package/dist/src/handlers/datasets.js.map +1 -1
- package/dist/src/handlers/datasets.spec.js +968 -14
- package/dist/src/handlers/datasets.spec.js.map +1 -1
- package/dist/src/handlers/index.d.ts +5 -1
- package/dist/src/handlers/index.d.ts.map +1 -1
- package/dist/src/handlers/index.js +4 -1
- package/dist/src/handlers/index.js.map +1 -1
- package/dist/src/handlers/key-search.d.ts +102 -0
- package/dist/src/handlers/key-search.d.ts.map +1 -0
- package/dist/src/handlers/key-search.js +351 -0
- package/dist/src/handlers/key-search.js.map +1 -0
- package/dist/src/handlers/segments.d.ts +124 -0
- package/dist/src/handlers/segments.d.ts.map +1 -0
- package/dist/src/handlers/segments.js +278 -0
- package/dist/src/handlers/segments.js.map +1 -0
- package/dist/src/handlers/workspaces.spec.js +1 -0
- package/dist/src/handlers/workspaces.spec.js.map +1 -1
- package/dist/src/portable.spec.js +3 -2
- package/dist/src/portable.spec.js.map +1 -1
- package/dist/src/routes/dataset-path.d.ts +16 -0
- package/dist/src/routes/dataset-path.d.ts.map +1 -1
- package/dist/src/routes/dataset-path.js +18 -0
- package/dist/src/routes/dataset-path.js.map +1 -1
- package/dist/src/routes/datasets.d.ts.map +1 -1
- package/dist/src/routes/datasets.js +228 -2
- package/dist/src/routes/datasets.js.map +1 -1
- package/dist/src/routes/executions.js +1 -1
- package/dist/src/routes/executions.js.map +1 -1
- package/dist/src/routes/transfer.d.ts.map +1 -1
- package/dist/src/routes/transfer.js +11 -5
- package/dist/src/routes/transfer.js.map +1 -1
- package/dist/src/stopping-run.d.ts +24 -3
- package/dist/src/stopping-run.d.ts.map +1 -1
- package/dist/src/stopping-run.js +29 -7
- package/dist/src/stopping-run.js.map +1 -1
- package/dist/src/stopping-run.spec.js +30 -1
- package/dist/src/stopping-run.spec.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Where a narrowing's rows sit in a record (#1349), from the narrowing's runs
|
|
7
|
+
* of one of the record's indexes, as a record Slice resolves them:
|
|
8
|
+
*
|
|
9
|
+
* - `place`: how many of the runs' entries each record segment holds — read
|
|
10
|
+
* from the index's own segments, each entry's row placed in its record
|
|
11
|
+
* segment by the record's fences, which its manifest carries, so no record
|
|
12
|
+
* segment is read;
|
|
13
|
+
* - `within`: which of some index entries the runs hold — each run a stretch
|
|
14
|
+
* of the index's rows, so an entry is in it when it falls between the run's
|
|
15
|
+
* first and last entries in the index's order, and only those boundary
|
|
16
|
+
* entries are read, at most two index segments a run.
|
|
17
|
+
*
|
|
18
|
+
* Neither evaluates anything over a row: the index holds what its maintained
|
|
19
|
+
* key functions emitted, and both reads use only that. Each reads every segment
|
|
20
|
+
* it touches once, through the decoded segments the API process keeps.
|
|
21
|
+
*
|
|
22
|
+
* @packageDocumentation
|
|
23
|
+
*/
|
|
24
|
+
import { parseFor, segmentKeyTypeOf } from '@elaraai/east';
|
|
25
|
+
import { sendJsonError } from '../errors.js';
|
|
26
|
+
import { DATASET_BATCH_MAX, runsRefusal } from './dataset-batches.js';
|
|
27
|
+
import { PAGE_BYTE_BUDGET_DEFAULT, PAGE_MAX_LIMIT, cachedSegments, corruptRefusal, elementsOf, indexOf, pageError, readDataset, } from './dataset-reads.js';
|
|
28
|
+
import { comparators } from './segments.js';
|
|
29
|
+
/**
|
|
30
|
+
* Place a window of a narrowing's runs in a record: how many of the window's
|
|
31
|
+
* entries each record segment holds.
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* The window's entries are read from the index's own segments, with no join,
|
|
35
|
+
* as a covering index page reads them, and each entry's row — its primary key,
|
|
36
|
+
* `k` — is placed in the record segment that holds it by a bisect of the
|
|
37
|
+
* record's fences, which come with its manifest: no record segment is read.
|
|
38
|
+
*
|
|
39
|
+
* The window is a page's at most: {@link PAGE_MAX_LIMIT} entries, and the page
|
|
40
|
+
* byte budget by the index's average entry. Responds with JSON
|
|
41
|
+
* `{ segments: [{ segment, offset, count, rows }], placed }`, the segments in
|
|
42
|
+
* the record's order and only those that hold some of the window's entries,
|
|
43
|
+
* `placed` how many entries it places: the caller asks again from `offset +
|
|
44
|
+
* placed`. A record Slice's runs name each row once, so a segment's rows over
|
|
45
|
+
* every window add up to the narrowing's rows in it. A summary index is
|
|
46
|
+
* refused 400, naming it: its entries stand for many rows and name none to place.
|
|
47
|
+
*
|
|
48
|
+
* @param storage - Storage backend
|
|
49
|
+
* @param repoPath - Repository identifier
|
|
50
|
+
* @param workspace - Workspace name
|
|
51
|
+
* @param treePath - The record's path
|
|
52
|
+
* @param request - The index, its runs, the window and the pin
|
|
53
|
+
* @param limits - The byte budget
|
|
54
|
+
* @returns The placement, or a JSON refusal
|
|
55
|
+
*/
|
|
56
|
+
export async function placeDatasetRuns(storage, repoPath, workspace, treePath, request, limits = {}) {
|
|
57
|
+
try {
|
|
58
|
+
if (request.runs.length > DATASET_BATCH_MAX) {
|
|
59
|
+
return pageError('bad_request', `A placement takes at most ${DATASET_BATCH_MAX} runs; this one has ${request.runs.length}`);
|
|
60
|
+
}
|
|
61
|
+
const offset = request.offset ?? 0;
|
|
62
|
+
const limit = request.limit ?? PAGE_MAX_LIMIT;
|
|
63
|
+
if (!Number.isSafeInteger(offset) || offset < 0)
|
|
64
|
+
return pageError('bad_request', `offset ${offset} is not a row at least 0`);
|
|
65
|
+
if (!Number.isSafeInteger(limit) || limit < 0)
|
|
66
|
+
return pageError('bad_request', `limit ${limit} is not a count at least 0`);
|
|
67
|
+
const opened = await openIndexed(storage, repoPath, workspace, treePath, request.index, request.hash, 'a placement of runs', 'to place in a record segment');
|
|
68
|
+
if (opened instanceof Response)
|
|
69
|
+
return opened;
|
|
70
|
+
const { hash, index, primary } = opened;
|
|
71
|
+
const refused = runsRefusal(request.runs, index.elementCount);
|
|
72
|
+
if (refused !== undefined)
|
|
73
|
+
return pageError('bad_request', refused);
|
|
74
|
+
const entries = request.runs.reduce((sum, [, count]) => sum + count, 0);
|
|
75
|
+
// A covering index page's bounds: the hard cap, and the byte budget by the
|
|
76
|
+
// index's average entry.
|
|
77
|
+
const byteBudget = limits.byteBudget ?? PAGE_BYTE_BUDGET_DEFAULT;
|
|
78
|
+
const perEntry = index.elementCount > 0 ? index.bytes / index.elementCount : 1;
|
|
79
|
+
const bound = Math.max(1, Math.min(PAGE_MAX_LIMIT, Math.floor(byteBudget / Math.max(1, perEntry))));
|
|
80
|
+
const placed = Math.max(0, Math.min(limit, bound, entries - offset));
|
|
81
|
+
let segments;
|
|
82
|
+
try {
|
|
83
|
+
const pairs = await elementsOf(storage, repoPath, index, windowSpans(request.runs, offset, placed));
|
|
84
|
+
const owner = await segmentOfKey(primary);
|
|
85
|
+
const held = new Map();
|
|
86
|
+
for (const [entry] of pairs) {
|
|
87
|
+
const segment = owner(entry.k);
|
|
88
|
+
held.set(segment, (held.get(segment) ?? 0) + 1);
|
|
89
|
+
}
|
|
90
|
+
segments = [...held].sort((a, b) => a[0] - b[0]).map(([segment, rows]) => ({
|
|
91
|
+
segment,
|
|
92
|
+
offset: segment === 0 ? 0 : primary.cumulative[segment - 1],
|
|
93
|
+
count: primary.counts[segment],
|
|
94
|
+
rows,
|
|
95
|
+
}));
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
return corruptRefusal(err, 'dataset_not_canonical');
|
|
99
|
+
}
|
|
100
|
+
return new Response(JSON.stringify({ segments, placed }), {
|
|
101
|
+
status: 200,
|
|
102
|
+
headers: {
|
|
103
|
+
'Content-Type': 'application/json',
|
|
104
|
+
'Cache-Control': 'no-store',
|
|
105
|
+
'X-Content-SHA256': hash,
|
|
106
|
+
'X-Total-Elements': String(primary.elementCount),
|
|
107
|
+
'X-Run-Entries': String(entries),
|
|
108
|
+
},
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
catch (err) {
|
|
112
|
+
return sendJsonError(err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Answer which of some index entries a narrowing's runs hold: for each entry
|
|
117
|
+
* key, whether it lies in one of the runs.
|
|
118
|
+
*
|
|
119
|
+
* @remarks
|
|
120
|
+
* Each run is a contiguous stretch of the index's rows, so an entry lies in it
|
|
121
|
+
* when it falls between the run's first and last entries in the index's
|
|
122
|
+
* order. Only those boundary entries are read — at most two index segments a
|
|
123
|
+
* run — and every key is placed among them by the index entry key's
|
|
124
|
+
* comparator: nothing else is decoded, and nothing is evaluated over a row. A
|
|
125
|
+
* row is in the narrowing when any of its entries is.
|
|
126
|
+
*
|
|
127
|
+
* Responds with JSON `{ within: [boolean, …] }`, one a key, in order. More than
|
|
128
|
+
* {@link DATASET_BATCH_MAX} keys or runs, runs that are not ascending, disjoint
|
|
129
|
+
* and inside the index, and a key that is not a literal of the index's entry
|
|
130
|
+
* key type are refused, naming what is wrong — and so is a summary index, whose
|
|
131
|
+
* entries stand for many rows and name none whose membership to answer.
|
|
132
|
+
*
|
|
133
|
+
* @param storage - Storage backend
|
|
134
|
+
* @param repoPath - Repository identifier
|
|
135
|
+
* @param workspace - Workspace name
|
|
136
|
+
* @param treePath - The record's path
|
|
137
|
+
* @param request - The index, its runs, the entry keys and the pin
|
|
138
|
+
* @returns The answers, or a JSON refusal
|
|
139
|
+
*/
|
|
140
|
+
export async function withinDatasetRuns(storage, repoPath, workspace, treePath, request) {
|
|
141
|
+
try {
|
|
142
|
+
if (request.runs.length > DATASET_BATCH_MAX) {
|
|
143
|
+
return pageError('bad_request', `A membership read takes at most ${DATASET_BATCH_MAX} runs; this one has ${request.runs.length}`);
|
|
144
|
+
}
|
|
145
|
+
if (request.keys.length > DATASET_BATCH_MAX) {
|
|
146
|
+
return pageError('bad_request', `A membership read takes at most ${DATASET_BATCH_MAX} keys; this one has ${request.keys.length}`);
|
|
147
|
+
}
|
|
148
|
+
const opened = await openIndexed(storage, repoPath, workspace, treePath, request.index, request.hash, 'a membership read', 'to answer whether a narrowing holds it');
|
|
149
|
+
if (opened instanceof Response)
|
|
150
|
+
return opened;
|
|
151
|
+
const { hash, index, entryKeyType } = opened;
|
|
152
|
+
const refused = runsRefusal(request.runs, index.elementCount);
|
|
153
|
+
if (refused !== undefined)
|
|
154
|
+
return pageError('bad_request', refused);
|
|
155
|
+
const parse = parseFor(entryKeyType);
|
|
156
|
+
const keys = [];
|
|
157
|
+
for (const [i, literal] of request.keys.entries()) {
|
|
158
|
+
const parsed = parse(literal);
|
|
159
|
+
if (!parsed.success)
|
|
160
|
+
return pageError('key_parse_error', `key ${i}: ${parsed.error}`);
|
|
161
|
+
keys.push(parsed.value);
|
|
162
|
+
}
|
|
163
|
+
let within;
|
|
164
|
+
try {
|
|
165
|
+
// Each run's first and last entries, every segment they lie in read once.
|
|
166
|
+
const spans = request.runs.flatMap(([row, count]) => count === 1 ? [{ from: row, to: row + 1 }] : [{ from: row, to: row + 1 }, { from: row + count - 1, to: row + count }]);
|
|
167
|
+
const bounds = (await elementsOf(storage, repoPath, index, spans)).map(([key]) => key);
|
|
168
|
+
const firsts = [];
|
|
169
|
+
const lasts = [];
|
|
170
|
+
let at = 0;
|
|
171
|
+
for (const [, count] of request.runs) {
|
|
172
|
+
firsts.push(bounds[at]);
|
|
173
|
+
lasts.push(bounds[count === 1 ? at : at + 1]);
|
|
174
|
+
at += count === 1 ? 1 : 2;
|
|
175
|
+
}
|
|
176
|
+
const cmp = comparators(entryKeyType);
|
|
177
|
+
within = keys.map((key) => {
|
|
178
|
+
// The last run starting at or before the key, then whether it reaches it.
|
|
179
|
+
let lo = 0;
|
|
180
|
+
let hi = firsts.length;
|
|
181
|
+
while (lo < hi) {
|
|
182
|
+
const mid = (lo + hi) >> 1;
|
|
183
|
+
if (cmp(firsts[mid], key) <= 0)
|
|
184
|
+
lo = mid + 1;
|
|
185
|
+
else
|
|
186
|
+
hi = mid;
|
|
187
|
+
}
|
|
188
|
+
return lo > 0 && cmp(key, lasts[lo - 1]) <= 0;
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
catch (err) {
|
|
192
|
+
return corruptRefusal(err, 'dataset_not_canonical');
|
|
193
|
+
}
|
|
194
|
+
return new Response(JSON.stringify({ within }), {
|
|
195
|
+
status: 200,
|
|
196
|
+
headers: {
|
|
197
|
+
'Content-Type': 'application/json',
|
|
198
|
+
'Cache-Control': 'no-store',
|
|
199
|
+
'X-Content-SHA256': hash,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
catch (err) {
|
|
204
|
+
return sendJsonError(err);
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* The record, the index and its primary a read names, opened; or the refusal
|
|
209
|
+
* of a pin, a path or an index — a summary's among them (#1039): its entries
|
|
210
|
+
* stand for every row of their key and name none, so neither read has a row to
|
|
211
|
+
* place or to answer of, and it is refused 400 as a joined read of one is.
|
|
212
|
+
*
|
|
213
|
+
* @param storage - Storage backend
|
|
214
|
+
* @param repoPath - Repository identifier
|
|
215
|
+
* @param workspace - Workspace name
|
|
216
|
+
* @param treePath - The record's path
|
|
217
|
+
* @param name - The index
|
|
218
|
+
* @param hash - The record's content hash the read is pinned to
|
|
219
|
+
* @param what - How the refusal of an empty path names the read
|
|
220
|
+
* @param unnamed - What the read needs of the row an entry names, as a summary's refusal says it
|
|
221
|
+
* @returns The opened index, or the refusal
|
|
222
|
+
*/
|
|
223
|
+
async function openIndexed(storage, repoPath, workspace, treePath, name, hash, what, unnamed) {
|
|
224
|
+
const dataset = await readDataset(storage, repoPath, workspace, treePath, hash, what);
|
|
225
|
+
if (dataset instanceof Response)
|
|
226
|
+
return dataset;
|
|
227
|
+
const resolved = await indexOf(storage, repoPath, workspace, treePath, dataset.hash, name);
|
|
228
|
+
if (resolved instanceof Response)
|
|
229
|
+
return resolved;
|
|
230
|
+
if (resolved.summary) {
|
|
231
|
+
const refPath = treePath.map((segment) => segment.value).join('/');
|
|
232
|
+
return pageError('bad_request', `index '${name}' of '${refPath}' is a summary: each entry stands for every row of its key and names none ${unnamed}`);
|
|
233
|
+
}
|
|
234
|
+
const index = await cachedSegments(storage, repoPath, resolved.manifest, (await storage.objects.stat(repoPath, resolved.manifest)).size);
|
|
235
|
+
const primary = await cachedSegments(storage, repoPath, resolved.primary, (await storage.objects.stat(repoPath, resolved.primary)).size);
|
|
236
|
+
const entryKeyType = segmentKeyTypeOf(resolved.collectionType);
|
|
237
|
+
return { hash: dataset.hash, index, primary, entryKeyType };
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* A window of runs as spans of their rows: the runs' entries `[offset,
|
|
241
|
+
* offset + count)`, counting through them as one sequence.
|
|
242
|
+
*/
|
|
243
|
+
function windowSpans(runs, offset, count) {
|
|
244
|
+
const spans = [];
|
|
245
|
+
let skip = offset;
|
|
246
|
+
let remaining = count;
|
|
247
|
+
for (const [row, length] of runs) {
|
|
248
|
+
if (remaining === 0)
|
|
249
|
+
break;
|
|
250
|
+
if (skip >= length) {
|
|
251
|
+
skip -= length;
|
|
252
|
+
continue;
|
|
253
|
+
}
|
|
254
|
+
const taken = Math.min(length - skip, remaining);
|
|
255
|
+
spans.push({ from: row + skip, to: row + skip + taken });
|
|
256
|
+
remaining -= taken;
|
|
257
|
+
skip = 0;
|
|
258
|
+
}
|
|
259
|
+
return spans;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* The segment of a record that holds each key: a bisect of the record's fences,
|
|
263
|
+
* which its manifest carries, so nothing is read. The greatest segment whose
|
|
264
|
+
* fence is at most the key; segments are disjoint ascending ranges.
|
|
265
|
+
*/
|
|
266
|
+
async function segmentOfKey(primary) {
|
|
267
|
+
const cmp = comparators(segmentKeyTypeOf(primary.typeValue));
|
|
268
|
+
const fences = await Promise.all(Array.from({ length: primary.segmentCount }, (_, i) => primary.fence(i)));
|
|
269
|
+
return (key) => {
|
|
270
|
+
let lo = 0;
|
|
271
|
+
let hi = fences.length - 1;
|
|
272
|
+
while (lo < hi) {
|
|
273
|
+
const mid = (lo + hi + 1) >> 1;
|
|
274
|
+
if (cmp(fences[mid], key) <= 0)
|
|
275
|
+
lo = mid;
|
|
276
|
+
else
|
|
277
|
+
hi = mid - 1;
|
|
278
|
+
}
|
|
279
|
+
return lo;
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=dataset-place.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset-place.js","sourceRoot":"","sources":["../../../src/handlers/dataset-place.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAsB,MAAM,eAAe,CAAC;AAG/E,OAAO,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;IAClD,MAAM,GAAG,GAAG,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,SAAS,CAAE,CAAC,CAAC;IAC9D,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3G,OAAO,CAAC,GAAG,EAAE,EAAE;QACb,IAAI,EAAE,GAAG,CAAC,CAAC;QACX,IAAI,EAAE,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;QAC3B,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;YACf,MAAM,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC;YAC/B,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC;gBAAE,EAAE,GAAG,GAAG,CAAC;;gBACpC,EAAE,GAAG,GAAG,GAAG,CAAC,CAAC;QACpB,CAAC;QACD,OAAO,EAAE,CAAC;IACZ,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2025 Elara AI Pty Ltd
|
|
3
|
+
* Licensed under BSL 1.1. See LICENSE for details.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* What every paged read of a dataset shares: the datasets opened for it, the
|
|
7
|
+
* refusals it answers with, and the rows it reads — a span of a collection's
|
|
8
|
+
* rows, the rows of a Dict by key — through the kept decoded segments
|
|
9
|
+
* (`segments.ts`), each segment read once.
|
|
10
|
+
*
|
|
11
|
+
* @packageDocumentation
|
|
12
|
+
*/
|
|
13
|
+
import { type EastTypeValue, type option } from '@elaraai/east';
|
|
14
|
+
import type { TreePath } from '@elaraai/e3-types';
|
|
15
|
+
import { DatasetSegments, type ResolvedRecordIndex, type StorageBackend } from '@elaraai/e3-core/portable';
|
|
16
|
+
import type { KeySearchTarget } from './key-search.js';
|
|
17
|
+
/** Elements returned per page when the request names no limit. */
|
|
18
|
+
export declare const PAGE_DEFAULT_LIMIT = 1000;
|
|
19
|
+
/** Hard cap on elements per page — and on the queries, keys or runs one batch
|
|
20
|
+
* read takes, and the entries it answers. */
|
|
21
|
+
export declare const PAGE_MAX_LIMIT = 10000;
|
|
22
|
+
/** Default cap on a page's share of the source blob, in bytes. The
|
|
23
|
+
* effective limit shrinks so `limit × avgElementBytes` stays under the
|
|
24
|
+
* budget, bounding page payloads even for very wide rows. Deployments with
|
|
25
|
+
* tighter response limits (e.g. Lambda proxy's 6 MB, base64-inflated) pass
|
|
26
|
+
* a smaller budget through the route options. */
|
|
27
|
+
export declare const PAGE_BYTE_BUDGET_DEFAULT: number;
|
|
28
|
+
/** Opens (or reuses) a stored collection, LRU-cached per backend, repository
|
|
29
|
+
* and content hash, and bounded by retained bytes.
|
|
30
|
+
*
|
|
31
|
+
* All three key parts are load-bearing. An opened dataset holds the backend
|
|
32
|
+
* it reads segment objects through, and a manifest names objects that exist
|
|
33
|
+
* in the repository it was read from and nowhere else — so two backends, or
|
|
34
|
+
* two repositories, that happen to hold the same bytes under the same name
|
|
35
|
+
* must not share an entry. `size` is the object's, when the caller knows it;
|
|
36
|
+
* the opener reads it on a miss otherwise. */
|
|
37
|
+
export declare function cachedSegments(storage: StorageBackend, repoPath: string, hash: string, size?: number): Promise<DatasetSegments>;
|
|
38
|
+
/**
|
|
39
|
+
* Who may keep a hash-pinned answer, which never changes: `private`, the
|
|
40
|
+
* caller's own cache alone (a browser's), or `public`, any cache between it
|
|
41
|
+
* and the server as well (a CDN's). `private` unless a host says otherwise,
|
|
42
|
+
* since an answer holds the rows of a workspace its caller was let read; a
|
|
43
|
+
* host whose data any caller may read opts in to `public`.
|
|
44
|
+
*/
|
|
45
|
+
export type PinnedCache = 'private' | 'public';
|
|
46
|
+
/** The `Cache-Control` of a hash-pinned answer: kept for a year, never
|
|
47
|
+
* revalidated, by the caches {@link PinnedCache} lets keep it. */
|
|
48
|
+
export declare function pinnedCacheControl(cache: PinnedCache | undefined): string;
|
|
49
|
+
/** The opener's refusal of a collection stored as one blob, which an older
|
|
50
|
+
* e3 wrote: answered as `dataset_not_indexed`, in the refusal's own words. */
|
|
51
|
+
export declare const BLOB_REFUSAL: RegExp;
|
|
52
|
+
/** A refusal, answered as JSON: its type, its message and its status. */
|
|
53
|
+
export declare function pageError(type: string, message: string, status?: 400 | 404 | 409 | 413, headers?: Record<string, string>): Response;
|
|
54
|
+
/**
|
|
55
|
+
* A stored collection opened for a read, or the refusal of one stored as one
|
|
56
|
+
* blob, which an older e3 wrote: `dataset_not_indexed`, in the opener's own
|
|
57
|
+
* words. Any other failure is a real one, and raised as it is.
|
|
58
|
+
*
|
|
59
|
+
* @param storage - Storage backend
|
|
60
|
+
* @param repoPath - Repository identifier
|
|
61
|
+
* @param hash - The collection's hash, or a record state naming its primary
|
|
62
|
+
* @param size - The object's size, when the caller knows it
|
|
63
|
+
* @returns The opened collection, or the refusal
|
|
64
|
+
*/
|
|
65
|
+
export declare function openForRead(storage: StorageBackend, repoPath: string, hash: string, size?: number): Promise<DatasetSegments | Response>;
|
|
66
|
+
/** A dataset a paged read reads: its status, and the collection type it holds. */
|
|
67
|
+
export interface ReadDataset {
|
|
68
|
+
/** The content hash it holds now. */
|
|
69
|
+
hash: string;
|
|
70
|
+
/** Its stored size, when the status knows it. */
|
|
71
|
+
size: number | undefined;
|
|
72
|
+
/** Its type. */
|
|
73
|
+
typeValue: EastTypeValue;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The dataset a paged read names, or the refusal its status calls for: no
|
|
77
|
+
* path, a dataset with no value yet, or a pin to content it no longer holds,
|
|
78
|
+
* refused with 409 naming the content it holds now.
|
|
79
|
+
*
|
|
80
|
+
* @param storage - Storage backend
|
|
81
|
+
* @param repoPath - Repository identifier
|
|
82
|
+
* @param workspace - Workspace name
|
|
83
|
+
* @param treePath - The dataset's path
|
|
84
|
+
* @param hash - The content hash the read is pinned to, if any
|
|
85
|
+
* @param what - How the refusal of an empty path names the read
|
|
86
|
+
* @returns The dataset, or the refusal
|
|
87
|
+
*/
|
|
88
|
+
export declare function readDataset(storage: StorageBackend, repoPath: string, workspace: string, treePath: TreePath, hash: string | undefined, what: string): Promise<ReadDataset | Response>;
|
|
89
|
+
/**
|
|
90
|
+
* The segment holding row `row` of a collection: the first whose prefix sum
|
|
91
|
+
* passes it.
|
|
92
|
+
*
|
|
93
|
+
* @param cumulative - The collection's prefix sums of its segments' counts
|
|
94
|
+
* @param row - A row inside the collection
|
|
95
|
+
* @returns The segment's index
|
|
96
|
+
*/
|
|
97
|
+
export declare function segmentOfRow(cumulative: readonly number[], row: number): number;
|
|
98
|
+
/** A span of a collection's rows, `[from, to)`. */
|
|
99
|
+
export interface RowSpan {
|
|
100
|
+
from: number;
|
|
101
|
+
to: number;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The elements of a collection's rows in some spans, in order — an Array's
|
|
105
|
+
* items, a Set's elements, a Dict's `[key, value]` pairs — every segment the
|
|
106
|
+
* spans touch read once, several at a time, through the kept decoded
|
|
107
|
+
* segments.
|
|
108
|
+
*
|
|
109
|
+
* @param storage - The backend the collection is read through
|
|
110
|
+
* @param repo - The repository it is in
|
|
111
|
+
* @param segments - The opened collection
|
|
112
|
+
* @param spans - The rows, each span inside the collection
|
|
113
|
+
* @returns The elements, span after span
|
|
114
|
+
* @throws {SegmentCorruptError} When a segment does not hold what its manifest
|
|
115
|
+
* says of it
|
|
116
|
+
*/
|
|
117
|
+
export declare function elementsOf(storage: StorageBackend, repo: string, segments: DatasetSegments, spans: readonly RowSpan[]): Promise<unknown[]>;
|
|
118
|
+
/**
|
|
119
|
+
* A collection's elements as a value of the collection's own type: the items
|
|
120
|
+
* as an array, the elements as a `SortedSet` or the pairs as a `SortedMap`,
|
|
121
|
+
* under the key type's comparator.
|
|
122
|
+
*
|
|
123
|
+
* @param typeValue - The collection's type: an Array, a Set or a Dict
|
|
124
|
+
* @param elements - Its elements, in canonical order
|
|
125
|
+
* @returns The value
|
|
126
|
+
*/
|
|
127
|
+
export declare function collectionOf(typeValue: EastTypeValue, elements: readonly unknown[]): unknown;
|
|
128
|
+
/**
|
|
129
|
+
* The rows a Dict holds under some keys — each read from the segment its fence
|
|
130
|
+
* places the key in, every such segment read once, several at a time, through
|
|
131
|
+
* the kept decoded segments.
|
|
132
|
+
*
|
|
133
|
+
* @param storage - The backend the Dict is read through
|
|
134
|
+
* @param repo - The repository it is in
|
|
135
|
+
* @param segments - The opened Dict
|
|
136
|
+
* @param keys - The keys, in any order
|
|
137
|
+
* @returns Each key's row, or none, in the keys' order
|
|
138
|
+
* @throws {SegmentCorruptError} When a segment does not hold what its manifest
|
|
139
|
+
* says of it
|
|
140
|
+
*/
|
|
141
|
+
export declare function rowsByKey(storage: StorageBackend, repo: string, segments: DatasetSegments, keys: readonly unknown[]): Promise<option<unknown>[]>;
|
|
142
|
+
/**
|
|
143
|
+
* A corrupt segment, answered as the refusal of the read that met it: a window
|
|
144
|
+
* or a search over a collection that is not canonical (`dataset_not_canonical`),
|
|
145
|
+
* or one writer segment that does not decode alone (`dataset_not_segmented`).
|
|
146
|
+
* Any other failure — a store's — is raised as it is.
|
|
147
|
+
*
|
|
148
|
+
* @param err - What a read threw
|
|
149
|
+
* @param type - The refusal's type
|
|
150
|
+
* @returns The refusal
|
|
151
|
+
* @throws The failure, when it is not a segment's
|
|
152
|
+
*/
|
|
153
|
+
export declare function corruptRefusal(err: unknown, type: 'dataset_not_canonical' | 'dataset_not_segmented'): Response;
|
|
154
|
+
/**
|
|
155
|
+
* One of a record's indexes, resolved at its state for a read, or the refusal
|
|
156
|
+
* of a name the state does not hold, naming the indexes it does — or of a
|
|
157
|
+
* joined read of a summary (#1039), whose entries stand for many rows and name
|
|
158
|
+
* none.
|
|
159
|
+
*
|
|
160
|
+
* @param storage - Storage backend
|
|
161
|
+
* @param repoPath - Repository identifier
|
|
162
|
+
* @param workspace - Workspace name
|
|
163
|
+
* @param treePath - The record's path
|
|
164
|
+
* @param stateHash - The record's state
|
|
165
|
+
* @param name - The index
|
|
166
|
+
* @param join - Whether the read fills each entry's row from the record
|
|
167
|
+
* @returns The resolved index, or the 404 refusal, or the 400 refusal of a joined summary
|
|
168
|
+
*/
|
|
169
|
+
export declare function indexOf(storage: StorageBackend, repoPath: string, workspace: string, treePath: TreePath, stateHash: string, name: string, join?: boolean): Promise<ResolvedRecordIndex | Response>;
|
|
170
|
+
/** The collection a key search searches: the dataset's own, or an index's. */
|
|
171
|
+
export interface SearchTarget extends KeySearchTarget {
|
|
172
|
+
/** The collection's object: the dataset's content, or the index's manifest. */
|
|
173
|
+
hash: string;
|
|
174
|
+
/** Its stored size, when the dataset's status knows it. */
|
|
175
|
+
size: number | undefined;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The collection a key search of a dataset searches, or the refusal of one it
|
|
179
|
+
* cannot: an index the state does not hold, or a collection with no key order.
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* An index selector searches the index's own collection, whose rows the answer
|
|
183
|
+
* is in — the same row space an index page serves — and its forms address the
|
|
184
|
+
* index key, which the collection sorts by first.
|
|
185
|
+
*
|
|
186
|
+
* @param storage - Storage backend
|
|
187
|
+
* @param repoPath - Repository identifier
|
|
188
|
+
* @param workspace - Workspace name
|
|
189
|
+
* @param treePath - The dataset's path
|
|
190
|
+
* @param dataset - The dataset, as its status reads
|
|
191
|
+
* @param index - The index searched, if any
|
|
192
|
+
* @returns The collection, or the refusal
|
|
193
|
+
*/
|
|
194
|
+
export declare function searchTarget(storage: StorageBackend, repoPath: string, workspace: string, treePath: TreePath, dataset: ReadDataset, index: string | undefined): Promise<SearchTarget | Response>;
|
|
195
|
+
/**
|
|
196
|
+
* Opens the collection a key search searches, or refuses one stored as one
|
|
197
|
+
* blob, which an older e3 wrote.
|
|
198
|
+
*
|
|
199
|
+
* @param storage - Storage backend
|
|
200
|
+
* @param repoPath - Repository identifier
|
|
201
|
+
* @param target - The collection
|
|
202
|
+
* @returns The opened collection, or the refusal
|
|
203
|
+
*/
|
|
204
|
+
export declare function openTarget(storage: StorageBackend, repoPath: string, target: SearchTarget): Promise<DatasetSegments | Response>;
|
|
205
|
+
//# sourceMappingURL=dataset-reads.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dataset-reads.d.ts","sourceRoot":"","sources":["../../../src/handlers/dataset-reads.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;;;;;;GAOG;AAEH,OAAO,EAAkF,KAAK,aAAa,EAAE,KAAK,MAAM,EAAE,MAAM,eAAe,CAAC;AAChJ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EACL,eAAe,EAAmE,KAAK,mBAAmB,EAAE,KAAK,cAAc,EAChI,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,kEAAkE;AAClE,eAAO,MAAM,kBAAkB,OAAQ,CAAC;AAExC;8CAC8C;AAC9C,eAAO,MAAM,cAAc,QAAS,CAAC;AAErC;;;;kDAIkD;AAClD,eAAO,MAAM,wBAAwB,QAAkB,CAAC;AAmCxD;;;;;;;;+CAQ+C;AAC/C,wBAAsB,cAAc,CAClC,OAAO,EAAE,cAAc,EACvB,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,CAAC,CAgB1B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE/C;mEACmE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,WAAW,GAAG,SAA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