import { Schema, TypeMap } from 'apache-arrow'; import { TTableSchema } from '../../thrift/TCLIService_types'; /** * Sum the row counts of every RecordBatch message in an Arrow IPC * stream, WITHOUT materializing the Arrow vector tree. * * Why this exists: `ArrowResultConverter` consumes `ArrowBatch` objects * that carry an explicit `rowCount`, but the kernel's IPC payload only * carries per-RecordBatch `length` (no separate total). `KernelResultsProvider` * needs that count to build the `ArrowBatch` it hands to the converter — * which then re-decodes the same bytes for the actual values. * * The previous implementation used `RecordBatchReader` and iterated the * batches, which calls `_loadVectors` and materializes the full vector * tree for every batch just to read `numRows` and discard everything * else — ~2x Arrow decode CPU + transient allocation on the fetch hot * path. `MessageReader` instead reads only each message's FlatBuffer * metadata header (where `RecordBatch.length` lives) and skips the body * bytes, so no vectors are decoded here. The converter's later re-decode * is the only real materialization. * * `ipcBytes` must already be Duration-patched (row count is unaffected * by the Duration→Int64 rewrite, and the framing is unchanged). Returns * 0 for an empty / schema-only stream. */ export declare function countRowsInIpc(ipcBytes: Buffer): number; /** * Decode an Arrow IPC schema payload (no record batches) into the * apache-arrow Schema object. */ export declare function decodeIpcSchema(ipcBytes: Buffer): Schema; /** * Pre-process raw IPC bytes from the kernel so they're consumable by * `apache-arrow@13`. The current transformation is `Duration → Int64` * with the original duration unit preserved in field metadata (see * `KernelArrowIpcDurationFix.ts`). Returned bytes are byte-identical to * the input when no transformation is needed. * * Exposed so callers can pre-patch the buffer **once** and pass the * result through both `decodeIpcBatch` (for row-count extraction in * `KernelResultsProvider`) and `ArrowResultConverter.fetchNext` (which * re-decodes the same bytes via `RecordBatchReader.from`). Without * this, the converter would re-throw on `Duration` because it never * sees the patched bytes. */ export declare function patchIpcBytes(ipcBytes: Buffer): Buffer; /** * Synthesize a Thrift `TTableSchema` from an Arrow schema decoded out * of the kernel's IPC stream. Used by `KernelOperationBackend.getResultMetadata` * to drive `ArrowResultConverter.convertThriftTypes` (Phase 2) without * changing that code. */ export declare function arrowSchemaToThriftSchema(arrowSchema: Schema): TTableSchema;