/** * Copyright (c) 2025 Elara AI Pty Ltd * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details. */ /** * The paging runtime's second layer: single reads. A window, fetched pinned or * answered from a landed one that covers it (#1217); one key search, its answer * re-firing its channel with the rest of its burst (#1360); and the rows reads * by key hold at a revision, by key and by position, which a later search or * one-row window is answered from (#1351). * * @packageDocumentation */ import { parseFor, type EastTypeValue } from "@elaraai/east"; import type { DatasetFindQuery } from "@elaraai/e3-api-client"; import type { TreePath } from "@elaraai/e3-types"; import type { PagedSelector, PagedRow } from "./api.js"; import { type PageEntry, type Snapshot, type HeldRows } from "./state.js"; import { PagedChannels } from "./channels.js"; /** * What a spec watches a paging runtime by (test use only), as the Calendar's * frame is watched by its render probe: each landed channel a read looks at as * it seeks one that answers it — a window covering the window it reads * (#1217), or one holding the key it reads the row of (#1351). */ export interface PagedRuntimeProbe { /** Called for each landed channel a read looks at. */ readonly looked?: () => void; } /** * Install (or clear) the probe every paging runtime is watched by. Test use only. * * @param probe - What watches the runtimes; `undefined` clears it */ export declare function setPagedRuntimeProbe(probe: PagedRuntimeProbe | undefined): void; /** * Single windows and searches over the channels, and the rows reads by key hold: the paging runtime's second layer. */ export declare class PagedReads extends PagedChannels { /** Each key type's printer and parser, and each landed Dict window's keys * in order — what reads by key look keys up by (#1351). */ protected readonly printers: WeakMap string>; protected readonly parsers: WeakMap { success: true; value: any; position: number; } | { success: false; error: string; position: number; }>; protected readonly keysOfWindows: WeakMap; /** Start the pinned fetch for a window if it is due one, returning its * channel. */ protected ensureWindow(sourceType: EastTypeValue, workspace: string, path: TreePath, snapshot: Snapshot, revision: string, offset: number, limit: number, selector: PagedSelector, key: string): PageEntry; /** * Answer a window from a landed one of its family that covers it — the * same rows at the same revision (#1217), a window's or one run of a runs * read's (#1351): the cut lands in the window's own channel, so it keeps * one identity, and nothing is fetched. The channel is the snapshot's, so * a move drops the cut with every window. Only the landed windows are * looked at — at most {@link MAX_RETAINED_WINDOWS}, or past it what its * readers hold — never every channel of the revision. * * @param sourceType - The source's type * @param family - The window's family * @param offset - The window's first element * @param limit - How many elements it asks for * @param key - The window's channel's key * @param into - The window's channel, not loaded */ protected cutFromCovering(sourceType: EastTypeValue, family: string, offset: number, limit: number, key: string, into: PageEntry): void; /** * A window in flight that covers a read of `[offset, offset + limit)` of a * family (#1596): the read waits on it, its rows cut from that window once * it lands, rather than asking for them on its own. Only the reads in * flight are looked at, never every channel of the revision. * * @param family - The read's family * @param offset - The read's first element * @param limit - How many elements it asks for * @param key - The read's own channel * @returns The covering window's channel; `undefined` when no window in flight covers it */ protected coveringInFlight(family: string, offset: number, limit: number, key: string): string | undefined; /** Start the pinned fence search for one key query if it is due one, * returning its channel — the seek sibling of {@link ensureWindow}. Its * answer re-fires its channel with the rest of its burst (#1360). */ protected ensureSeek(workspace: string, path: TreePath, snapshot: Snapshot, revision: string, selector: PagedSelector, query: DatasetFindQuery, key: string): PageEntry; /** A printer of a key type's East text, built once per type. */ protected printerOf(keyType: EastTypeValue): (key: unknown) => string; /** A parser of a key type's East text, built once per type. */ protected parserOf(keyType: EastTypeValue): (text: string) => ReturnType>; /** The rows a family's reads by key hold, made empty on first use. */ protected heldRowsOf(snapshot: Snapshot, family: string, keyType: EastTypeValue): HeldRows; /** Hold a read's rows, each by its key and the dataset's by position too; * past {@link MAX_HELD_ROWS}, the family's older rows go first. */ protected hold(snapshot: Snapshot, family: string, keyType: EastTypeValue, rows: readonly PagedRow[]): void; /** The row a landed Dict window of a family holds under a key — or the * key's absence, when the window's span takes it in — and its position. * Only the landed windows are looked at, never every channel of the * revision. */ protected rowInWindows(family: string, keyType: EastTypeValue, key: unknown): PagedRow | undefined; /** A Dict window's keys, in order, listed once per window. */ protected windowKeys(window: ReadonlyMap): readonly unknown[]; /** The row a family's reads by key hold under a key's East text, when they * hold one — what a search by the key answers from (#1351). */ protected heldRow(snapshot: Snapshot, family: string, sourceType: EastTypeValue, literal: string): PagedRow | undefined; } //# sourceMappingURL=reads.d.ts.map