import { type Column, DynamicColumn, JsonColumn, VariantColumn } from "../columns.ts"; import { type BufferReader, BufferWriter } from "../io.ts"; import type { DeserializerState } from "../serialization.ts"; import { type TypedArray, VariantValue } from "../types.ts"; import { type Codec, type GenContext, SQL_NULL } from "./base.ts"; export type CodecResolver = (type: string) => Codec; /** * VariantCodec handles Variant(T1, T2, ...) types. * * Implements instead extending BaseCodec because: * - Variant has its own null representation (discriminator=255) * - Sparse serialization applies to children, not variant itself * - Discriminators are always dense-encoded * * Children (variant groups) may be sparse-encoded individually. */ export declare class VariantCodec implements Codec { readonly type: string; private typeStrings; private codecs; private primitiveDisc; constructor(typeStrings: string[], codecs: Codec[]); writePrefix(writer: BufferWriter, col: Column): void; readPrefix(reader: BufferReader, state: DeserializerState): void; encode(col: Column, sizeHint?: number): Uint8Array; decode(reader: BufferReader, rows: number, state: DeserializerState): VariantColumn; fromValues(values: unknown[]): VariantColumn; zeroValue(): null; estimateSize(rows: number): number; findVariantIndex(value: unknown, types: string[]): number; readKinds(reader: BufferReader): import("../serialization.ts").SerializationNode; toLiteral(value: unknown): string | typeof SQL_NULL; generate(ctx: GenContext): VariantValue | null; compare(a: unknown, b: unknown): boolean; } export declare class DynamicCodec implements Codec { readonly type = "Dynamic"; private resolveCodec; constructor(resolveCodec: CodecResolver); writePrefix(writer: BufferWriter, col: Column): void; readPrefix(reader: BufferReader, state: DeserializerState): void; encode(col: Column, sizeHint?: number): Uint8Array; decode(reader: BufferReader, rows: number, state: DeserializerState): DynamicColumn; fromValues(values: unknown[]): DynamicColumn; /** * Build a column from sparse data: `values[j]` belongs to row * `rowIndices[j]`; every other row is null. `rowIndices` must be strictly * ascending — group values are stored in scan order, so out-of-order or * duplicate indices pair rows with the wrong values. `rowIndices === null` * means identity (`values[j]` is row `j`), with rows past `values.length` * null. Lets JsonCodec scatter only the keys a row actually has instead of * materializing a dense rows-length array per path. */ fromSparse(rowIndices: number[] | null, values: unknown[], rows: number): DynamicColumn; zeroValue(): null; estimateSize(rows: number): number; guessType(value: unknown): string; readKinds(reader: BufferReader): { kind: number; children: never[]; }; toLiteral(value: unknown): string | typeof SQL_NULL; /** * Generate an explicit-typed Dynamic value (`DynamicValue`). * * `DynamicCodec` has no type universe at construction (types are discovered * from the wire), so the type is sampled from the harness-injected pool via * `ctx.pickDynamicType()`. Wrapping the sampled value in a `DynamicValue` * carries the type through `fromValues`, which otherwise re-derives the * discriminator from the runtime value via `guessType` and would collapse the * full type space onto `guessType` fixed points. This makes the whole pool * reachable for nested Dynamic (Array(Dynamic), JSON dynamic paths), matching * how standalone Dynamic columns are generated. * * `null` exercises the null discriminator (`types.length`). */ generate(ctx: GenContext): unknown; /** * `a` is the generated value (possibly a DynamicValue carrying an explicit * type); `b` is the decoded bare value. The inner values are in the canonical * representation `DynamicColumn.get` returns. */ compare(a: unknown, b: unknown): boolean; } export declare class JsonCodec implements Codec { readonly type: string; private typedPaths; private typedPathNames; private typedPathNameList; private resolveCodec; constructor(resolveCodec: CodecResolver, typedPaths?: { name: string; type: string; }[], type?: string); private dynamicPathsOf; writePrefix(writer: BufferWriter, col: Column): void; readPrefix(reader: BufferReader, state: DeserializerState): void; encode(col: Column, sizeHint?: number): Uint8Array; decode(reader: BufferReader, rows: number, state: DeserializerState): JsonColumn; fromValues(values: unknown[]): JsonColumn; fromCols(input: Record): JsonColumn; private assembleColumn; zeroValue(): {}; estimateSize(rows: number): number; readKinds(reader: BufferReader): import("../serialization.ts").SerializationNode; toLiteral(value: unknown): string | typeof SQL_NULL; /** * Generate a random JSON object from the typed paths (matching * `JsonColumn.get`): each typed path via its codec, null values omitted since * `JsonColumn.get` omits null paths on decode. Dynamic paths are scheduled by * the fuzz harness (per-column path-presence shapes) and merged on top. */ generate(ctx: GenContext): Record; /** * Compare two JSON objects under the null-path-omission rule: a path absent in * one side equals a null/absent path in the other (`JsonColumn.get` omits null * paths). Typed paths compare via their codec. Dynamic paths carry a generated * `DynamicValue` (explicit type) on side `a` and a bare decoded value on side * `b`; compare via the declared type's codec so type-aware equality (Float32 * precision, Decimal scale, DateTime64 ticks) applies, falling back to a * structural compare when neither side is type-tagged. */ compare(a: unknown, b: unknown): boolean; } //# sourceMappingURL=dynamic.d.ts.map