ArrayVector: Add vector field value warning (#73692)

This commit is contained in:
Ihor Yeromin 2023-08-28 21:11:16 +02:00 committed by GitHub
parent a307582212
commit 384a6ad54d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 18 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import { ArrayVector } from './ArrayVector';
describe('Check Appending Vector', () => {
it('should transparently join them', () => {
jest.spyOn(console, 'warn').mockImplementation();
const appended = new AppendedVectors();
appended.append(new ArrayVector([1, 2, 3]));
appended.append(new ArrayVector([4, 5, 6]));

View File

@ -3,6 +3,10 @@ import { Field, FieldType } from '../types';
import { ArrayVector } from './ArrayVector';
describe('ArrayVector', () => {
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation();
});
it('should init 150k with 65k Array.push() chonking', () => {
const arr = Array.from({ length: 150e3 }, (v, i) => i);
const av = new ArrayVector(arr);

View File

@ -1,3 +1,6 @@
const notice = 'ArrayVector is deprecated and will be removed in Grafana 11. Please use plain arrays for field.values.';
let notified = false;
/**
* @public
*
@ -30,6 +33,11 @@ export class ArrayVector<T = any> extends Array<T> {
constructor(buffer?: any[]) {
super();
this.buffer = buffer ?? [];
if (!notified) {
console.warn(notice);
notified = true;
}
}
toJSON(): T[] {

View File

@ -6,6 +6,7 @@ import { ConstantVector } from './ConstantVector';
describe('ScaledVector', () => {
it('should support multiply operations', () => {
jest.spyOn(console, 'warn').mockImplementation();
const source = new ArrayVector([1, 2, 3, 4]);
const scale = 2.456;
const operation = binaryOperators.get(BinaryOperationID.Multiply).operation;

View File

@ -3,6 +3,7 @@ import { SortedVector } from './SortedVector';
describe('SortedVector', () => {
it('Should support sorting', () => {
jest.spyOn(console, 'warn').mockImplementation();
const values = new ArrayVector([1, 5, 2, 4]);
const sorted = new SortedVector(values, [0, 2, 3, 1]);
expect(sorted.toArray()).toEqual([1, 2, 4, 5]);

View File

@ -201,6 +201,7 @@ describe(`Traces Filters`, () => {
});
it('should add a trace filter', async () => {
jest.spyOn(console, 'warn').mockImplementation();
let mockQuery = createMockQuery({ azureTraces: { traceTypes: ['customEvents'] } });
mockQuery.azureTraces = {
...mockQuery.azureTraces,

View File

@ -286,6 +286,7 @@ describe('DataGrid', () => {
});
});
it('should add a new column', async () => {
jest.spyOn(console, 'warn').mockImplementation();
const spy = jest.spyOn(utils, 'updateSnapshot');
jest.useFakeTimers();
render(<DataGridPanel {...props} />, {

View File

@ -6,6 +6,7 @@ describe('when deleting rows', () => {
let df: DataFrame;
beforeEach(() => {
jest.spyOn(console, 'warn').mockImplementation();
df = {
name: 'test',
length: 5,