import type { DataType, Maybe, Primitive } from '../../api/agDataType'; import type { FieldKey } from '../../shared/fieldKey'; import type { AgColumnMetadata } from './agColumnMetadata'; export type ColumnStorageType = 'raw' | 'indexed' | 'typed-array' | 'date' | 'datetime' | 'number'; export interface ColumnExtraData { [key: string]: any; } /** * Base class for column data within result sets. * Provides access to columnar data with type information and storage metadata. */ export interface AgColumnData = ArrayLike, S extends ColumnStorageType = ColumnStorageType, M extends ColumnExtraData = ColumnExtraData> { /** * The underlying data array or typed array. */ readonly data: D; /** * Offset within the data array. */ readonly offset: number; /** * Branded composite key identifying this column. */ readonly fieldKey: FieldKey; /** * Logical data type of values in this column. */ readonly dataType: DataType; /** * Number of elements in this column (may be less than data.length due to offset). */ readonly length: number; /** * Additional metadata about the column (e.g., cardinality, min/max values). */ readonly stats: M; /** * Storage format (raw, indexed, typed-array, or date). */ readonly storageType: S; /** * Get value at the given index. */ get(index: number): Maybe; /** * Materialize the value at the given index. */ materialise(index: number): Maybe; /** * Bulk-materialise values into a plain array. Avoids per-element virtual dispatch * by keeping the hot loop inside the concrete column type. * * @param length Number of values to materialise. * @param indices Optional external indices to select (default: 0..length-1). */ toArray(length: number, indices?: ArrayLike): Maybe[]; /** * Get cardinality (number of unique values), if available. */ getCardinality(): number | undefined; /** * Returns unified metadata about this column. * Provides a stable API without requiring knowledge of storage implementation. */ getMetadata(): AgColumnMetadata; /** * Create a view (subset) of the column from start to end. */ view(start: number, end: number): AgColumnData; }