FieldValues: Use plain arrays instead of Vector (part 1 of 2) (#66187)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
Co-authored-by: Torkel Ödegaard <torkel@grafana.com>
This commit is contained in:
Ryan McKinley
2023-04-14 07:36:53 -05:00
committed by GitHub
co-authored by Leon Sorokin Torkel Ödegaard
parent 4f5b80095e
commit b8188eead4
37 changed files with 531 additions and 292 deletions
@@ -1,4 +1,4 @@
import { Vector, QueryResultMeta } from '../types';
import { QueryResultMeta } from '../types';
import { Field, FieldType, DataFrame } from '../types/dataFrame';
import { FunctionalVector } from '../vector/FunctionalVector';
import { vectorToArray } from '../vector/vectorToArray';
@@ -10,10 +10,12 @@ export type ValueConverter<T = any> = (val: unknown) => T;
const NOOP: ValueConverter = (v) => v;
class ArrayPropertyVector<T = any> implements Vector<T> {
class ArrayPropertyVector<T = any> extends FunctionalVector<T> {
converter = NOOP;
constructor(private source: any[], private prop: string) {}
constructor(private source: any[], private prop: string) {
super();
}
get length(): number {
return this.source.length;