FieldValues: Use simple array in transformations and grafana/data (#66702)

Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
Ryan McKinley
2023-04-17 14:02:51 -07:00
committed by GitHub
co-authored by Leon Sorokin
parent 19ebb079ba
commit 50cb4f8998
55 changed files with 197 additions and 214 deletions
@@ -13,6 +13,8 @@ interface AppendedVectorInfo<T> {
* This may be more trouble than it is worth. This trades some computation time for
* RAM -- rather than allocate a new array the size of all previous arrays, this just
* points the correct index to their original array values
*
* @deprecated use a simple Arrays
*/
export class AppendedVectors<T = any> extends FunctionalVector<T> {
length = 0;
@@ -60,7 +62,7 @@ export class AppendedVectors<T = any> extends FunctionalVector<T> {
for (let i = 0; i < this.source.length; i++) {
const src = this.source[i];
if (index >= src.start && index < src.end) {
return src.values.get(index - src.start);
return src.values[index - src.start];
}
}
return undefined as unknown as T;
@@ -6,6 +6,7 @@ import { FunctionalVector } from './FunctionalVector';
* This will force all values to be numbers
*
* @public
* @deprecated use a simple Arrays
*/
export class AsNumberVector extends FunctionalVector<number> {
constructor(private field: Vector) {
@@ -6,6 +6,7 @@ import { vectorToArray } from './vectorToArray';
/**
* @public
* @deprecated use a simple Arrays
*/
export class BinaryOperationVector extends FunctionalVector<number> {
constructor(private left: Vector<number>, private right: Vector<number>, private operation: BinaryOperation) {
@@ -14,6 +14,7 @@ interface CircularOptions<T> {
* to match a configured capacity.
*
* @public
* @deprecated use a simple Arrays
*/
export class CircularVector<T = any> extends FunctionalVector<T> {
private buffer: T[];
@@ -2,6 +2,7 @@ import { FunctionalVector } from './FunctionalVector';
/**
* @public
* @deprecated use a simple Arrays
*/
export class ConstantVector<T = any> extends FunctionalVector<T> {
constructor(private value: T, private len: number) {
@@ -6,6 +6,7 @@ import { FunctionalVector } from './FunctionalVector';
/**
* @public
* @deprecated use a simple Arrays
*/
export class FormattedVector<T = any> extends FunctionalVector<string> {
constructor(private source: Vector<T>, private formatter: DisplayProcessor) {
@@ -2,7 +2,10 @@ import { Vector } from '../types';
import { vectorToArray } from './vectorToArray';
/** @public */
/**
* @public
* @deprecated use a simple Arrays
*/
export abstract class FunctionalVector<T = any> implements Vector<T> {
abstract get length(): number;
@@ -187,6 +190,8 @@ const emptyarray: any[] = [];
/**
* Use functional programming with your vector
*
* @deprecated use a simple Arrays
*/
export function vectorator<T>(vector: Vector<T>) {
return {
@@ -6,6 +6,7 @@ import { vectorToArray } from './vectorToArray';
/**
* RowVector makes the row values look like a vector
* @internal
* @deprecated use a simple Arrays
*/
export class RowVector extends FunctionalVector<number> {
constructor(private columns: Vector[]) {