turbodata 0.1.0
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/LICENSE +201 -0
- package/NOTICE +27 -0
- package/README.md +215 -0
- package/dist/compression.d.ts +8 -0
- package/dist/compression.d.ts.map +1 -0
- package/dist/compression.js +19 -0
- package/dist/compression.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +23 -0
- package/dist/index.js.map +1 -0
- package/dist/io.d.ts +37 -0
- package/dist/io.d.ts.map +1 -0
- package/dist/io.js +174 -0
- package/dist/io.js.map +1 -0
- package/dist/iterators/message_heap.d.ts +17 -0
- package/dist/iterators/message_heap.d.ts.map +1 -0
- package/dist/iterators/message_heap.js +83 -0
- package/dist/iterators/message_heap.js.map +1 -0
- package/dist/iterators/preloaded_topics_group_iterator.d.ts +38 -0
- package/dist/iterators/preloaded_topics_group_iterator.d.ts.map +1 -0
- package/dist/iterators/preloaded_topics_group_iterator.js +109 -0
- package/dist/iterators/preloaded_topics_group_iterator.js.map +1 -0
- package/dist/iterators/topics_group_iterator.d.ts +45 -0
- package/dist/iterators/topics_group_iterator.d.ts.map +1 -0
- package/dist/iterators/topics_group_iterator.js +132 -0
- package/dist/iterators/topics_group_iterator.js.map +1 -0
- package/dist/loaded_bytes.d.ts +12 -0
- package/dist/loaded_bytes.d.ts.map +1 -0
- package/dist/loaded_bytes.js +43 -0
- package/dist/loaded_bytes.js.map +1 -0
- package/dist/msgpack.d.ts +10 -0
- package/dist/msgpack.d.ts.map +1 -0
- package/dist/msgpack.js +44 -0
- package/dist/msgpack.js.map +1 -0
- package/dist/multi_reader.d.ts +56 -0
- package/dist/multi_reader.d.ts.map +1 -0
- package/dist/multi_reader.js +281 -0
- package/dist/multi_reader.js.map +1 -0
- package/dist/read_fetcher.d.ts +9 -0
- package/dist/read_fetcher.d.ts.map +1 -0
- package/dist/read_fetcher.js +59 -0
- package/dist/read_fetcher.js.map +1 -0
- package/dist/read_options.d.ts +40 -0
- package/dist/read_options.d.ts.map +1 -0
- package/dist/read_options.js +16 -0
- package/dist/read_options.js.map +1 -0
- package/dist/read_planner.d.ts +37 -0
- package/dist/read_planner.d.ts.map +1 -0
- package/dist/read_planner.js +110 -0
- package/dist/read_planner.js.map +1 -0
- package/dist/read_source.d.ts +19 -0
- package/dist/read_source.d.ts.map +1 -0
- package/dist/read_source.js +15 -0
- package/dist/read_source.js.map +1 -0
- package/dist/read_strategy.d.ts +52 -0
- package/dist/read_strategy.d.ts.map +1 -0
- package/dist/read_strategy.js +70 -0
- package/dist/read_strategy.js.map +1 -0
- package/dist/reader.d.ts +209 -0
- package/dist/reader.d.ts.map +1 -0
- package/dist/reader.js +649 -0
- package/dist/reader.js.map +1 -0
- package/dist/sample.d.ts +41 -0
- package/dist/sample.d.ts.map +1 -0
- package/dist/sample.js +528 -0
- package/dist/sample.js.map +1 -0
- package/dist/sort_and_filter.d.ts +25 -0
- package/dist/sort_and_filter.d.ts.map +1 -0
- package/dist/sort_and_filter.js +126 -0
- package/dist/sort_and_filter.js.map +1 -0
- package/dist/sources/blob.d.ts +8 -0
- package/dist/sources/blob.d.ts.map +1 -0
- package/dist/sources/blob.js +38 -0
- package/dist/sources/blob.js.map +1 -0
- package/dist/sources/http.d.ts +17 -0
- package/dist/sources/http.d.ts.map +1 -0
- package/dist/sources/http.js +90 -0
- package/dist/sources/http.js.map +1 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +29 -0
- package/dist/types.js.map +1 -0
- package/package.json +61 -0
- package/src/compression.ts +28 -0
- package/src/index.ts +70 -0
- package/src/io.ts +214 -0
- package/src/iterators/message_heap.ts +104 -0
- package/src/iterators/preloaded_topics_group_iterator.ts +143 -0
- package/src/iterators/topics_group_iterator.ts +180 -0
- package/src/loaded_bytes.ts +61 -0
- package/src/msgpack.ts +46 -0
- package/src/multi_reader.ts +337 -0
- package/src/read_fetcher.ts +74 -0
- package/src/read_options.ts +58 -0
- package/src/read_planner.ts +153 -0
- package/src/read_source.ts +33 -0
- package/src/read_strategy.ts +111 -0
- package/src/reader.ts +910 -0
- package/src/sample.ts +715 -0
- package/src/sort_and_filter.ts +167 -0
- package/src/sources/blob.ts +52 -0
- package/src/sources/http.ts +121 -0
- package/src/types.ts +110 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { ReadStrategy } from "./read_strategy.js";
|
|
2
|
+
export interface Range {
|
|
3
|
+
/** int64. Absolute file offset. */
|
|
4
|
+
offset: bigint;
|
|
5
|
+
/** int64. Length in bytes. */
|
|
6
|
+
length: bigint;
|
|
7
|
+
}
|
|
8
|
+
export interface ReadOp {
|
|
9
|
+
offset: bigint;
|
|
10
|
+
length: bigint;
|
|
11
|
+
}
|
|
12
|
+
export interface RangeLocation {
|
|
13
|
+
/** Index into the produced ReadOp[]. */
|
|
14
|
+
opIndex: number;
|
|
15
|
+
/** Byte offset within that op's buffer (must fit in number; ops are bounded). */
|
|
16
|
+
inOpOff: number;
|
|
17
|
+
/** Length of this original range, in bytes. */
|
|
18
|
+
length: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Plan groups Ranges into ReadOps.
|
|
22
|
+
*
|
|
23
|
+
* Precondition: ranges must be in non-decreasing offset order. All call sites
|
|
24
|
+
* in this package satisfy this by construction (writer lays out groups and
|
|
25
|
+
* chunks at monotonically increasing file offsets).
|
|
26
|
+
*
|
|
27
|
+
* Algorithm:
|
|
28
|
+
* 1. Coalesce: merge adjacent ranges whose gap is < coalesceGap.
|
|
29
|
+
* 2. Split: a coalesced op whose length exceeds splitThreshold is sliced at
|
|
30
|
+
* internal range boundaries via greedy packing. A single range larger
|
|
31
|
+
* than splitThreshold stays as one oversize op (atomic units never break).
|
|
32
|
+
*/
|
|
33
|
+
export declare function plan(ranges: Range[], s: ReadStrategy): {
|
|
34
|
+
ops: ReadOp[];
|
|
35
|
+
locations: RangeLocation[];
|
|
36
|
+
};
|
|
37
|
+
//# sourceMappingURL=read_planner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_planner.d.ts","sourceRoot":"","sources":["../src/read_planner.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,KAAK;IACpB,mCAAmC;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,8BAA8B;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAQD;;;;;;;;;;;;GAYG;AACH,wBAAgB,IAAI,CAClB,MAAM,EAAE,KAAK,EAAE,EACf,CAAC,EAAE,YAAY,GACd;IAAE,GAAG,EAAE,MAAM,EAAE,CAAC;IAAC,SAAS,EAAE,aAAa,EAAE,CAAA;CAAE,CA0F/C"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
// Copyright 2026 Wanjia He
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
/**
|
|
15
|
+
* Plan groups Ranges into ReadOps.
|
|
16
|
+
*
|
|
17
|
+
* Precondition: ranges must be in non-decreasing offset order. All call sites
|
|
18
|
+
* in this package satisfy this by construction (writer lays out groups and
|
|
19
|
+
* chunks at monotonically increasing file offsets).
|
|
20
|
+
*
|
|
21
|
+
* Algorithm:
|
|
22
|
+
* 1. Coalesce: merge adjacent ranges whose gap is < coalesceGap.
|
|
23
|
+
* 2. Split: a coalesced op whose length exceeds splitThreshold is sliced at
|
|
24
|
+
* internal range boundaries via greedy packing. A single range larger
|
|
25
|
+
* than splitThreshold stays as one oversize op (atomic units never break).
|
|
26
|
+
*/
|
|
27
|
+
export function plan(ranges, s) {
|
|
28
|
+
const locations = new Array(ranges.length);
|
|
29
|
+
if (ranges.length === 0) {
|
|
30
|
+
return { ops: [], locations };
|
|
31
|
+
}
|
|
32
|
+
const groups = [];
|
|
33
|
+
for (let idx = 0; idx < ranges.length; idx++) {
|
|
34
|
+
const r = ranges[idx];
|
|
35
|
+
if (groups.length === 0) {
|
|
36
|
+
groups.push({
|
|
37
|
+
offset: r.offset,
|
|
38
|
+
end: r.offset + r.length,
|
|
39
|
+
members: [idx],
|
|
40
|
+
});
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const cur = groups[groups.length - 1];
|
|
44
|
+
const gap = r.offset - cur.end;
|
|
45
|
+
if (gap >= 0n && gap < s.coalesceGap) {
|
|
46
|
+
const newEnd = r.offset + r.length;
|
|
47
|
+
if (newEnd > cur.end) {
|
|
48
|
+
cur.end = newEnd;
|
|
49
|
+
}
|
|
50
|
+
cur.members.push(idx);
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
groups.push({
|
|
54
|
+
offset: r.offset,
|
|
55
|
+
end: r.offset + r.length,
|
|
56
|
+
members: [idx],
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const ops = [];
|
|
60
|
+
const threshold = s.splitThreshold;
|
|
61
|
+
const splitDisabled = threshold <= 0n;
|
|
62
|
+
for (const g of groups) {
|
|
63
|
+
if (splitDisabled || g.end - g.offset <= threshold) {
|
|
64
|
+
const opIndex = ops.length;
|
|
65
|
+
ops.push({ offset: g.offset, length: g.end - g.offset });
|
|
66
|
+
for (const mi of g.members) {
|
|
67
|
+
const r = ranges[mi];
|
|
68
|
+
locations[mi] = {
|
|
69
|
+
opIndex,
|
|
70
|
+
inOpOff: Number(r.offset - g.offset),
|
|
71
|
+
length: Number(r.length),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
// Greedy split at range boundaries.
|
|
77
|
+
let opStartIdx = 0;
|
|
78
|
+
let opStartOffset = ranges[g.members[0]].offset;
|
|
79
|
+
let opEndOffset = ranges[g.members[0]].offset + ranges[g.members[0]].length;
|
|
80
|
+
const flushOp = (lastMember) => {
|
|
81
|
+
const opIndex = ops.length;
|
|
82
|
+
ops.push({ offset: opStartOffset, length: opEndOffset - opStartOffset });
|
|
83
|
+
for (let k = opStartIdx; k <= lastMember; k++) {
|
|
84
|
+
const mi = g.members[k];
|
|
85
|
+
const r = ranges[mi];
|
|
86
|
+
locations[mi] = {
|
|
87
|
+
opIndex,
|
|
88
|
+
inOpOff: Number(r.offset - opStartOffset),
|
|
89
|
+
length: Number(r.length),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
for (let k = 1; k < g.members.length; k++) {
|
|
94
|
+
const mi = g.members[k];
|
|
95
|
+
const r = ranges[mi];
|
|
96
|
+
const nextEnd = r.offset + r.length;
|
|
97
|
+
if (nextEnd - opStartOffset > threshold) {
|
|
98
|
+
flushOp(k - 1);
|
|
99
|
+
opStartIdx = k;
|
|
100
|
+
opStartOffset = r.offset;
|
|
101
|
+
opEndOffset = nextEnd;
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
opEndOffset = nextEnd;
|
|
105
|
+
}
|
|
106
|
+
flushOp(g.members.length - 1);
|
|
107
|
+
}
|
|
108
|
+
return { ops, locations };
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=read_planner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_planner.js","sourceRoot":"","sources":["../src/read_planner.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAkCjC;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,IAAI,CAClB,MAAe,EACf,CAAe;IAEf,MAAM,SAAS,GAAoB,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAC5D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACxB,OAAO,EAAE,GAAG,EAAE,EAAE,EAAE,SAAS,EAAE,CAAC;IAChC,CAAC;IAED,MAAM,MAAM,GAAoB,EAAE,CAAC;IACnC,KAAK,IAAI,GAAG,GAAG,CAAC,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,GAAG,MAAM,CAAC,GAAG,CAAE,CAAC;QACvB,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,CAAC,IAAI,CAAC;gBACV,MAAM,EAAE,CAAC,CAAC,MAAM;gBAChB,GAAG,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM;gBACxB,OAAO,EAAE,CAAC,GAAG,CAAC;aACf,CAAC,CAAC;YACH,SAAS;QACX,CAAC;QACD,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC;QACvC,MAAM,GAAG,GAAG,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC;QAC/B,IAAI,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B,MAAM,CAAC,GAAG,MAAM,CAAC,EAAE,CAAE,CAAC;YACtB,MAAM,OAAO,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC;YACpC,IAAI,OAAO,GAAG,aAAa,GAAG,SAAS,EAAE,CAAC;gBACxC,OAAO,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;gBACf,UAAU,GAAG,CAAC,CAAC;gBACf,aAAa,GAAG,CAAC,CAAC,MAAM,CAAC;gBACzB,WAAW,GAAG,OAAO,CAAC;gBACtB,SAAS;YACX,CAAC;YACD,WAAW,GAAG,OAAO,CAAC;QACxB,CAAC;QACD,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AAC5B,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ReadSource is the storage abstraction the Reader uses. It is intentionally
|
|
3
|
+
* minimal: every Go ReadAt/Read+Seek call site can be expressed as `read(off,
|
|
4
|
+
* len)`.
|
|
5
|
+
*
|
|
6
|
+
* Concurrency contract: implementations MUST be safe for concurrent `read`
|
|
7
|
+
* calls. The cost-aware reader path issues many in-flight reads bounded only
|
|
8
|
+
* by `maxConcurrency`.
|
|
9
|
+
*/
|
|
10
|
+
export interface ReadSource {
|
|
11
|
+
/** Total length of the underlying file/blob/resource, in bytes. */
|
|
12
|
+
size(): Promise<bigint>;
|
|
13
|
+
/**
|
|
14
|
+
* Read exactly `length` bytes starting at `offset`. Implementations should
|
|
15
|
+
* throw if fewer bytes are available; the Reader assumes a full read.
|
|
16
|
+
*/
|
|
17
|
+
read(offset: bigint, length: bigint): Promise<Uint8Array>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=read_source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_source.d.ts","sourceRoot":"","sources":["../src/read_source.ts"],"names":[],"mappings":"AAcA;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IACzB,mEAAmE;IACnE,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAExB;;;OAGG;IACH,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;CAC3D"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2026 Wanjia He
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=read_source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_source.js","sourceRoot":"","sources":["../src/read_source.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
export interface ReadStrategy {
|
|
2
|
+
/**
|
|
3
|
+
* int64. Byte gap below which two adjacent needed ranges are merged into
|
|
4
|
+
* a single read. 0n disables coalescing.
|
|
5
|
+
*/
|
|
6
|
+
coalesceGap: bigint;
|
|
7
|
+
/**
|
|
8
|
+
* int64. Size above which a merged read is sliced into parallel sub-reads
|
|
9
|
+
* at internal range boundaries. A single range larger than splitThreshold
|
|
10
|
+
* stays as one oversized op (atomic units are never split). 0n or
|
|
11
|
+
* int64-max disables splitting.
|
|
12
|
+
*/
|
|
13
|
+
splitThreshold: bigint;
|
|
14
|
+
/** Max number of in-flight reads. <= 0 is clamped to 1 (serial). */
|
|
15
|
+
maxConcurrency: number;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Strategy that minimizes wall-clock by amortizing per-request RTT and
|
|
19
|
+
* splitting reads at the bandwidth-latency product so each parallel sub-read
|
|
20
|
+
* keeps a stream saturated for ~one RTT.
|
|
21
|
+
*/
|
|
22
|
+
export declare function StrategyForLatency(opts: {
|
|
23
|
+
rttSeconds: number;
|
|
24
|
+
perStreamBytesPerSec: number;
|
|
25
|
+
concurrency: number;
|
|
26
|
+
}): ReadStrategy;
|
|
27
|
+
/**
|
|
28
|
+
* Strategy that minimizes total spend by aggressively coalescing (to save
|
|
29
|
+
* requests) and never splitting (extra splits = extra paid requests).
|
|
30
|
+
*
|
|
31
|
+
* Set bytePrice to 0 for free in-region egress; then coalescing happens
|
|
32
|
+
* regardless of gap.
|
|
33
|
+
*/
|
|
34
|
+
export declare function StrategyForMoney(opts: {
|
|
35
|
+
reqPrice: number;
|
|
36
|
+
bytePrice: number;
|
|
37
|
+
concurrency: number;
|
|
38
|
+
}): ReadStrategy;
|
|
39
|
+
/**
|
|
40
|
+
* Strategy that minimizes spend (via the same money-driven coalesceGap as
|
|
41
|
+
* StrategyForMoney) but caps how long any single read may take by splitting
|
|
42
|
+
* reads larger than maxReadTimeSeconds * perStreamBytesPerSec into parallel
|
|
43
|
+
* sub-reads.
|
|
44
|
+
*/
|
|
45
|
+
export declare function StrategyForBlended(opts: {
|
|
46
|
+
reqPrice: number;
|
|
47
|
+
bytePrice: number;
|
|
48
|
+
maxReadTimeSeconds: number;
|
|
49
|
+
perStreamBytesPerSec: number;
|
|
50
|
+
concurrency: number;
|
|
51
|
+
}): ReadStrategy;
|
|
52
|
+
//# sourceMappingURL=read_strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_strategy.d.ts","sourceRoot":"","sources":["../src/read_strategy.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B;;;OAGG;IACH,WAAW,EAAE,MAAM,CAAC;IAEpB;;;;;OAKG;IACH,cAAc,EAAE,MAAM,CAAC;IAEvB,oEAAoE;IACpE,cAAc,EAAE,MAAM,CAAC;CACxB;AAID;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,UAAU,EAAE,MAAM,CAAC;IACnB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,YAAY,CAUf;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,YAAY,CAUf;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE;IACvC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,YAAY,CAgBf"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
// Copyright 2026 Wanjia He
|
|
2
|
+
//
|
|
3
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
// you may not use this file except in compliance with the License.
|
|
5
|
+
// You may obtain a copy of the License at
|
|
6
|
+
//
|
|
7
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8
|
+
//
|
|
9
|
+
// Unless required by applicable law or agreed to in writing, software
|
|
10
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
|
+
// See the License for the specific language governing permissions and
|
|
13
|
+
// limitations under the License.
|
|
14
|
+
const MAX_INT64 = 0x7fffffffffffffffn;
|
|
15
|
+
/**
|
|
16
|
+
* Strategy that minimizes wall-clock by amortizing per-request RTT and
|
|
17
|
+
* splitting reads at the bandwidth-latency product so each parallel sub-read
|
|
18
|
+
* keeps a stream saturated for ~one RTT.
|
|
19
|
+
*/
|
|
20
|
+
export function StrategyForLatency(opts) {
|
|
21
|
+
let bdp = BigInt(Math.trunc(opts.rttSeconds * opts.perStreamBytesPerSec));
|
|
22
|
+
if (bdp <= 0n) {
|
|
23
|
+
bdp = 1n;
|
|
24
|
+
}
|
|
25
|
+
return {
|
|
26
|
+
coalesceGap: bdp,
|
|
27
|
+
splitThreshold: bdp,
|
|
28
|
+
maxConcurrency: opts.concurrency,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Strategy that minimizes total spend by aggressively coalescing (to save
|
|
33
|
+
* requests) and never splitting (extra splits = extra paid requests).
|
|
34
|
+
*
|
|
35
|
+
* Set bytePrice to 0 for free in-region egress; then coalescing happens
|
|
36
|
+
* regardless of gap.
|
|
37
|
+
*/
|
|
38
|
+
export function StrategyForMoney(opts) {
|
|
39
|
+
let gap = MAX_INT64;
|
|
40
|
+
if (opts.bytePrice > 0) {
|
|
41
|
+
gap = BigInt(Math.trunc(opts.reqPrice / opts.bytePrice));
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
coalesceGap: gap,
|
|
45
|
+
splitThreshold: MAX_INT64,
|
|
46
|
+
maxConcurrency: opts.concurrency,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Strategy that minimizes spend (via the same money-driven coalesceGap as
|
|
51
|
+
* StrategyForMoney) but caps how long any single read may take by splitting
|
|
52
|
+
* reads larger than maxReadTimeSeconds * perStreamBytesPerSec into parallel
|
|
53
|
+
* sub-reads.
|
|
54
|
+
*/
|
|
55
|
+
export function StrategyForBlended(opts) {
|
|
56
|
+
let gap = MAX_INT64;
|
|
57
|
+
if (opts.bytePrice > 0) {
|
|
58
|
+
gap = BigInt(Math.trunc(opts.reqPrice / opts.bytePrice));
|
|
59
|
+
}
|
|
60
|
+
let split = BigInt(Math.trunc(opts.maxReadTimeSeconds * opts.perStreamBytesPerSec));
|
|
61
|
+
if (split <= 0n) {
|
|
62
|
+
split = MAX_INT64;
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
coalesceGap: gap,
|
|
66
|
+
splitThreshold: split,
|
|
67
|
+
maxConcurrency: opts.concurrency,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=read_strategy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"read_strategy.js","sourceRoot":"","sources":["../src/read_strategy.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,EAAE;AACF,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,iDAAiD;AACjD,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAwBjC,MAAM,SAAS,GAAG,mBAAmB,CAAC;AAEtC;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAIlC;IACC,IAAI,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC1E,IAAI,GAAG,IAAI,EAAE,EAAE,CAAC;QACd,GAAG,GAAG,EAAE,CAAC;IACX,CAAC;IACD,OAAO;QACL,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,GAAG;QACnB,cAAc,EAAE,IAAI,CAAC,WAAW;KACjC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB,CAAC,IAIhC;IACC,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QACvB,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,OAAO;QACL,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,SAAS;QACzB,cAAc,EAAE,IAAI,CAAC,WAAW;KACjC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,IAMlC;IACC,IAAI,GAAG,GAAG,SAAS,CAAC;IACpB,IAAI,IAAI,CAAC,SAAS,GAAG,CAAC,EAAE,CAAC;QACvB,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC;IAC3D,CAAC;IACD,IAAI,KAAK,GAAG,MAAM,CAChB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,oBAAoB,CAAC,CAChE,CAAC;IACF,IAAI,KAAK,IAAI,EAAE,EAAE,CAAC;QAChB,KAAK,GAAG,SAAS,CAAC;IACpB,CAAC;IACD,OAAO;QACL,WAAW,EAAE,GAAG;QAChB,cAAc,EAAE,KAAK;QACrB,cAAc,EAAE,IAAI,CAAC,WAAW;KACjC,CAAC;AACJ,CAAC"}
|
package/dist/reader.d.ts
ADDED
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import type { Decompressor } from "./compression.js";
|
|
2
|
+
import type { ReadOptions } from "./read_options.js";
|
|
3
|
+
import type { ReadSource } from "./read_source.js";
|
|
4
|
+
import type { ReadStrategy } from "./read_strategy.js";
|
|
5
|
+
import { type Summary } from "./types.js";
|
|
6
|
+
export interface Message {
|
|
7
|
+
/** int64 nanosecond (or arbitrary unit) timestamp from the writer. */
|
|
8
|
+
timestamp: bigint;
|
|
9
|
+
topicName: string;
|
|
10
|
+
/**
|
|
11
|
+
* Message bytes. By default this aliases an internal reusable buffer and
|
|
12
|
+
* is only valid until the next iteration step. Pass `{ copy: true }` to
|
|
13
|
+
* receive a fresh Uint8Array per message.
|
|
14
|
+
*/
|
|
15
|
+
data: Uint8Array;
|
|
16
|
+
}
|
|
17
|
+
export interface ReaderOptions {
|
|
18
|
+
/** Override the default fzstd decompressor (e.g. for a WASM zstd build). */
|
|
19
|
+
decompress?: Decompressor;
|
|
20
|
+
/**
|
|
21
|
+
* Present in-file topic names under different exposed names. Keyed by in-file
|
|
22
|
+
* name, valued by the exposed name emitted from readMessages, accepted by
|
|
23
|
+
* ReadOptions.topicNames and SampleQuery.topic, and reported by summary().
|
|
24
|
+
* Names absent from the map pass through unchanged; omitting it means
|
|
25
|
+
* identity (no behavior change).
|
|
26
|
+
*
|
|
27
|
+
* Validated lazily against the file's summary on first use: it throws a
|
|
28
|
+
* TopicRemapError when two topics collapse onto the same exposed name
|
|
29
|
+
* (whether two in-file names map to the same target, or a renamed name
|
|
30
|
+
* collides with an untouched in-file name).
|
|
31
|
+
*/
|
|
32
|
+
topicRemap?: Record<string, string>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Thrown when a configured topic remap collapses two in-file topics onto the
|
|
36
|
+
* same exposed name. Detected lazily against the summary on first use.
|
|
37
|
+
*/
|
|
38
|
+
export declare class TopicRemapError extends Error {
|
|
39
|
+
readonly exposed: string;
|
|
40
|
+
readonly first: string;
|
|
41
|
+
readonly second: string;
|
|
42
|
+
constructor(exposed: string, first: string, second: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* One sampling request: the floor message of `topic` at each timestamp.
|
|
46
|
+
* Within `timestamps`, values must be strictly increasing, and the same
|
|
47
|
+
* `topic` must not appear in more than one query in a single sample() call.
|
|
48
|
+
*/
|
|
49
|
+
export interface SampleQuery {
|
|
50
|
+
topic: string;
|
|
51
|
+
/** int64 timestamps; strictly increasing. */
|
|
52
|
+
timestamps: bigint[];
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* One coded video frame surfaced as part of a SampleResult's GOP prefix or
|
|
56
|
+
* incremental tail. `data` is an owned copy and is safe to retain.
|
|
57
|
+
*/
|
|
58
|
+
export interface Frame {
|
|
59
|
+
timestamp: bigint;
|
|
60
|
+
isKeyFrame: boolean;
|
|
61
|
+
data: Uint8Array;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* One returned floor message. out[i][j] corresponds to queries[i].timestamps[j].
|
|
65
|
+
* `found` is false when there is no message with timestamp <= timestamps[j]
|
|
66
|
+
* for the topic.
|
|
67
|
+
*
|
|
68
|
+
* Without videoDecodable, every topic (including video topics) returns its
|
|
69
|
+
* floor message in `data` (an owned copy), `isVideo` is false, and `frames` /
|
|
70
|
+
* `resetDecoder` are unset.
|
|
71
|
+
*
|
|
72
|
+
* With videoDecodable, results for video topics instead carry a decoder-ready
|
|
73
|
+
* GOP sequence and set `isVideo` true. For those results, within a single row
|
|
74
|
+
* (one topic, strictly increasing query timestamps):
|
|
75
|
+
*
|
|
76
|
+
* - `data` is empty; the frame bytes live in `frames` and the target frame
|
|
77
|
+
* is the last element. `timestamp` names that target frame.
|
|
78
|
+
* - For the first found result in each GOP encountered in the row:
|
|
79
|
+
* `resetDecoder` is true, `frames` = [keyframe ... target] in storage
|
|
80
|
+
* (decode) order. The decoder must reset before feeding.
|
|
81
|
+
* - For subsequent found results within the same GOP: `resetDecoder` is
|
|
82
|
+
* false, `frames` = [previous_target+1 ... target] (only the new frames).
|
|
83
|
+
* `frames` is empty when two queries resolve to the same target frame;
|
|
84
|
+
* `timestamp` still names that target.
|
|
85
|
+
*/
|
|
86
|
+
export interface SampleResult {
|
|
87
|
+
found: boolean;
|
|
88
|
+
timestamp: bigint;
|
|
89
|
+
data: Uint8Array;
|
|
90
|
+
isVideo: boolean;
|
|
91
|
+
frames: Frame[];
|
|
92
|
+
resetDecoder: boolean;
|
|
93
|
+
}
|
|
94
|
+
/** Options for Reader.sample(). */
|
|
95
|
+
export interface SampleOptions {
|
|
96
|
+
/**
|
|
97
|
+
* Cost model for the concurrent reads. Defaults to DEFAULT_SAMPLE_STRATEGY,
|
|
98
|
+
* which is sized for a cloud-object / in-region profile.
|
|
99
|
+
*/
|
|
100
|
+
strategy?: ReadStrategy;
|
|
101
|
+
/**
|
|
102
|
+
* int64. Bytes to read speculatively from the file tail when loading the
|
|
103
|
+
* summary. Same semantics as ReadOptions.tailPrefetch.
|
|
104
|
+
*/
|
|
105
|
+
tailPrefetch?: bigint;
|
|
106
|
+
/**
|
|
107
|
+
* When true, results for video topics carry a decoder-ready GOP sequence
|
|
108
|
+
* (frames + resetDecoder) and set isVideo. See SampleResult. Non-video
|
|
109
|
+
* topics are unaffected. Default: false.
|
|
110
|
+
*/
|
|
111
|
+
videoDecodable?: boolean;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Default strategy for Reader.sample when none is supplied. Mirrors the Go and
|
|
115
|
+
* Python DEFAULT_SAMPLE_STRATEGY (1 MiB coalesce, 4 MiB split, 16-way fanout).
|
|
116
|
+
*/
|
|
117
|
+
export declare const DEFAULT_SAMPLE_STRATEGY: ReadStrategy;
|
|
118
|
+
/**
|
|
119
|
+
* Aggregated precondition failures from Reader.sample, raised before any data
|
|
120
|
+
* I/O. `violations` lists every problem found across all queries.
|
|
121
|
+
*/
|
|
122
|
+
export declare class SampleValidationError extends Error {
|
|
123
|
+
readonly violations: string[];
|
|
124
|
+
constructor(violations: string[]);
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* N timestamps starting at `start`, each `stride` apart. Useful for "N samples
|
|
128
|
+
* at a given frequency from T" patterns. Mirrors Go LinSpaceTimestamps.
|
|
129
|
+
* Returns [] when count <= 0; throws when stride <= 0 (would break the
|
|
130
|
+
* strictly-increasing contract on SampleQuery.timestamps).
|
|
131
|
+
*/
|
|
132
|
+
export declare function linSpaceTimestamps(start: bigint, stride: bigint, count: number): bigint[];
|
|
133
|
+
/**
|
|
134
|
+
* Per-exposed-topic span used by MultiReader. `isVideo` flags a video topic
|
|
135
|
+
* (always a single-topic group); [minTs, maxTs] is the inclusive timestamp
|
|
136
|
+
* span of the topic's messages. Mirrors go topicBound / py _TopicBound.
|
|
137
|
+
*
|
|
138
|
+
* @internal
|
|
139
|
+
*/
|
|
140
|
+
export interface TopicBound {
|
|
141
|
+
isVideo: boolean;
|
|
142
|
+
minTs: bigint;
|
|
143
|
+
maxTs: bigint;
|
|
144
|
+
}
|
|
145
|
+
export declare class Reader {
|
|
146
|
+
private readonly rs;
|
|
147
|
+
private readonly decompress;
|
|
148
|
+
private cachedSize;
|
|
149
|
+
private cachedSummary;
|
|
150
|
+
private boundsCache;
|
|
151
|
+
private readonly topicRemap;
|
|
152
|
+
private renamePrepared;
|
|
153
|
+
private renameInverse;
|
|
154
|
+
private renameErr;
|
|
155
|
+
constructor(rs: ReadSource, opts?: ReaderOptions);
|
|
156
|
+
/**
|
|
157
|
+
* Build the exposed -> in-file inverse map once the summary is known and
|
|
158
|
+
* validate that no two topics collapse onto the same exposed name. Results
|
|
159
|
+
* (including any error) are cached. Returns undefined when no remap is set.
|
|
160
|
+
*/
|
|
161
|
+
private prepareRename;
|
|
162
|
+
/**
|
|
163
|
+
* Return a copy of `summary` with TopicMetadata.name rewritten to exposed
|
|
164
|
+
* names. Index-chunk lists and metadata maps are shared (read-only here).
|
|
165
|
+
* Returns the original summary when no remap is configured.
|
|
166
|
+
*/
|
|
167
|
+
private exposedSummary;
|
|
168
|
+
/**
|
|
169
|
+
* Returns the parsed summary, loading and caching it on first call. When a
|
|
170
|
+
* topic remap is configured, TopicMetadata.name reports exposed names.
|
|
171
|
+
*/
|
|
172
|
+
summary(): Promise<Summary>;
|
|
173
|
+
private summaryWithHint;
|
|
174
|
+
/**
|
|
175
|
+
* Read messages. Returns an async iterable; iterating consumes lazily.
|
|
176
|
+
*
|
|
177
|
+
* Concurrency note: because the iterator carries internal mutable state
|
|
178
|
+
* (cursors and a reusable buffer), only one iteration at a time over the
|
|
179
|
+
* same returned async iterable is supported.
|
|
180
|
+
*/
|
|
181
|
+
readMessages(opts?: ReadOptions): AsyncIterableIterator<Message>;
|
|
182
|
+
/**
|
|
183
|
+
* Floor-message lookup at concrete timestamps per topic. For each
|
|
184
|
+
* (queries[i].topic, queries[i].timestamps[j]) pair, out[i][j] is the
|
|
185
|
+
* message with the greatest timestamp <= timestamps[j], or found=false when
|
|
186
|
+
* none exists.
|
|
187
|
+
*
|
|
188
|
+
* Preconditions, validated before any data I/O (all violations aggregated
|
|
189
|
+
* into a single SampleValidationError):
|
|
190
|
+
* - each queries[i].timestamps must be strictly increasing
|
|
191
|
+
* - each queries[i].topic must be unique across all i
|
|
192
|
+
* - each queries[i].topic must exist in the file's summary
|
|
193
|
+
*
|
|
194
|
+
* All data I/O runs concurrently under the hood, governed by the strategy.
|
|
195
|
+
*/
|
|
196
|
+
sample(queries: SampleQuery[], opts?: SampleOptions): Promise<SampleResult[][]>;
|
|
197
|
+
/**
|
|
198
|
+
* Per-exposed-topic bounds, computed once from the cached summary. Honors any
|
|
199
|
+
* configured remap so keys are exposed names. Used by MultiReader to merge
|
|
200
|
+
* streams and enforce video time-disjointness. Mirrors go (*Reader).topicBounds
|
|
201
|
+
* and py Reader._topic_bounds.
|
|
202
|
+
*
|
|
203
|
+
* @internal
|
|
204
|
+
*/
|
|
205
|
+
topicBounds(): Promise<Map<string, TopicBound>>;
|
|
206
|
+
private prepareDefault;
|
|
207
|
+
private prepareCostAware;
|
|
208
|
+
}
|
|
209
|
+
//# sourceMappingURL=reader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reader.d.ts","sourceRoot":"","sources":["../src/reader.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,YAAY,E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