/** * Codec classes for Native format encoding/decoding. * Each codec handles a specific ClickHouse type. */ import { type Column, JsonColumn } from "./columns.ts"; import { type BufferReader, BufferWriter } from "./io.ts"; import { type DeserializerState, type SerializationNode } from "./serialization.ts"; import { type TypedArray } from "./types.ts"; /** * Sentinel value representing SQL NULL in toLiteral serialization. * Used to distinguish actual NULL from the string "NULL". */ export declare const SQL_NULL: unique symbol; export { toBigInt, toInt16, toInt32, toInt64, toInt8, toNumber, toUInt16, toUInt32, toUInt64, toUInt8, } from "./coercion.ts"; export declare function defaultDeserializerState(): DeserializerState; export interface Codec { /** ClickHouse type string this codec handles */ readonly type: string; encode(col: Column, sizeHint?: number): Uint8Array; decode(reader: BufferReader, rows: number, state: DeserializerState): Column; fromValues(values: unknown[] | TypedArray): Column; zeroValue(): unknown; estimateSize(rows: number): number; writePrefix?(writer: BufferWriter, col: Column): void; readPrefix?(reader: BufferReader): void; readKinds(reader: BufferReader): SerializationNode; /** * Serialize a single value to ClickHouse literal string syntax. * * @param value - The value to serialize * @param quoted - Controls string formatting: * - false (default): For HTTP query params. Control chars escaped, no quotes. * - true: For nested values in Array/Tuple/Map. Fully escaped and single-quoted. * @returns The serialized literal string, or SQL_NULL symbol for null values */ toLiteral(value: unknown, quoted?: boolean): string | typeof SQL_NULL; } /** * Base class for codecs that support sparse serialization. * Centralizes the sparse check pattern - subclasses implement decodeDense(). */ export declare abstract class BaseCodec implements Codec { abstract readonly type: string; abstract encode(col: Column, sizeHint?: number): Uint8Array; abstract fromValues(values: unknown[] | TypedArray): Column; abstract zeroValue(): unknown; abstract estimateSize(rows: number): number; abstract decodeDense(reader: BufferReader, rows: number, state: DeserializerState): Column; abstract serializeLiteral(value: unknown, quoted?: boolean): string; toLiteral(value: unknown, quoted?: boolean): string | typeof SQL_NULL; decode(reader: BufferReader, rows: number, state: DeserializerState): Column; readKinds(reader: BufferReader): SerializationNode; } export declare class JsonCodec implements Codec { readonly type = "JSON"; private typedPaths; private typedPathNames; private dynamicPaths; private dynamicCodecs; constructor(typedPaths?: { name: string; type: string; }[]); writePrefix(writer: BufferWriter, col: Column): void; readPrefix(reader: BufferReader): void; encode(col: Column, sizeHint?: number): Uint8Array; decode(reader: BufferReader, rows: number, state: DeserializerState): JsonColumn; fromValues(values: unknown[]): JsonColumn; private discoverDynamicPaths; zeroValue(): {}; estimateSize(rows: number): number; readKinds(reader: BufferReader): SerializationNode; toLiteral(value: unknown): string | typeof SQL_NULL; } export declare function getCodec(type: string): Codec; //# sourceMappingURL=codecs.d.ts.map