import { DataTypeFieldConfig, DataTypeFields, Maybe } from '@terascope/types'; import { WritableData } from '../core/index.js'; import { ListVector, Vector, VectorType } from '../vector/index.js'; /** * Since Vectors are immutable, a Builder can be used to construct a * Vector. When values are inserted they are coerced and validated. */ export declare abstract class Builder { /** * Make an instance of a Builder from a DataTypeFieldConfig */ static make(data: WritableData, options: BuilderOptions): Builder; /** * Convert a Vector to a Builder with current values * populated depending on the length populated */ static makeFromVector(vector: Vector, size: number): Builder; /** * The type of Vector, this should only be set with the specific Vector type classes. */ readonly type: VectorType; /** * The field type configuration */ readonly config: Readonly; /** * When Vector is an object type, this will be the data type fields * for the object */ readonly childConfig?: DataTypeFields; /** * @internal */ readonly data: WritableData; /** * The name of field, if specified this will just be used for metadata */ readonly name?: string; /** * Used for optimizations to noop certain functions and save memory where possible */ private isEmpty; /** * The current insertion index (used for append) */ currentIndex: number; constructor( /** * This will be set automatically by specific Builder classes */ type: VectorType, data: WritableData, options: BuilderOptions); /** * Convert a value to the internal in-memory storage format for the Vector */ abstract _valueFrom(value: unknown): T; /** * Convert a value to the internal in-memory storage format for the Vector */ valueFrom(value: unknown, indices?: number | Iterable): T; private _throwValueFromError; /** * Set value by index */ set(index: number, value: unknown): this; /** * Set a single unique value on multiple indices */ mset(value: unknown, indices: Iterable): this; /** * Append a value to the end */ append(value: unknown): this; /** * Resize the amount of records stored in in the * writable data structure */ resize(size: number): this; /** * Flush and convert the result to a Vector */ toVector(): Vector; } /** * Returns true if the input is a Builder */ export declare function isBuilder(input: unknown): input is Builder; /** * Coerce a value so it can be stored in the builder */ export type ValueFromFn = (value: unknown) => T; /** * A list of Builder Options */ export interface BuilderOptions { /** * The type config for any nested fields (currently only works for objects) */ childConfig?: DataTypeFields; /** * The field config */ config: DataTypeFieldConfig | Readonly; /** * The name of field, if specified this will just be used for metadata */ name?: string; } /** * Copy the values from a Vector to a Builder */ export declare function copyVectorToBuilder(vector: Vector | ListVector, builder: Builder): Vector; /** * Copy the values from a Vector to a Builder */ export declare function transformVectorToBuilder(vector: Vector | ListVector, builder: Builder, transform: (value: T | readonly Maybe[], index: number) => Maybe | readonly Maybe[]): Vector; //# sourceMappingURL=Builder.d.ts.map