/** * ╔══════════════════════════════════════════════════════════════════════╗ * ║ EXP-30 BAKE-OFF CANDIDATE D — object-per-batch writes + async rollup. ║ * ╚══════════════════════════════════════════════════════════════════════╝ * * The hybrid: keep Candidate B's flat-cost write path (immutable create-once part * objects, sidecar lease — inherited wholesale from {@link ObjectPerBatchStrategy}) * and bolt on an ASYNCHRONOUS in-segment consolidation that folds settled tail * parts into a single `rollup` object. The aim is **B's write profile with A's * read profile** (EXP-30 §Candidate D). * * Layout (extends B's `parts/` + `.lease`): * `/parts/.jsonl` immutable batch parts (B, unchanged) * `/.lease` sidecar lease (B, unchanged) * `/rollup.jsonl` consolidated prefix `[0, X)` of the segment * * **Read model.** The logical segment is `rollup[0, X)` ++ the un-rolled tail * parts `[X..)`, where X = the rollup object's byte length (the high-water mark — * the rollup *is* its own marker: its length is exactly how far consolidation has * folded). A full read is ONE big GET (the rollup) + a GET per un-rolled tail * part, instead of B's GET-per-part across the whole segment. Frequent * consolidation keeps the tail short, so read fan-out stays O(1 + small tail) — * Candidate A's read shape — while appends stay flat (B's write shape). * * **Consolidation** runs on the lease-holding producer, OFF the append hot path: * each `appendBlock` only bumps an in-memory counter; once enough tail parts have * accumulated, a fire-and-forget pass GETs the current rollup, concatenates the * contiguous tail parts after the high-water mark, and PUTs the new rollup fenced * with `If-Match` on the rollup's ETag (so a stale pass can't clobber a newer * one). The append never waits on it. * * **Parts are retained, not deleted** (within the live segment). Deleting folded * parts would bound the LIST too, but races an in-flight reader holding an older * rollup view; the EXP-30 design defers that to a grace-period sweep. Here we keep * the read provably gap-free (rollup + ALL tail parts ≥ X are always present) and * measure D's GET-fan-out read win, which is its core advantage over B. */ import type { AppendBlockOptions, AppendResult, RangeReadResult } from '../../types.js'; import { ObjectPerBatchStrategy } from './objectPerBatch.js'; import type { S3AppendStrategyName, S3CompactionResult } from './types.js'; export declare class HybridRollupStrategy extends ObjectPerBatchStrategy { readonly name: S3AppendStrategyName; /** Parts appended since the last consolidation trigger, per segment path. Avoids a per-append LIST. */ private readonly partsSinceConsolidation; /** Paths with a consolidation pass currently in flight (so we don't stack them). */ private readonly consolidating; appendBlock(path: string, bytes: Buffer, options: AppendBlockOptions): Promise; /** * Rollup length (high-water mark) via a cheap HEAD — NOT a full GET. The * tail-follow read path only needs X to decide whether the requested window * touches the rollup; pulling the whole (multi-MB, growing) rollup body on * every poll just to read its length was the steady-state throughput killer * for Candidate D (EXP-30b real-S3: D breached at 500/s). Absent rollup → 0. */ private rollupLength; /** Read the rollup object's current length + ETag. Absent rollup → length 0. */ private readRollup; /** Ranged GET of the rollup object. Used by the read path to avoid pulling the whole rollup. */ private rangeReadRollup; /** * Fold the contiguous tail parts after the rollup high-water mark into a new * rollup. Fenced with `If-Match` on the rollup ETag so a stale pass cannot * clobber a newer one (and `If-None-Match: *` for the first-ever rollup). */ private consolidate; /** Expose B's protected object GET to this subclass for part/rollup reads. */ private getPartBytes; readSegment(path: string): Promise; rangeReadSegment(path: string, start: number, end: number): Promise; compactSegment(srcPath: string, dstPath: string): Promise; } //# sourceMappingURL=hybridRollup.d.ts.map