/** * Native format encoder/decoder for ClickHouse. * * Native is ClickHouse's columnar wire format - data doesn't need row-to-column * conversion on the server. * * Note: Only Dynamic/JSON V3 format is supported at present. For ClickHouse 25.6+, enable * `output_format_native_use_flattened_dynamic_and_json_serialization` setting. */ import { type Column, EnumColumn } from "./columns.ts"; import { BufferReader, BufferUnderflowError } from "./io.ts"; import { collectRows, rows } from "./rows.ts"; import { batchFromCols, batchFromRows, type ExternalTableData, type MaterializeOptions, RecordBatch, type Row } from "./table.ts"; import { type ColumnDef, type DecodeOptions } from "./types.ts"; export { ClickHouseDateTime64, type ColumnDef, type DecodeOptions, type DecodeResult, TEXT_DECODER, } from "./types.ts"; export { type Column, RecordBatch, type Row, type MaterializeOptions, EnumColumn }; export { batchFromRows, batchFromCols, type ExternalTableData }; export { rows, collectRows }; export { getCodec } from "./codecs.ts"; export { BlockInfoField, Compression } from "./constants.ts"; export { BufferReader, BufferUnderflowError, BufferWriter, readVarInt64, StreamBuffer, } from "./io.ts"; export interface Block { columns: ColumnDef[]; columnData: Column[]; rowCount: number; decodeTimeMs?: number; } interface BlockResult extends Block { bytesConsumed: number; isEndMarker: boolean; } /** * Partial decode state for resumable decoding. * When underflow occurs mid-block, this captures completed columns * so retry can resume without re-parsing them. */ export interface PartialBlockState { columns: ColumnDef[]; columnData: Column[]; numCols: number; numRows: number; nextColIndex: number; resumeOffset: number; startOffset: number; } /** * Thrown when block decode runs out of data mid-parse. * Contains partial state to enable resumable decoding. */ export declare class BlockUnderflowError extends BufferUnderflowError { readonly partial: PartialBlockState; constructor(message: string, partial: PartialBlockState); } /** * Decode a single Native format block using an existing BufferReader. * Supports resumable decoding: pass partial state from previous underflow to continue. * Throws BlockUnderflowError with partial state if more data is needed. */ export declare function decodeNativeBlockWithReader(reader: BufferReader, options?: DecodeOptions, partial?: PartialBlockState): BlockResult; /** * Decode a single Native format block from a buffer. * Returns the decoded data and the number of bytes consumed. * Use this for streaming scenarios where you need to track buffer position. */ export declare function decodeNativeBlock(data: Uint8Array, offset: number, options?: DecodeOptions): BlockResult; /** * Encode a RecordBatch to Native format. */ export declare function encodeNative(batch: RecordBatch): Uint8Array; /** * Stream encode RecordBatches to Native format. * Each yielded RecordBatch produces one Native block. */ export declare function streamEncodeNative(batches: AsyncIterable): AsyncGenerator; export declare function streamDecodeNative(chunks: AsyncIterable, options?: DecodeOptions & { debug?: boolean; minBufferSize?: number; }): AsyncGenerator; /** * Iterate rows from RecordBatches. * * `RecordBatch` implements the iterable protocol, so you can iterate rows * directly from each batch yielded by `streamDecodeNative()`. * * @example * for await (const batch of streamDecodeNative(query(...))) { * for (const row of batch) { * console.log(row.id, row.name); * } * } */ //# sourceMappingURL=index.d.ts.map