Chore: Stop using ArrayVector and MutableField (#67333)

This commit is contained in:
Ryan McKinley
2023-04-26 15:28:54 -07:00
committed by GitHub
parent 353e11b771
commit 5c4ecf7a86
4 changed files with 17 additions and 20 deletions

View File

@@ -7,6 +7,7 @@ import { FunctionalVector } from '../vector/FunctionalVector';
import { guessFieldTypeFromValue, guessFieldTypeForField, toDataFrameDTO } from './processDataFrame';
/** @deprecated */
export type MutableField<T = any> = Field<T>;
type MutableVectorCreator = (buffer?: any[]) => any[];
@@ -65,14 +66,14 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
return this.first.length;
}
addFieldFor(value: unknown, name?: string): MutableField {
addFieldFor(value: unknown, name?: string): Field {
return this.addField({
name: name || '', // Will be filled in
type: guessFieldTypeFromValue(value),
});
}
addField(f: Field | FieldDTO, startLength?: number): MutableField {
addField(f: Field | FieldDTO, startLength?: number): Field {
let buffer: any[] | undefined = undefined;
if (f.values) {
@@ -98,7 +99,7 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
name = `Field ${this.fields.length + 1}`;
}
const field: MutableField = {
const field: Field = {
...f,
name,
type,

View File

@@ -1,6 +1,5 @@
import { map } from 'rxjs/operators';
import { MutableField } from '../../dataframe/MutableDataFrame';
import { guessFieldTypeForField } from '../../dataframe/processDataFrame';
import { getFieldDisplayName } from '../../field/fieldState';
import { DataFrame, Field, FieldType } from '../../types/dataFrame';
@@ -63,7 +62,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
// Group the values by fields and groups so we can get all values for a
// group for a given field.
const valuesByGroupKey = new Map<string, Record<string, MutableField>>();
const valuesByGroupKey = new Map<string, Record<string, Field>>();
for (let rowIndex = 0; rowIndex < frame.length; rowIndex++) {
const groupKey = String(groupByFields.map((field) => field.values[rowIndex]));
const valuesByField = valuesByGroupKey.get(groupKey) ?? {};