import { DataTypeConfig } from '@terascope/types'; import { Column, KeyAggregation, ValueAggregation } from '../column/index.js'; import { FieldArg } from '../core/index.js'; /** * A deferred execution frame dedicated to running aggregations. * * This is different from a DataFrame for a few reasons: * - GroupBy and aggregations have to run at the same time in-order to get the correct results. * - The operations are added to an instruction set and in one optimized execution. * - All methods in the AggregationFrame will mutate the execution * instructions instead of returning a new instance with the applied changes. */ export declare class AggregationFrame> { /** * The name of the Frame */ name?: string; /** * The list of columns */ columns: readonly Column[]; /** * An array of the column names */ fields: readonly (keyof T)[]; /** * Metadata about the Frame */ readonly metadata: Record; /** * The field to sort by * @internal */ protected _sortFields?: (readonly (keyof T)[]) | (readonly string[]); /** * The number of records to limit the result by */ protected _limit?: number; /** * The Aggregations to run */ protected readonly _aggregations: Map; /** * Group By fields */ protected _groupByFields: readonly (keyof T)[]; /** * The field to sort by */ protected _selectFields?: readonly (keyof T)[]; /** * Use this to cache the the column index needed, this * should speed things up */ protected _fieldToColumnIndexCache?: Map<(keyof T), number>; /** * When using mergeBy... similar to groupBy as groups by the unique fields but * if more than 1 is found it uses the last value and also merges fields * i.e. mergeBy("foo") * makes this [ { foo: a, bar: b, one: one }, { foo: a, bar: c, two: two } ] * turn into [ { foo: a, bar: c, one: one, two: two }, { foo: b, bar: b2 } ] */ private _merge?; constructor(columns: Column[] | readonly Column[], options: AggregationFrameOptions); /** * Get the number of records in the AggregationFrame */ get size(): number; /** * Generate the DataType config from the columns. */ get config(): DataTypeConfig; get id(): string; /** * GroupBy fields */ groupBy(...fieldArg: FieldArg[]): this; /** * MergeBy fields */ mergeBy(...fieldArg: FieldArg[]): this; /** * Calculate the average value in a column * * @note only works numeric data types * * @param field the name of the column to run the aggregation on * @param as a optional name for the new column with the aggregated values */ [ValueAggregation.avg](field: keyof T): this; [ValueAggregation.avg](field: keyof T, as: A): AggregationFrame>; /** * Add all of the values in a column together * * @note only works numeric data types * * @param field the name of the column to run the aggregation on * @param as a optional name for the new column with the aggregated values */ [ValueAggregation.sum](field: keyof T): this; [ValueAggregation.sum](field: keyof T, as: A): AggregationFrame>; /** * Find the minimum value in a column * * @note only works numeric data types * * @param field the name of the column to run the aggregation on * @param as a optional name for the new column with the aggregated values */ [ValueAggregation.min](field: keyof T): this; [ValueAggregation.min](field: keyof T, as: A): AggregationFrame>; /** * Find the maximum value in a column * * @note only works numeric data types * * @param field the name of the column to run the aggregation on * @param as a optional name for the new column with the aggregated values */ [ValueAggregation.max](field: keyof T): this; [ValueAggregation.max](field: keyof T, as: A): AggregationFrame>; /** * Count all of the values in a column * * @param field the name of the column to run the aggregation on * @param as a optional name for the new column with the aggregated values */ [ValueAggregation.count](field: keyof T): this; [ValueAggregation.count](field: keyof T, as: A): AggregationFrame>; /** * Group the data in hourly buckets * * @note only works Date data types * * @param field the name of the column to run the aggregation on */ [KeyAggregation.hourly](field: keyof T): this; /** * Group the data in daily buckets * * @note only works Date data types * * @param field the name of the column to run the aggregation on */ [KeyAggregation.daily](field: keyof T): this; /** * Group the data in monthly buckets * * @note only works Date data types * * @param field the name of the column to run the aggregation on */ [KeyAggregation.monthly](field: keyof T): this; /** * Group the data in yearly buckets * * @note only works Date data types * * @param field the name of the column to run the aggregation on */ [KeyAggregation.yearly](field: keyof T): this; /** * Order the rows by fields, format of is `field:asc` or `field:desc`. * Defaults to `asc` if none specified */ orderBy(...fieldArgs: FieldArg[]): this; orderBy(...fieldArgs: FieldArg[]): this; /** * Sort the records by a field, an alias of orderBy. * * @see orderBy */ sort(...fieldArgs: FieldArg[]): this; sort(...fieldArgs: FieldArg[]): this; /** * Limit the number of results being returned */ limit(num: number): this; /** * After the aggregations run, return only these selected fields */ select(...fieldArg: FieldArg[]): AggregationFrame>; /** * Get a column by name */ getColumn

(field: P): Column | undefined; /** * Get a column by name or throw if not found */ getColumnOrThrow

(field: P): Column; /** * Get a column by index */ getColumnAt

(index: number): Column | undefined; /** * Rename an existing column */ rename(name: K, renameTo: R): AggregationFrame & Record>; /** * Assign new columns, if given a column already exists, * the column will replace the existing one. */ assign = Record>(columns: readonly Column[]): AggregationFrame; private _ensureColumn; private _ensureNumericLike; /** * Execute the aggregations and flatten the grouped data. * Assigns the new columns to this. * * @todo move the limit and sort logic to here */ execute(): Promise; /** * Reset the Aggregations */ reset(): this; private _generateBuckets; private _generateBuilders; private _buildBucket; /** * this is slower version of the aggregation * that will select a specific row that shows more * correct information, like for min and max */ private _buildBucketWithAdjustedRowIndex; private _aggregationBuilders; } type AggObject = { key?: KeyAggregation; value?: ValueAggregation; }; type WithAlias, A extends string, V> = { [P in (keyof T) | A]: V; }; /** * AggregationFrame options */ export interface AggregationFrameOptions { name?: string; metadata?: Record; } export {}; //# sourceMappingURL=AggregationFrame.d.ts.map