/** * @license MIT * @author Teffen Ellis, et al. * @copyright Sister Software */ /** * The handler may return a value synchronously or as a promise; `undefined` skips the record. */ export type SegmentHandler = (record: Uint8Array, ctx: { index: number; segmentIndex: number; }) => unknown; export interface RunSegmentIO { records: AsyncIterable; handleRecord: SegmentHandler; segmentIndex: number; batchSize: number; maxInFlight: number; post: (batch: unknown[], transfer: ArrayBuffer[]) => void; waitForAck: () => Promise; inFlight: () => number; /** * Polled before each record. Once true the loop stops, the open batch is discarded, and `records` is closed through * its iterator's `return()`. A pooled worker uses it when the consumer leaves early, because the worker outlives the * call and cannot simply be terminated. */ isCancelled?: () => boolean; } /** * Drive one segment: read records, run the handler, accumulate results into `batchSize` batches, transfer `Uint8Array` * result buffers zero-copy, and respect a bounded in-flight window by awaiting an ack before exceeding `maxInFlight` * outstanding batches. Results of `undefined` are skipped (the filter case). Transport-agnostic so it unit-tests * without `worker_threads`. */ export declare function runSegment(io: RunSegmentIO): Promise; //# sourceMappingURL=segment-runtime.d.ts.map