mirror of
https://github.com/grafana/grafana.git
synced 2025-01-27 08:47:12 -06:00
FieldValues: Use plain arrays instead of Vector (part 2 of 2) (#66224)
Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
parent
6d53c87862
commit
e65163ba4e
@ -45,18 +45,19 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "14"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "16"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "17"]
|
||||
],
|
||||
"packages/grafana-data/src/dataframe/dimensions.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -72,26 +73,29 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "4"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "5"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "6"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "7"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "8"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "10"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "14"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "13"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "15"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "17"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "19"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "18"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "20"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "21"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "23"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "22"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "23"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "24"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "26"]
|
||||
],
|
||||
"packages/grafana-data/src/datetime/datemath.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -273,7 +277,8 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/groupBy.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/groupingToMatrix.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -285,9 +290,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/joinDataFrames.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/merge.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
@ -297,9 +299,7 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"packages/grafana-data/src/transformations/transformers/reduce.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "3"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"packages/grafana-data/src/types/OptionsUIRegistryBuilder.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -3287,8 +3287,7 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/features/search/service/bluge.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "2"]
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/features/search/service/sql.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -4585,10 +4584,7 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/plugins/datasource/jaeger/testResponse.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/jaeger/types.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
@ -5120,15 +5116,9 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"public/app/plugins/datasource/zipkin/utils/testData.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/zipkin/utils/testResponse.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/zipkin/utils/transforms.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
@ -5796,7 +5786,9 @@ exports[`better eslint`] = {
|
||||
],
|
||||
"public/app/plugins/panel/nodeGraph/utils.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"public/app/plugins/panel/piechart/PieChart.tsx:5381": [
|
||||
[0, 0, 0, "Use data-testid for E2E selectors instead of aria-label", "0"]
|
||||
|
@ -1,4 +1,3 @@
|
||||
import { ArrayVector } from '..';
|
||||
import { DataFrame, FieldType } from '../types/dataFrame';
|
||||
|
||||
import { DataFrameJSON, dataFrameFromJSON, dataFrameToJSON } from './DataFrameJSON';
|
||||
@ -203,13 +202,13 @@ describe('DataFrame JSON', () => {
|
||||
name: 'time1',
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector([11, 12, 13]),
|
||||
values: [11, 12, 13],
|
||||
},
|
||||
{
|
||||
name: 'time2',
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector([14, 15, 16]),
|
||||
values: [14, 15, 16],
|
||||
nanos: [17, 18, 19],
|
||||
},
|
||||
],
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { DataFrame, FieldType, FieldConfig, Labels, QueryResultMeta, Field } from '../types';
|
||||
import { ArrayVector } from '../vector';
|
||||
|
||||
import { guessFieldTypeFromNameAndValue } from './processDataFrame';
|
||||
|
||||
@ -203,7 +202,7 @@ export function dataFrameFromJSON(dto: DataFrameJSON): DataFrame {
|
||||
...f,
|
||||
type: type ?? guessFieldType(f.name, buffer),
|
||||
config: f.config ?? {},
|
||||
values: new ArrayVector(buffer),
|
||||
values: buffer,
|
||||
// the presence of this prop is an optimization signal & lookup for consumers
|
||||
entities: entities ?? {},
|
||||
};
|
||||
@ -242,7 +241,7 @@ export function dataFrameToJSON(frame: DataFrame): DataFrameJSON {
|
||||
fields: frame.fields.map((f) => {
|
||||
const { values, nanos, state, display, ...sfield } = f;
|
||||
delete (sfield as any).entities;
|
||||
data.values.push(values.toArray());
|
||||
data.values.push(values);
|
||||
|
||||
if (nanos != null) {
|
||||
allNanos.push(nanos);
|
||||
|
@ -15,15 +15,15 @@ describe('Reversing DataFrame', () => {
|
||||
|
||||
const helper = new MutableDataFrame(frame);
|
||||
|
||||
expect(helper.fields[0].values.toArray()).toEqual([100, 200, 300]);
|
||||
expect(helper.fields[1].values.toArray()).toEqual(['a', 'b', 'c']);
|
||||
expect(helper.fields[2].values.toArray()).toEqual([1, 2, 3]);
|
||||
expect(helper.fields[0].values).toEqual([100, 200, 300]);
|
||||
expect(helper.fields[1].values).toEqual(['a', 'b', 'c']);
|
||||
expect(helper.fields[2].values).toEqual([1, 2, 3]);
|
||||
|
||||
helper.reverse();
|
||||
|
||||
expect(helper.fields[0].values.toArray()).toEqual([300, 200, 100]);
|
||||
expect(helper.fields[1].values.toArray()).toEqual(['c', 'b', 'a']);
|
||||
expect(helper.fields[2].values.toArray()).toEqual([3, 2, 1]);
|
||||
expect(helper.fields[0].values).toEqual([300, 200, 100]);
|
||||
expect(helper.fields[1].values).toEqual(['c', 'b', 'a']);
|
||||
expect(helper.fields[2].values).toEqual([3, 2, 1]);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -39,7 +39,7 @@ describe('Apending DataFrame', () => {
|
||||
};
|
||||
|
||||
const frame = new MutableDataFrame(dto);
|
||||
expect(frame.fields[0].values.toArray()).toEqual([100, undefined, undefined]);
|
||||
expect(frame.fields[0].values).toEqual([100, undefined, undefined]);
|
||||
|
||||
// Set a value on the second row
|
||||
frame.set(1, { time: 200, name: 'BB', value: 20 });
|
||||
|
@ -2,16 +2,14 @@ import { isString } from 'lodash';
|
||||
|
||||
import { QueryResultMeta } from '../types/data';
|
||||
import { Field, DataFrame, DataFrameDTO, FieldDTO, FieldType } from '../types/dataFrame';
|
||||
import { Vector } from '../types/vector';
|
||||
import { makeFieldParser } from '../utils/fieldParser';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
import { FunctionalVector } from '../vector/FunctionalVector';
|
||||
|
||||
import { guessFieldTypeFromValue, guessFieldTypeForField, toDataFrameDTO } from './processDataFrame';
|
||||
|
||||
export type MutableField<T = any> = Field<T>;
|
||||
|
||||
type MutableVectorCreator = (buffer?: any[]) => Vector;
|
||||
type MutableVectorCreator = (buffer?: any[]) => any[];
|
||||
|
||||
export const MISSING_VALUE = undefined; // Treated as connected in new graph panel
|
||||
|
||||
@ -21,7 +19,7 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
|
||||
meta?: QueryResultMeta;
|
||||
fields: MutableField[] = [];
|
||||
|
||||
private first: Vector = new ArrayVector();
|
||||
private first: any[] = [];
|
||||
private creator: MutableVectorCreator;
|
||||
|
||||
constructor(source?: DataFrame | DataFrameDTO, creator?: MutableVectorCreator) {
|
||||
@ -31,7 +29,7 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
|
||||
this.creator = creator
|
||||
? creator
|
||||
: (buffer?: any[]) => {
|
||||
return new ArrayVector(buffer);
|
||||
return buffer ?? [];
|
||||
};
|
||||
|
||||
// Copy values from
|
||||
@ -78,11 +76,7 @@ export class MutableDataFrame<T = any> extends FunctionalVector<T> implements Da
|
||||
let buffer: any[] | undefined = undefined;
|
||||
|
||||
if (f.values) {
|
||||
if (Array.isArray(f.values)) {
|
||||
buffer = f.values;
|
||||
} else {
|
||||
buffer = (f.values as Vector).toArray();
|
||||
}
|
||||
buffer = f.values;
|
||||
}
|
||||
|
||||
let type = f.type;
|
||||
|
@ -22,10 +22,8 @@ import {
|
||||
DataQueryResponseData,
|
||||
PanelData,
|
||||
LoadingState,
|
||||
GraphSeriesValue,
|
||||
} from '../types/index';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
import { SortedVector } from '../vector/SortedVector';
|
||||
import { vectorToArray } from '../vector/vectorToArray';
|
||||
|
||||
import { ArrayDataFrame } from './ArrayDataFrame';
|
||||
import { dataFrameFromJSON } from './DataFrameJSON';
|
||||
@ -38,7 +36,7 @@ function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
return {
|
||||
name: text?.length ? text : c, // rename 'text' to the 'name' field
|
||||
config: (disp || {}) as FieldConfig,
|
||||
values: new ArrayVector(),
|
||||
values: [] as any[],
|
||||
type: type && Object.values(FieldType).includes(type as FieldType) ? (type as FieldType) : FieldType.other,
|
||||
};
|
||||
});
|
||||
@ -49,7 +47,7 @@ function convertTableToDataFrame(table: TableData): DataFrame {
|
||||
|
||||
for (const row of table.rows) {
|
||||
for (let i = 0; i < fields.length; i++) {
|
||||
fields[i].values.buffer.push(row[i]);
|
||||
fields[i].values.push(row[i]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -87,7 +85,7 @@ function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {
|
||||
name: TIME_SERIES_TIME_FIELD_NAME,
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector<number>(times),
|
||||
values: times,
|
||||
},
|
||||
{
|
||||
name: TIME_SERIES_VALUE_FIELD_NAME,
|
||||
@ -95,7 +93,7 @@ function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {
|
||||
config: {
|
||||
unit: timeSeries.unit,
|
||||
},
|
||||
values: new ArrayVector<TimeSeriesValue>(values),
|
||||
values: values,
|
||||
labels: timeSeries.tags,
|
||||
},
|
||||
];
|
||||
@ -118,13 +116,13 @@ function convertTimeSeriesToDataFrame(timeSeries: TimeSeries): DataFrame {
|
||||
* to DataFrame. See: https://github.com/grafana/grafana/issues/18528
|
||||
*/
|
||||
function convertGraphSeriesToDataFrame(graphSeries: GraphSeriesXY): DataFrame {
|
||||
const x = new ArrayVector();
|
||||
const y = new ArrayVector();
|
||||
const x: GraphSeriesValue[] = [];
|
||||
const y: GraphSeriesValue[] = [];
|
||||
|
||||
for (let i = 0; i < graphSeries.data.length; i++) {
|
||||
const row = graphSeries.data[i];
|
||||
x.buffer.push(row[1]);
|
||||
y.buffer.push(row[0]);
|
||||
x.push(row[1]);
|
||||
y.push(row[0]);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -145,7 +143,7 @@ function convertGraphSeriesToDataFrame(graphSeries: GraphSeriesXY): DataFrame {
|
||||
values: y,
|
||||
},
|
||||
],
|
||||
length: x.buffer.length,
|
||||
length: x.length,
|
||||
};
|
||||
}
|
||||
|
||||
@ -159,12 +157,12 @@ function convertJSONDocumentDataToDataFrame(timeSeries: TimeSeries): DataFrame {
|
||||
unit: timeSeries.unit,
|
||||
filterable: (timeSeries as any).filterable,
|
||||
},
|
||||
values: new ArrayVector(),
|
||||
values: [] as TimeSeriesValue[][],
|
||||
},
|
||||
];
|
||||
|
||||
for (const point of timeSeries.datapoints) {
|
||||
fields[0].values.buffer.push(point);
|
||||
fields[0].values.push(point);
|
||||
}
|
||||
|
||||
return {
|
||||
@ -392,7 +390,7 @@ export const toLegacyResponseData = (frame: DataFrame): TimeSeries | TableData =
|
||||
return {
|
||||
alias: fields[0].name || frame.name,
|
||||
target: fields[0].name || frame.name,
|
||||
datapoints: fields[0].values.toArray(),
|
||||
datapoints: fields[0].values,
|
||||
filterable: fields[0].config ? fields[0].config.filterable : undefined,
|
||||
type: 'docs',
|
||||
} as TimeSeries;
|
||||
@ -436,7 +434,7 @@ export function sortDataFrame(data: DataFrame, sortIndex?: number, reverse = fal
|
||||
fields: data.fields.map((f) => {
|
||||
return {
|
||||
...f,
|
||||
values: new SortedVector(f.values, index),
|
||||
values: f.values.map((v, i) => f.values[index[i]]),
|
||||
};
|
||||
}),
|
||||
};
|
||||
@ -449,11 +447,11 @@ export function reverseDataFrame(data: DataFrame): DataFrame {
|
||||
return {
|
||||
...data,
|
||||
fields: data.fields.map((f) => {
|
||||
const copy = [...f.values.toArray()];
|
||||
copy.reverse();
|
||||
const values = [...f.values];
|
||||
values.reverse();
|
||||
return {
|
||||
...f,
|
||||
values: new ArrayVector(copy),
|
||||
values,
|
||||
};
|
||||
}),
|
||||
};
|
||||
@ -480,11 +478,7 @@ export function toDataFrameDTO(data: DataFrame): DataFrameDTO {
|
||||
export function toFilteredDataFrameDTO(data: DataFrame, fieldPredicate?: (f: Field) => boolean): DataFrameDTO {
|
||||
const filteredFields = fieldPredicate ? data.fields.filter(fieldPredicate) : data.fields;
|
||||
const fields: FieldDTO[] = filteredFields.map((f) => {
|
||||
let values = f.values.toArray();
|
||||
// The byte buffers serialize like objects
|
||||
if (values instanceof Float64Array) {
|
||||
values = vectorToArray(f.values);
|
||||
}
|
||||
let values = f.values;
|
||||
return {
|
||||
name: f.name,
|
||||
type: f.type,
|
||||
|
@ -3,7 +3,6 @@ import { createTheme } from '../themes';
|
||||
import { FieldConfig, FieldType, ThresholdsMode } from '../types';
|
||||
import { DisplayProcessor, DisplayValue } from '../types/displayValue';
|
||||
import { MappingType, ValueMapping } from '../types/valueMapping';
|
||||
import { ArrayVector } from '../vector';
|
||||
|
||||
import { getDisplayProcessor, getRawDisplayProcessor } from './displayProcessor';
|
||||
|
||||
@ -548,7 +547,7 @@ describe('Date display options', () => {
|
||||
field: {
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector([Date.parse('2020-08-01T08:48:43.783337Z'), Date.parse('2020-08-01T08:49:15.123456Z')]),
|
||||
values: [Date.parse('2020-08-01T08:48:43.783337Z'), Date.parse('2020-08-01T08:49:15.123456Z')],
|
||||
},
|
||||
theme: createTheme(),
|
||||
});
|
||||
@ -562,7 +561,7 @@ describe('Date display options', () => {
|
||||
field: {
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector([Date.parse('2020-08-01T08:49:15.123456Z'), Date.parse('2020-08-01T08:43:43.783337Z')]),
|
||||
values: [Date.parse('2020-08-01T08:49:15.123456Z'), Date.parse('2020-08-01T08:43:43.783337Z')],
|
||||
},
|
||||
theme: createTheme(),
|
||||
});
|
||||
@ -578,7 +577,7 @@ describe('Date display options', () => {
|
||||
config: {
|
||||
unit: 'time:YYYY-MM-DD HH:mm',
|
||||
},
|
||||
values: new ArrayVector([Date.parse('2020-08-01T08:48:43.783337Z'), Date.parse('2020-08-01T08:49:15.123456Z')]),
|
||||
values: [Date.parse('2020-08-01T08:48:43.783337Z'), Date.parse('2020-08-01T08:49:15.123456Z')],
|
||||
},
|
||||
theme: createTheme(),
|
||||
});
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { createTheme } from '../themes';
|
||||
import { Field, FieldColorModeId, FieldType } from '../types';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { fieldColorModeRegistry, FieldValueColorCalculator, getFieldSeriesColor } from './fieldColor';
|
||||
|
||||
@ -8,7 +7,7 @@ function getTestField(mode: string, fixedColor?: string): Field {
|
||||
return {
|
||||
name: 'name',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
config: {
|
||||
color: {
|
||||
mode: mode,
|
||||
@ -54,7 +53,7 @@ describe('fieldColorModeRegistry', () => {
|
||||
field.config.color!.seriesBy = 'last';
|
||||
// min = -10, max = 10, last = 5
|
||||
// last percent 75%
|
||||
field.values = new ArrayVector([0, -10, 5, 10, 2, 5]);
|
||||
field.values = [0, -10, 5, 10, 2, 5];
|
||||
|
||||
const color = getFieldSeriesColor(field, createTheme());
|
||||
const calcFn = getCalculator({ mode: 'continuous-GrYlRd' });
|
||||
@ -77,7 +76,7 @@ describe('fieldColorModeRegistry', () => {
|
||||
|
||||
describe('getFieldSeriesColor', () => {
|
||||
const field = getTestField('continuous-GrYlRd');
|
||||
field.values = new ArrayVector([0, -10, 5, 10, 2, 5]);
|
||||
field.values = [0, -10, 5, 10, 2, 5];
|
||||
|
||||
it('When color.seriesBy is last use that to calc series color', () => {
|
||||
field.config.color!.seriesBy = 'last';
|
||||
|
@ -17,7 +17,6 @@ import {
|
||||
} from '../types';
|
||||
import { locationUtil, Registry } from '../utils';
|
||||
import { mockStandardProperties } from '../utils/tests/mockStandardProperties';
|
||||
import { ArrayVector } from '../vector';
|
||||
|
||||
import { FieldConfigOptionsRegistry } from './FieldConfigOptionsRegistry';
|
||||
import { getDisplayProcessor } from './displayProcessor';
|
||||
@ -1010,14 +1009,14 @@ describe('applyRawFieldOverrides', () => {
|
||||
const numberAsEpoc: Field = {
|
||||
name: 'numberAsEpoc',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1599045551050]),
|
||||
values: [1599045551050],
|
||||
config: getNumberFieldConfig(),
|
||||
};
|
||||
|
||||
const numberWithDecimals: Field = {
|
||||
name: 'numberWithDecimals',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3.14159265359]),
|
||||
values: [3.14159265359],
|
||||
config: {
|
||||
...getNumberFieldConfig(),
|
||||
decimals: 3,
|
||||
@ -1027,28 +1026,28 @@ describe('applyRawFieldOverrides', () => {
|
||||
const numberAsBoolean: Field = {
|
||||
name: 'numberAsBoolean',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([0]),
|
||||
values: [0],
|
||||
config: getNumberFieldConfig(),
|
||||
};
|
||||
|
||||
const boolean: Field = {
|
||||
name: 'boolean',
|
||||
type: FieldType.boolean,
|
||||
values: new ArrayVector([0]),
|
||||
values: [0],
|
||||
config: getEmptyConfig(),
|
||||
};
|
||||
|
||||
const string: Field = {
|
||||
name: 'string',
|
||||
type: FieldType.boolean,
|
||||
values: new ArrayVector(['A - string']),
|
||||
values: ['A - string'],
|
||||
config: getEmptyConfig(),
|
||||
};
|
||||
|
||||
const datetime: Field = {
|
||||
name: 'datetime',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1599045551050]),
|
||||
values: [1599045551050],
|
||||
config: {
|
||||
unit: 'dateTimeAsIso',
|
||||
},
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { createTheme } from '../themes';
|
||||
import { ThresholdsMode, Field, FieldType, FieldColorModeId } from '../types';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { getScaleCalculator } from './scale';
|
||||
import { sortThresholds } from './thresholds';
|
||||
@ -17,7 +16,7 @@ describe('getScaleCalculator', () => {
|
||||
name: 'test',
|
||||
config: { thresholds: { mode: ThresholdsMode.Absolute, steps: sortThresholds(thresholds) } },
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([0, 50, 100]),
|
||||
values: [0, 50, 100],
|
||||
};
|
||||
|
||||
const calc = getScaleCalculator(field, createTheme());
|
||||
@ -33,7 +32,7 @@ describe('getScaleCalculator', () => {
|
||||
name: 'test',
|
||||
config: {},
|
||||
type: FieldType.boolean,
|
||||
values: new ArrayVector([true, false, true]),
|
||||
values: [true, false, true],
|
||||
};
|
||||
|
||||
const theme = createTheme();
|
||||
@ -55,7 +54,7 @@ describe('getScaleCalculator', () => {
|
||||
name: 'test',
|
||||
config: { color: { mode: FieldColorModeId.ContinuousGrYlRd } },
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1]),
|
||||
values: [1],
|
||||
};
|
||||
|
||||
const theme = createTheme();
|
||||
|
@ -1,5 +1,4 @@
|
||||
import { ThresholdsConfig, ThresholdsMode, FieldConfig, Threshold, Field, FieldType } from '../types';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { validateFieldConfig } from './fieldOverrides';
|
||||
import { sortThresholds, getActiveThreshold, getActiveThresholdForValue } from './thresholds';
|
||||
@ -50,7 +49,7 @@ describe('thresholds', () => {
|
||||
name: 'test',
|
||||
config: { thresholds: { mode: mode, steps: sortThresholds(steps) } },
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([]),
|
||||
values: [],
|
||||
};
|
||||
validateFieldConfig(field.config!);
|
||||
return getActiveThresholdForValue(field, value, percent);
|
||||
|
@ -3,7 +3,6 @@ import { difference } from 'lodash';
|
||||
import { MutableDataFrame } from '../dataframe/MutableDataFrame';
|
||||
import { guessFieldTypeFromValue } from '../dataframe/processDataFrame';
|
||||
import { Field, FieldType } from '../types/index';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { fieldReducers, ReducerID, reduceField } from './fieldReducer';
|
||||
|
||||
@ -15,11 +14,11 @@ function reduce(field: Field, id: string) {
|
||||
}
|
||||
|
||||
function createField<T>(name: string, values?: T[], type?: FieldType): Field<T> {
|
||||
const arr = new ArrayVector(values);
|
||||
const arr = values ?? [];
|
||||
return {
|
||||
name,
|
||||
config: {},
|
||||
type: type ? type : guessFieldTypeFromValue(arr.get(0)),
|
||||
type: type ? type : guessFieldTypeFromValue(arr[0]),
|
||||
values: arr,
|
||||
};
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { FieldType, DataFrame } from '../../types';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { getFieldMatcher } from '../matchers';
|
||||
|
||||
import { FieldMatcherID } from './ids';
|
||||
@ -401,12 +400,12 @@ describe('Field Regexp or Names Matcher', () => {
|
||||
it('Support fallback name matchers', () => {
|
||||
const frame: DataFrame = {
|
||||
fields: [
|
||||
{ name: 'time', type: FieldType.time, config: {}, values: new ArrayVector([1, 2]) },
|
||||
{ name: 'time', type: FieldType.time, config: {}, values: [1, 2] },
|
||||
{
|
||||
name: 'UP',
|
||||
type: FieldType.number,
|
||||
config: {},
|
||||
values: new ArrayVector([1, 2]),
|
||||
values: [1, 2],
|
||||
labels: { __name__: 'UP' },
|
||||
},
|
||||
],
|
||||
@ -433,12 +432,12 @@ describe('Field Regexp or Names Matcher', () => {
|
||||
it('Support fallback multiple names matchers', () => {
|
||||
const frame: DataFrame = {
|
||||
fields: [
|
||||
{ name: 'time', type: FieldType.time, config: {}, values: new ArrayVector([1, 2]) },
|
||||
{ name: 'time', type: FieldType.time, config: {}, values: [1, 2] },
|
||||
{
|
||||
name: 'UP',
|
||||
type: FieldType.number,
|
||||
config: {},
|
||||
values: new ArrayVector([1, 2]),
|
||||
values: [1, 2],
|
||||
labels: { __name__: 'UP' },
|
||||
},
|
||||
],
|
||||
|
@ -3,7 +3,6 @@ import { map } from 'rxjs';
|
||||
import { toDataFrame } from '../dataframe/processDataFrame';
|
||||
import { CustomTransformOperator, FieldType } from '../types';
|
||||
import { mockTransformationsRegistry } from '../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../vector/ArrayVector';
|
||||
|
||||
import { ReducerID } from './fieldReducer';
|
||||
import { FrameMatcherID } from './matchers/ids';
|
||||
@ -31,7 +30,7 @@ const customTransform1: CustomTransformOperator = () => (source) => {
|
||||
fields: frame.fields.map((field) => {
|
||||
return {
|
||||
...field,
|
||||
values: new ArrayVector(field.values.toArray().map((v) => v / 100)),
|
||||
values: field.values.map((v) => v / 100),
|
||||
};
|
||||
}),
|
||||
};
|
||||
@ -50,7 +49,7 @@ const customTransform2: CustomTransformOperator = () => (source) => {
|
||||
fields: frame.fields.map((field) => {
|
||||
return {
|
||||
...field,
|
||||
values: new ArrayVector(field.values.toArray().map((v) => v * 2)),
|
||||
values: field.values.map((v) => v * 2),
|
||||
};
|
||||
}),
|
||||
};
|
||||
|
@ -5,7 +5,7 @@ import { getTimeField } from '../../dataframe/processDataFrame';
|
||||
import { getFieldDisplayName } from '../../field';
|
||||
import { DataFrame, DataTransformerInfo, Field, FieldType, NullValueMode, Vector } from '../../types';
|
||||
import { BinaryOperationID, binaryOperators } from '../../utils/binaryOperators';
|
||||
import { ArrayVector, BinaryOperationVector, ConstantVector, IndexVector } from '../../vector';
|
||||
import { BinaryOperationVector, ConstantVector, IndexVector } from '../../vector';
|
||||
import { AsNumberVector } from '../../vector/AsNumberVector';
|
||||
import { RowVector } from '../../vector/RowVector';
|
||||
import { doStandardCalcs, fieldReducers, ReducerID } from '../fieldReducer';
|
||||
@ -207,7 +207,7 @@ function getReduceRowCreator(options: ReduceOptions, allFrames: DataFrame[]): Va
|
||||
vals.push(val);
|
||||
}
|
||||
|
||||
return new ArrayVector(vals);
|
||||
return vals;
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ import { map } from 'rxjs/operators';
|
||||
|
||||
import { DataFrame, Field, TIME_SERIES_VALUE_FIELD_NAME } from '../../types/dataFrame';
|
||||
import { DataTransformerInfo } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
|
||||
@ -94,7 +93,7 @@ export function concatenateFields(data: DataFrame[], opts: ConcatenateTransforme
|
||||
values.length = maxLength;
|
||||
return {
|
||||
...f,
|
||||
values: new ArrayVector(values),
|
||||
values: values,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { Field, FieldType } from '../../types/dataFrame';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
|
||||
import {
|
||||
ensureTimeField,
|
||||
@ -18,13 +17,13 @@ describe('field convert type', () => {
|
||||
const stringTime = {
|
||||
name: 'proper dates',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector([
|
||||
values: [
|
||||
'2021-07-19 00:00:00.000',
|
||||
'2021-07-23 00:00:00.000',
|
||||
'2021-07-25 00:00:00.000',
|
||||
'2021-08-01 00:00:00.000',
|
||||
'2021-08-02 00:00:00.000',
|
||||
]),
|
||||
],
|
||||
config: {},
|
||||
};
|
||||
|
||||
@ -32,7 +31,7 @@ describe('field convert type', () => {
|
||||
expect(timefield).toEqual({
|
||||
name: 'proper dates',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1626674400000, 1627020000000, 1627192800000, 1627797600000, 1627884000000]),
|
||||
values: [1626674400000, 1627020000000, 1627192800000, 1627797600000, 1627884000000],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
@ -42,13 +41,13 @@ describe('field convert type', () => {
|
||||
const yearFormat = {
|
||||
name: 'format to year',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector([
|
||||
values: [
|
||||
'2017-07-19 00:00:00.000',
|
||||
'2018-07-23 00:00:00.000',
|
||||
'2019-07-25 00:00:00.000',
|
||||
'2020-08-01 00:00:00.000',
|
||||
'2021-08-02 00:00:00.000',
|
||||
]),
|
||||
],
|
||||
config: {},
|
||||
};
|
||||
|
||||
@ -56,7 +55,7 @@ describe('field convert type', () => {
|
||||
expect(timefield).toEqual({
|
||||
name: 'format to year',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1483246800000, 1514782800000, 1546318800000, 1577854800000, 1609477200000]),
|
||||
values: [1483246800000, 1514782800000, 1546318800000, 1577854800000, 1609477200000],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
@ -67,7 +66,7 @@ describe('field convert type', () => {
|
||||
const misformattedStrings = {
|
||||
name: 'misformatted dates',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['2021/08-01 00:00.00:000', '2021/08/01 00.00-000', '2021/08-01 00:00.00:000']),
|
||||
values: ['2021/08-01 00:00.00:000', '2021/08/01 00.00-000', '2021/08-01 00:00.00:000'],
|
||||
config: { unit: 'time' },
|
||||
};
|
||||
|
||||
@ -75,7 +74,7 @@ describe('field convert type', () => {
|
||||
expect(timefield).toEqual({
|
||||
name: 'misformatted dates',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([null, null, null]),
|
||||
values: [null, null, null],
|
||||
config: { unit: 'time' },
|
||||
});
|
||||
});
|
||||
@ -86,7 +85,7 @@ describe('field convert type', () => {
|
||||
const stringyNumbers = {
|
||||
name: 'stringy nums',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['10', '12', '30', '14', '10']),
|
||||
values: ['10', '12', '30', '14', '10'],
|
||||
config: {},
|
||||
};
|
||||
|
||||
@ -95,7 +94,7 @@ describe('field convert type', () => {
|
||||
expect(numbers).toEqual({
|
||||
name: 'stringy nums',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10, 12, 30, 14, 10]),
|
||||
values: [10, 12, 30, 14, 10],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
@ -107,7 +106,7 @@ it('can convert strings with commas to numbers', () => {
|
||||
const stringyNumbers = {
|
||||
name: 'stringy nums',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['1,000', '1,000,000']),
|
||||
values: ['1,000', '1,000,000'],
|
||||
config: {},
|
||||
};
|
||||
|
||||
@ -116,7 +115,7 @@ it('can convert strings with commas to numbers', () => {
|
||||
expect(numbers).toEqual({
|
||||
name: 'stringy nums',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1000, 1000000]),
|
||||
values: [1000, 1000000],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
@ -127,7 +126,7 @@ it('converts booleans to numbers', () => {
|
||||
const stringyNumbers = {
|
||||
name: 'booleans',
|
||||
type: FieldType.boolean,
|
||||
values: new ArrayVector([true, false]),
|
||||
values: [true, false],
|
||||
config: {},
|
||||
};
|
||||
|
||||
@ -136,7 +135,7 @@ it('converts booleans to numbers', () => {
|
||||
expect(numbers).toEqual({
|
||||
name: 'booleans',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 0]),
|
||||
values: [1, 0],
|
||||
config: {},
|
||||
});
|
||||
});
|
||||
@ -382,7 +381,7 @@ describe('ensureTimeField', () => {
|
||||
config: {},
|
||||
name: 'proper dates',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1626674400000, 1627020000000, 1627192800000, 1627797600000, 1627884000000]),
|
||||
values: [1626674400000, 1627020000000, 1627192800000, 1627797600000, 1627884000000],
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -396,14 +395,14 @@ describe('fieldToTimeField', () => {
|
||||
config: {},
|
||||
name: 'ISO 8601 date strings',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector(['2021-11-11T19:45:00Z']),
|
||||
values: ['2021-11-11T19:45:00Z'],
|
||||
};
|
||||
|
||||
expect(fieldToTimeField(stringTimeField)).toEqual({
|
||||
config: {},
|
||||
name: 'ISO 8601 date strings',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1636659900000]),
|
||||
values: [1636659900000],
|
||||
});
|
||||
});
|
||||
|
||||
@ -412,7 +411,7 @@ describe('fieldToTimeField', () => {
|
||||
config: {},
|
||||
name: 'ISO 8601 date strings',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([
|
||||
values: [
|
||||
'2021-11-11T19:45:00+05:30',
|
||||
'2021-11-11T19:45:00-05:30',
|
||||
'2021-11-11T19:45:00+0530',
|
||||
@ -421,17 +420,17 @@ describe('fieldToTimeField', () => {
|
||||
'2021-11-11T19:45:00.0000000000-0530',
|
||||
'2021-11-11T19:45:00.000Z',
|
||||
'2021-11-11T19:45:00.0000000000Z',
|
||||
]),
|
||||
],
|
||||
};
|
||||
|
||||
expect(fieldToTimeField(stringTimeField)).toEqual({
|
||||
config: {},
|
||||
name: 'ISO 8601 date strings',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([
|
||||
values: [
|
||||
1636640100000, 1636679700000, 1636640100000, 1636679700000, 1636640100000, 1636679700000, 1636659900000,
|
||||
1636659900000,
|
||||
]),
|
||||
],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ import { map } from 'rxjs/operators';
|
||||
import { dateTimeParse } from '../../datetime';
|
||||
import { SynchronousDataTransformerInfo } from '../../types';
|
||||
import { DataFrame, EnumFieldConfig, Field, FieldType } from '../../types/dataFrame';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { fieldMatchers } from '../matchers';
|
||||
import { FieldMatcherID } from '../matchers/ids';
|
||||
|
||||
@ -136,7 +135,7 @@ export function fieldToTimeField(field: Field, dateFormat?: string): Field {
|
||||
return {
|
||||
...field,
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector(timeValues),
|
||||
values: timeValues,
|
||||
};
|
||||
}
|
||||
|
||||
@ -162,7 +161,7 @@ function fieldToNumberField(field: Field): Field {
|
||||
return {
|
||||
...field,
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(numValues),
|
||||
values: numValues,
|
||||
};
|
||||
}
|
||||
|
||||
@ -176,7 +175,7 @@ function fieldToBooleanField(field: Field): Field {
|
||||
return {
|
||||
...field,
|
||||
type: FieldType.boolean,
|
||||
values: new ArrayVector(booleanValues),
|
||||
values: booleanValues,
|
||||
};
|
||||
}
|
||||
|
||||
@ -199,7 +198,7 @@ function fieldToStringField(field: Field, dateFormat?: string): Field {
|
||||
return {
|
||||
...field,
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(values),
|
||||
values: values,
|
||||
};
|
||||
}
|
||||
|
||||
@ -217,7 +216,7 @@ function fieldToComplexField(field: Field): Field {
|
||||
return {
|
||||
...field,
|
||||
type: FieldType.other,
|
||||
values: new ArrayVector(complexValues),
|
||||
values: complexValues,
|
||||
};
|
||||
}
|
||||
|
||||
@ -273,6 +272,6 @@ function fieldToEnumField(field: Field, cfg?: EnumFieldConfig): Field {
|
||||
},
|
||||
},
|
||||
type: FieldType.enum,
|
||||
values: new ArrayVector(enumValues),
|
||||
values: enumValues,
|
||||
};
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { DataTransformerConfig, FieldType, MatcherConfig } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { ValueMatcherID } from '../matchers/ids';
|
||||
import { BasicValueMatcherOptions } from '../matchers/valueMatchers/types';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
@ -18,8 +17,8 @@ const seriesAWithSingleField = toDataFrame({
|
||||
name: 'A',
|
||||
length: 7,
|
||||
fields: [
|
||||
{ name: 'time', type: FieldType.time, values: new ArrayVector([1000, 2000, 3000, 4000, 5000, 6000, 7000]) },
|
||||
{ name: 'numbers', type: FieldType.number, values: new ArrayVector([1, 2, 3, 4, 5, 6, 7]) },
|
||||
{ name: 'time', type: FieldType.time, values: [1000, 2000, 3000, 4000, 5000, 6000, 7000] },
|
||||
{ name: 'numbers', type: FieldType.number, values: [1, 2, 3, 4, 5, 6, 7] },
|
||||
],
|
||||
});
|
||||
|
||||
@ -56,13 +55,13 @@ describe('FilterByValue transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([6000, 7000]),
|
||||
values: [6000, 7000],
|
||||
state: {},
|
||||
},
|
||||
{
|
||||
name: 'numbers',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 7]),
|
||||
values: [6, 7],
|
||||
state: {},
|
||||
},
|
||||
]);
|
||||
@ -97,13 +96,13 @@ describe('FilterByValue transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1000, 2000, 3000, 4000, 5000]),
|
||||
values: [1000, 2000, 3000, 4000, 5000],
|
||||
state: {},
|
||||
},
|
||||
{
|
||||
name: 'numbers',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 3, 4, 5]),
|
||||
values: [1, 2, 3, 4, 5],
|
||||
state: {},
|
||||
},
|
||||
]);
|
||||
@ -147,13 +146,13 @@ describe('FilterByValue transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1000, 2000, 3000, 4000, 7000]),
|
||||
values: [1000, 2000, 3000, 4000, 7000],
|
||||
state: {},
|
||||
},
|
||||
{
|
||||
name: 'numbers',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 3, 4, 7]),
|
||||
values: [1, 2, 3, 4, 7],
|
||||
state: {},
|
||||
},
|
||||
]);
|
||||
@ -197,13 +196,13 @@ describe('FilterByValue transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([4000, 5000]),
|
||||
values: [4000, 5000],
|
||||
state: {},
|
||||
},
|
||||
{
|
||||
name: 'numbers',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([4, 5]),
|
||||
values: [4, 5],
|
||||
state: {},
|
||||
},
|
||||
]);
|
||||
|
@ -3,7 +3,6 @@ import { map } from 'rxjs/operators';
|
||||
import { getFieldDisplayName } from '../../field/fieldState';
|
||||
import { DataFrame, Field } from '../../types/dataFrame';
|
||||
import { DataTransformerInfo, MatcherConfig } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
import { getValueMatcher } from '../matchers';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -114,7 +113,7 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
|
||||
// We keep field config, but clean the state as it's being recalculated when the field overrides are applied
|
||||
fields.push({
|
||||
...field,
|
||||
values: new ArrayVector(buffer),
|
||||
values: buffer,
|
||||
state: {},
|
||||
});
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { DataTransformerConfig, Field, FieldType } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { ReducerID } from '../fieldReducer';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
@ -69,7 +68,7 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'three']),
|
||||
values: ['one', 'two', 'three'],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -110,13 +109,13 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'three']),
|
||||
values: ['one', 'two', 'three'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values (sum)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 4, 9]),
|
||||
values: [1, 4, 9],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -161,25 +160,25 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'three']),
|
||||
values: ['one', 'two', 'three'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'time (count)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 3]),
|
||||
values: [1, 2, 3],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'time (last)',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 5000, 8000]),
|
||||
values: [3000, 5000, 8000],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values (sum)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 4, 9]),
|
||||
values: [1, 4, 9],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -230,13 +229,13 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'three']),
|
||||
values: ['one', 'two', 'three'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values (sum)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 4, 9]),
|
||||
values: [1, 4, 9],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -245,13 +244,13 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'three']),
|
||||
values: ['one', 'two', 'three'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values (sum)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([0, 7, 8]),
|
||||
values: [0, 7, 8],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -292,13 +291,13 @@ describe('GroupBy transformer', () => {
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['500', '404', 'one', 'two', '200']),
|
||||
values: ['500', '404', 'one', 'two', '200'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values (sum)',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 4, 6, 3, 4]),
|
||||
values: [1, 4, 6, 3, 4],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
|
@ -5,7 +5,6 @@ import { guessFieldTypeForField } from '../../dataframe/processDataFrame';
|
||||
import { getFieldDisplayName } from '../../field/fieldState';
|
||||
import { DataFrame, Field, FieldType } from '../../types/dataFrame';
|
||||
import { DataTransformerInfo } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
import { reduceField, ReducerID } from '../fieldReducer';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -81,7 +80,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
|
||||
name: fieldName,
|
||||
type: field.type,
|
||||
config: { ...field.config },
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
};
|
||||
}
|
||||
|
||||
@ -92,7 +91,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
|
||||
const fields: Field[] = [];
|
||||
|
||||
for (const field of groupByFields) {
|
||||
const values = new ArrayVector();
|
||||
const values: any[] = [];
|
||||
const fieldName = getFieldDisplayName(field);
|
||||
|
||||
valuesByGroupKey.forEach((value) => {
|
||||
@ -137,7 +136,7 @@ export const groupByTransformer: DataTransformerInfo<GroupByTransformerOptions>
|
||||
for (const aggregation of aggregations) {
|
||||
const aggregationField: Field = {
|
||||
name: `${fieldName} (${aggregation})`,
|
||||
values: new ArrayVector(valuesByAggregation[aggregation]),
|
||||
values: valuesByAggregation[aggregation],
|
||||
type: FieldType.other,
|
||||
config: {},
|
||||
};
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { DataTransformerConfig, FieldType, Field, SpecialValue } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { GroupingToMatrixTransformerOptions, groupingToMatrixTransformer } from './groupingToMatrix';
|
||||
@ -32,25 +31,25 @@ describe('Grouping to Matrix', () => {
|
||||
{
|
||||
name: 'Time\\Time',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector([1000, 1001, 1002]),
|
||||
values: [1000, 1001, 1002],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1000',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, '', '']),
|
||||
values: [1, '', ''],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1001',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(['', 2, '']),
|
||||
values: ['', 2, ''],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1002',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(['', '', 3]),
|
||||
values: ['', '', 3],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -84,19 +83,19 @@ describe('Grouping to Matrix', () => {
|
||||
{
|
||||
name: 'Row\\Column',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['R1', 'R2']),
|
||||
values: ['R1', 'R2'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'C1',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 4]),
|
||||
values: [1, 4],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'C2',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([5, '']),
|
||||
values: [5, ''],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -127,19 +126,19 @@ describe('Grouping to Matrix', () => {
|
||||
{
|
||||
name: 'Time\\Time',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector([1000, 1001]),
|
||||
values: [1000, 1001],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1000',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, null]),
|
||||
values: [1, null],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1001',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([null, 2]),
|
||||
values: [null, 2],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
|
@ -5,7 +5,6 @@ import { createTheme, GrafanaTheme2 } from '../../themes';
|
||||
import { DataFrameType, SynchronousDataTransformerInfo } from '../../types';
|
||||
import { DataFrame, Field, FieldConfig, FieldType } from '../../types/dataFrame';
|
||||
import { roundDecimals } from '../../utils';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
import { AlignedData, join } from './joinDataFrames';
|
||||
@ -158,7 +157,7 @@ export function getHistogramFields(frame: DataFrame): HistogramFields | undefine
|
||||
xMax = {
|
||||
...xMin,
|
||||
name: histogramFrameBucketMaxFieldName,
|
||||
values: new ArrayVector(vals.map((v) => v + bucketSize)),
|
||||
values: vals.map((v) => v + bucketSize),
|
||||
};
|
||||
}
|
||||
|
||||
@ -169,7 +168,7 @@ export function getHistogramFields(frame: DataFrame): HistogramFields | undefine
|
||||
xMin = {
|
||||
...xMax,
|
||||
name: histogramFrameBucketMinFieldName,
|
||||
values: new ArrayVector(vals.map((v) => v - bucketSize)),
|
||||
values: vals.map((v) => v - bucketSize),
|
||||
};
|
||||
}
|
||||
|
||||
@ -291,7 +290,7 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
|
||||
const xMin: Field = {
|
||||
name: histogramFrameBucketMinFieldName,
|
||||
values: new ArrayVector(joinedHists[0]),
|
||||
values: joinedHists[0],
|
||||
type: FieldType.number,
|
||||
state: undefined,
|
||||
config:
|
||||
@ -305,7 +304,7 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
const xMax = {
|
||||
...xMin,
|
||||
name: histogramFrameBucketMaxFieldName,
|
||||
values: new ArrayVector(joinedHists[0].map((v) => v + bucketSize!)),
|
||||
values: joinedHists[0].map((v) => v + bucketSize!),
|
||||
};
|
||||
|
||||
if (options?.combine) {
|
||||
@ -319,14 +318,14 @@ export function buildHistogram(frames: DataFrame[], options?: HistogramTransform
|
||||
{
|
||||
...counts[0],
|
||||
name: 'count',
|
||||
values: new ArrayVector(vals),
|
||||
values: vals,
|
||||
type: FieldType.number,
|
||||
state: undefined,
|
||||
},
|
||||
];
|
||||
} else {
|
||||
counts.forEach((field, i) => {
|
||||
field.values = new ArrayVector(joinedHists[i + 1]);
|
||||
field.values = joinedHists[i + 1];
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { FieldType, DataTransformerConfig } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -257,9 +256,9 @@ describe('JOIN Transformer', () => {
|
||||
},
|
||||
};
|
||||
|
||||
everySecondSeries.fields[0].values = new ArrayVector(everySecondSeries.fields[0].values.toArray().reverse());
|
||||
everySecondSeries.fields[1].values = new ArrayVector(everySecondSeries.fields[1].values.toArray().reverse());
|
||||
everySecondSeries.fields[2].values = new ArrayVector(everySecondSeries.fields[2].values.toArray().reverse());
|
||||
everySecondSeries.fields[0].values = everySecondSeries.fields[0].values.reverse();
|
||||
everySecondSeries.fields[1].values = everySecondSeries.fields[1].values.reverse();
|
||||
everySecondSeries.fields[2].values = everySecondSeries.fields[2].values.reverse();
|
||||
|
||||
await expect(transformDataFrame([cfg], [everySecondSeries, everyOtherSecondSeries])).toEmitValuesWith(
|
||||
(received) => {
|
||||
@ -771,9 +770,9 @@ describe('JOIN Transformer', () => {
|
||||
},
|
||||
};
|
||||
|
||||
seriesA.fields[0].values = new ArrayVector(seriesA.fields[0].values.toArray().reverse());
|
||||
seriesA.fields[1].values = new ArrayVector(seriesA.fields[1].values.toArray().reverse());
|
||||
seriesA.fields[2].values = new ArrayVector(seriesA.fields[2].values.toArray().reverse());
|
||||
seriesA.fields[0].values = seriesA.fields[0].values.reverse();
|
||||
seriesA.fields[1].values = seriesA.fields[1].values.reverse();
|
||||
seriesA.fields[2].values = seriesA.fields[2].values.reverse();
|
||||
|
||||
await expect(transformDataFrame([cfg], [seriesA, seriesB])).toEmitValuesWith((received) => {
|
||||
const data = received[0];
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { FieldType } from '../../types/dataFrame';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
|
||||
import { calculateFieldTransformer } from './calculateField';
|
||||
import { JoinMode } from './joinByField';
|
||||
@ -321,42 +320,40 @@ describe('align frames', () => {
|
||||
|
||||
describe('check ascending data', () => {
|
||||
it('simple ascending', () => {
|
||||
const v = new ArrayVector([1, 2, 3, 4, 5]);
|
||||
const v = [1, 2, 3, 4, 5];
|
||||
expect(isLikelyAscendingVector(v)).toBeTruthy();
|
||||
});
|
||||
it('simple ascending with null', () => {
|
||||
const v = new ArrayVector([null, 2, 3, 4, null]);
|
||||
const v = [null, 2, 3, 4, null];
|
||||
expect(isLikelyAscendingVector(v)).toBeTruthy();
|
||||
});
|
||||
it('single value', () => {
|
||||
const v = new ArrayVector([null, null, null, 4, null]);
|
||||
const v = [null, null, null, 4, null];
|
||||
expect(isLikelyAscendingVector(v)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([4]))).toBeTruthy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([] as any[]))).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([4])).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([])).toBeTruthy();
|
||||
});
|
||||
|
||||
it('middle values', () => {
|
||||
const v = new ArrayVector([null, null, 5, 4, null]);
|
||||
const v = [null, null, 5, 4, null];
|
||||
expect(isLikelyAscendingVector(v)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('decending', () => {
|
||||
expect(isLikelyAscendingVector(new ArrayVector([7, 6, null]))).toBeFalsy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([7, 8, 6]))).toBeFalsy();
|
||||
expect(isLikelyAscendingVector([7, 6, null])).toBeFalsy();
|
||||
expect(isLikelyAscendingVector([7, 8, 6])).toBeFalsy();
|
||||
});
|
||||
|
||||
it('ascending first/last', () => {
|
||||
expect(isLikelyAscendingVector(new ArrayVector([10, 20, 30, 5, 15, 7, 43, 29, 11]), 3)).toBeFalsy();
|
||||
expect(
|
||||
isLikelyAscendingVector(new ArrayVector([null, 10, 20, 30, 5, null, 15, 7, 43, 29, 11, null]), 3)
|
||||
).toBeFalsy();
|
||||
expect(isLikelyAscendingVector([10, 20, 30, 5, 15, 7, 43, 29, 11], 3)).toBeFalsy();
|
||||
expect(isLikelyAscendingVector([null, 10, 20, 30, 5, null, 15, 7, 43, 29, 11, null], 3)).toBeFalsy();
|
||||
});
|
||||
|
||||
it('null stuffs', () => {
|
||||
expect(isLikelyAscendingVector(new ArrayVector([null, null, 1]), 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([1, null, null]), 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([null, null, null]), 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector(new ArrayVector([null, 1, null]), 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([null, null, 1], 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([1, null, null], 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([null, null, null], 3)).toBeTruthy();
|
||||
expect(isLikelyAscendingVector([null, 1, null], 3)).toBeTruthy();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import intersect from 'fast_array_intersect';
|
||||
|
||||
import { getTimeField, sortDataFrame } from '../../dataframe';
|
||||
import { DataFrame, Field, FieldMatcher, FieldType, Vector } from '../../types';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { fieldMatchers } from '../matchers';
|
||||
import { FieldMatcherID } from '../matchers/ids';
|
||||
|
||||
@ -227,7 +226,7 @@ export function joinDataFrames(options: JoinOptions): DataFrame | undefined {
|
||||
length: joined[0].length,
|
||||
fields: originalFields.map((f, index) => ({
|
||||
...f,
|
||||
values: new ArrayVector(joined[index]),
|
||||
values: joined[index],
|
||||
})),
|
||||
};
|
||||
}
|
||||
@ -352,7 +351,7 @@ export function join(tables: AlignedData[], nullModes?: number[][], mode: JoinMo
|
||||
|
||||
// Test a few samples to see if the values are ascending
|
||||
// Only exported for tests
|
||||
export function isLikelyAscendingVector(data: Vector, samples = 50) {
|
||||
export function isLikelyAscendingVector(data: Vector | [], samples = 50) {
|
||||
const len = data.length;
|
||||
|
||||
// empty or single value
|
||||
@ -364,11 +363,11 @@ export function isLikelyAscendingVector(data: Vector, samples = 50) {
|
||||
let firstIdx = 0;
|
||||
let lastIdx = len - 1;
|
||||
|
||||
while (firstIdx <= lastIdx && data.get(firstIdx) == null) {
|
||||
while (firstIdx <= lastIdx && data[firstIdx] == null) {
|
||||
firstIdx++;
|
||||
}
|
||||
|
||||
while (lastIdx >= firstIdx && data.get(lastIdx) == null) {
|
||||
while (lastIdx >= firstIdx && data[lastIdx] == null) {
|
||||
lastIdx--;
|
||||
}
|
||||
|
||||
@ -379,8 +378,8 @@ export function isLikelyAscendingVector(data: Vector, samples = 50) {
|
||||
|
||||
const stride = Math.max(1, Math.floor((lastIdx - firstIdx + 1) / samples));
|
||||
|
||||
for (let prevVal = data.get(firstIdx), i = firstIdx + stride; i <= lastIdx; i += stride) {
|
||||
const v = data.get(i);
|
||||
for (let prevVal = data[firstIdx], i = firstIdx + stride; i <= lastIdx; i += stride) {
|
||||
const v = data[i];
|
||||
|
||||
if (v != null) {
|
||||
if (v <= prevVal) {
|
||||
|
@ -2,7 +2,6 @@ import { map } from 'rxjs/operators';
|
||||
|
||||
import { getFieldDisplayName } from '../..';
|
||||
import { DataFrame, Field, FieldType, SynchronousDataTransformerInfo } from '../../types';
|
||||
import { ArrayVector } from '../../vector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
|
||||
@ -83,7 +82,7 @@ export const labelsToFieldsTransformer: SynchronousDataTransformerInfo<LabelsToF
|
||||
newFields.push({
|
||||
name: name,
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(values),
|
||||
values: values,
|
||||
config: {},
|
||||
});
|
||||
}
|
||||
@ -123,8 +122,8 @@ function convertLabelsToRows(data: DataFrame[], keepLabels?: string[]): DataFram
|
||||
...frame,
|
||||
name: getFieldDisplayName(field, frame, data),
|
||||
fields: [
|
||||
{ name: 'label', type: FieldType.string, config: {}, values: new ArrayVector(keys) },
|
||||
{ name: 'value', type: FieldType.string, config: {}, values: new ArrayVector(vals) },
|
||||
{ name: 'label', type: FieldType.string, config: {}, values: keys },
|
||||
{ name: 'value', type: FieldType.string, config: {}, values: vals },
|
||||
],
|
||||
length: vals.length,
|
||||
});
|
||||
|
@ -3,7 +3,6 @@ import { DataTransformerConfig } from '@grafana/data';
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { Field, FieldType } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -37,19 +36,19 @@ describe('Limit transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000]),
|
||||
values: [3000, 4000, 5000],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'two']),
|
||||
values: ['one', 'two', 'two'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 2]),
|
||||
values: [1, 2, 2],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -81,19 +80,19 @@ describe('Limit transformer', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000, 7000, 8000]),
|
||||
values: [3000, 4000, 5000, 6000, 7000, 8000],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'message',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['one', 'two', 'two', 'three', 'three', 'three']),
|
||||
values: ['one', 'two', 'two', 'three', 'three', 'three'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'values',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 2, 3, 3, 3]),
|
||||
values: [1, 2, 2, 3, 3, 3],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
import { DataTransformerInfo } from '../../types';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
|
||||
@ -28,10 +27,9 @@ export const limitTransformer: DataTransformerInfo<LimitTransformerOptions> = {
|
||||
return {
|
||||
...frame,
|
||||
fields: frame.fields.map((f) => {
|
||||
const vals = f.values.toArray();
|
||||
return {
|
||||
...f,
|
||||
values: new ArrayVector(vals.slice(0, limitFieldMatch)),
|
||||
values: f.values.slice(0, limitFieldMatch),
|
||||
};
|
||||
}),
|
||||
length: limitFieldMatch,
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { DataTransformerConfig, DisplayProcessor, Field, FieldType } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -592,7 +591,7 @@ const createField = (
|
||||
config = {},
|
||||
display?: DisplayProcessor
|
||||
): Field => {
|
||||
return { name, type, values: new ArrayVector(values), config, labels: undefined, display };
|
||||
return { name, type, values: values, config, labels: undefined, display };
|
||||
};
|
||||
|
||||
const unwrap = (fields: Field[]): Field[] => {
|
||||
|
@ -4,7 +4,6 @@ import { map } from 'rxjs/operators';
|
||||
import { MutableDataFrame } from '../../dataframe';
|
||||
import { DataFrame, Field } from '../../types/dataFrame';
|
||||
import { DataTransformerInfo } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
|
||||
@ -117,7 +116,7 @@ export const mergeTransformer: DataTransformerInfo<MergeTransformerOptions> = {
|
||||
const copyFieldStructure = (field: Field): Field => {
|
||||
return {
|
||||
...omit(field, ['values', 'state', 'labels', 'config']),
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
config: {
|
||||
...omit(field.config, 'displayName'),
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { FieldType, DataTransformerConfig } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -41,7 +40,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'temperature',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'temperature',
|
||||
@ -52,7 +51,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'humidity',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'humidity',
|
||||
@ -63,7 +62,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'time',
|
||||
@ -95,7 +94,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'time',
|
||||
@ -106,7 +105,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'temperature',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'temperature',
|
||||
@ -117,7 +116,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'humidity',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'humidity',
|
||||
@ -159,7 +158,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'humidity',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'humidity',
|
||||
@ -170,7 +169,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'time',
|
||||
@ -181,7 +180,7 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'pressure',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
labels: undefined,
|
||||
state: {
|
||||
displayName: 'pressure',
|
||||
@ -219,19 +218,19 @@ describe('Order Transformer', () => {
|
||||
config: {},
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
name: 'pressure',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
name: 'humidity',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { FieldType, DataTransformerConfig } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -53,7 +52,7 @@ describe('OrganizeFields Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -66,7 +65,7 @@ describe('OrganizeFields Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
@ -116,7 +115,7 @@ describe('OrganizeFields Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
@ -127,7 +126,7 @@ describe('OrganizeFields Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import { DataFrameView } from '../../dataframe';
|
||||
import { toDataFrame } from '../../dataframe/processDataFrame';
|
||||
import { DataTransformerConfig, Field, FieldType } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { ReducerID } from '../fieldReducer';
|
||||
import { notTimeFieldMatcher } from '../matchers/predicates';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
@ -64,31 +63,31 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['A temperature', 'A humidity', 'B temperature', 'B humidity']),
|
||||
values: ['A temperature', 'A humidity', 'B temperature', 'B humidity'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'First',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 10000.3, 1, 11000.1]),
|
||||
values: [3, 10000.3, 1, 11000.1],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Min',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 10000.3, 1, 11000.1]),
|
||||
values: [3, 10000.3, 1, 11000.1],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10000.6, 7, 11000.7]),
|
||||
values: [6, 10000.6, 7, 11000.7],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Last',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10000.6, 7, 11000.7]),
|
||||
values: [6, 10000.6, 7, 11000.7],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -115,31 +114,31 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['A temperature', 'B temperature']),
|
||||
values: ['A temperature', 'B temperature'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'First',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 1]),
|
||||
values: [3, 1],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Min',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 1]),
|
||||
values: [3, 1],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 7]),
|
||||
values: [6, 7],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Last',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 7]),
|
||||
values: [6, 7],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -165,31 +164,31 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['temperature', 'humidity']),
|
||||
values: ['temperature', 'humidity'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'First',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 10000.3]),
|
||||
values: [3, 10000.3],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Min',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 10000.3]),
|
||||
values: [3, 10000.3],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10000.6]),
|
||||
values: [6, 10000.6],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Last',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10000.6]),
|
||||
values: [6, 10000.6],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -214,31 +213,31 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['temperature']),
|
||||
values: ['temperature'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'First',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3]),
|
||||
values: [3],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Min',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3]),
|
||||
values: [3],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6]),
|
||||
values: [6],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Last',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6]),
|
||||
values: [6],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -306,13 +305,13 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['a', '2021']),
|
||||
values: ['a', '2021'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10]),
|
||||
values: [6, 10],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -351,13 +350,13 @@ describe('Reducer Transformer', () => {
|
||||
{
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
values: new ArrayVector(['a', '2021']),
|
||||
values: ['a', '2021'],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: 'Max',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([6, 10]),
|
||||
values: [6, 10],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
@ -418,7 +417,7 @@ describe('Reducer Transformer', () => {
|
||||
"CA",
|
||||
"NY",
|
||||
"CA",
|
||||
undefined,
|
||||
,
|
||||
],
|
||||
},
|
||||
{
|
||||
@ -426,8 +425,8 @@ describe('Reducer Transformer', () => {
|
||||
"name": "country",
|
||||
"type": "string",
|
||||
"values": [
|
||||
undefined,
|
||||
undefined,
|
||||
,
|
||||
,
|
||||
"USA",
|
||||
"USA",
|
||||
],
|
||||
|
@ -5,7 +5,6 @@ import { getFieldDisplayName } from '../../field';
|
||||
import { KeyValue } from '../../types/data';
|
||||
import { DataFrame, Field, FieldType } from '../../types/dataFrame';
|
||||
import { DataTransformerInfo, FieldMatcher, MatcherConfig } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector/ArrayVector';
|
||||
import { fieldReducers, reduceField, ReducerID } from '../fieldReducer';
|
||||
import { getFieldMatcher } from '../matchers';
|
||||
import { alwaysFieldMatcher, notTimeFieldMatcher } from '../matchers/predicates';
|
||||
@ -80,7 +79,7 @@ export function reduceSeriesToRows(
|
||||
|
||||
const size = source.length;
|
||||
const fields: Field[] = [];
|
||||
const names = new ArrayVector<string>(new Array(size));
|
||||
const names: string[] = new Array(size);
|
||||
fields.push({
|
||||
name: 'Field',
|
||||
type: FieldType.string,
|
||||
@ -88,10 +87,10 @@ export function reduceSeriesToRows(
|
||||
config: {},
|
||||
});
|
||||
|
||||
const labels: KeyValue<ArrayVector> = {};
|
||||
const labels: KeyValue<any[]> = {};
|
||||
if (labelsToFields) {
|
||||
for (const key of distinctLabels) {
|
||||
labels[key] = new ArrayVector<string>(new Array(size));
|
||||
labels[key] = new Array(size);
|
||||
fields.push({
|
||||
name: key,
|
||||
type: FieldType.string,
|
||||
@ -101,9 +100,9 @@ export function reduceSeriesToRows(
|
||||
}
|
||||
}
|
||||
|
||||
const calcs: KeyValue<ArrayVector> = {};
|
||||
const calcs: KeyValue<any[]> = {};
|
||||
for (const info of calculators) {
|
||||
calcs[info.id] = new ArrayVector(new Array(size));
|
||||
calcs[info.id] = new Array(size);
|
||||
fields.push({
|
||||
name: info.name,
|
||||
type: FieldType.other, // UNKNOWN until after we call the functions
|
||||
@ -120,19 +119,19 @@ export function reduceSeriesToRows(
|
||||
});
|
||||
|
||||
if (labelsToFields) {
|
||||
names.buffer[i] = field.name;
|
||||
names[i] = field.name;
|
||||
if (field.labels) {
|
||||
for (const key of Object.keys(field.labels)) {
|
||||
labels[key].set(i, field.labels[key]);
|
||||
labels[key][i] = field.labels[key];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
names.buffer[i] = getFieldDisplayName(field, series, data);
|
||||
names[i] = getFieldDisplayName(field, series, data);
|
||||
}
|
||||
|
||||
for (const info of calculators) {
|
||||
const v = results[info.id];
|
||||
calcs[info.id].buffer[i] = v;
|
||||
calcs[info.id][i] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@ -191,9 +190,9 @@ export function mergeResults(data: DataFrame[]): DataFrame | undefined {
|
||||
const isSameField = baseField.type === field.type && baseField.name === field.name;
|
||||
|
||||
if (isFirstField || isSameField) {
|
||||
const baseValues: any[] = baseField.values.toArray();
|
||||
const values: any[] = field.values.toArray();
|
||||
(baseField.values as unknown as ArrayVector).buffer = baseValues.concat(values);
|
||||
const baseValues = baseField.values;
|
||||
const values = field.values;
|
||||
baseField.values = baseValues.concat(values);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -224,7 +223,7 @@ export function reduceFields(data: DataFrame[], matcher: FieldMatcher, reducerId
|
||||
const value = results[reducer];
|
||||
const copy = {
|
||||
...field,
|
||||
values: new ArrayVector([value]),
|
||||
values: [value],
|
||||
};
|
||||
copy.state = undefined;
|
||||
if (reducers.length > 1) {
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { FieldType, DataTransformerConfig } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -49,7 +48,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -62,7 +61,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -75,7 +74,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
@ -119,7 +118,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
@ -130,7 +129,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -143,7 +142,7 @@ describe('Rename Transformer', () => {
|
||||
multipleFrames: false,
|
||||
},
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
@ -176,19 +175,19 @@ describe('Rename Transformer', () => {
|
||||
config: {},
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([3000, 4000, 5000, 6000]),
|
||||
values: [3000, 4000, 5000, 6000],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
name: 'pressure',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10.3, 10.4, 10.5, 10.6]),
|
||||
values: [10.3, 10.4, 10.5, 10.6],
|
||||
},
|
||||
{
|
||||
config: {},
|
||||
name: 'humidity',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([10000.3, 10000.4, 10000.5, 10000.6]),
|
||||
values: [10000.3, 10000.4, 10000.5, 10000.6],
|
||||
},
|
||||
]);
|
||||
});
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { toDataFrame } from '../../dataframe';
|
||||
import { DataTransformerConfig, Field, FieldType } from '../../types';
|
||||
import { mockTransformationsRegistry } from '../../utils/tests/mockTransformationsRegistry';
|
||||
import { ArrayVector } from '../../vector';
|
||||
import { transformDataFrame } from '../transformDataFrame';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
@ -246,9 +245,9 @@ describe('Series to rows', () => {
|
||||
});
|
||||
|
||||
const createField = (name: string, type: FieldType, values: unknown[], config = {}): Field => {
|
||||
return { name, type, values: new ArrayVector(values), config, labels: undefined };
|
||||
return { name, type, values: values, config, labels: undefined };
|
||||
};
|
||||
|
||||
const unwrap = (fields: Field[]): Field[] => {
|
||||
return fields.map((field) => createField(field.name, field.type, field.values.toArray(), field.config));
|
||||
return fields.map((field) => createField(field.name, field.type, field.values, field.config));
|
||||
};
|
||||
|
@ -12,7 +12,6 @@ import {
|
||||
TIME_SERIES_VALUE_FIELD_NAME,
|
||||
} from '../../types/dataFrame';
|
||||
import { DataTransformerInfo } from '../../types/transformations';
|
||||
import { ArrayVector } from '../../vector';
|
||||
|
||||
import { DataTransformerID } from './ids';
|
||||
|
||||
@ -39,7 +38,7 @@ export const seriesToRowsTransformer: DataTransformerInfo<SeriesToRowsTransforme
|
||||
const dataFrame = new MutableDataFrame();
|
||||
const metricField: Field = {
|
||||
name: TIME_SERIES_METRIC_FIELD_NAME,
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
config: {},
|
||||
type: FieldType.string,
|
||||
};
|
||||
@ -92,7 +91,7 @@ const copyFieldStructure = (field: Field, name: string): Field => {
|
||||
return {
|
||||
...omit(field, ['values', 'state', 'labels', 'config', 'name']),
|
||||
name: name,
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
config: {
|
||||
...omit(field.config, ['displayName', 'displayNameFromDS']),
|
||||
},
|
||||
|
@ -1,7 +1,6 @@
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
import {
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
DataQuery,
|
||||
DataQueryRequest,
|
||||
@ -327,15 +326,15 @@ describe('dataFrameToLogsModel', () => {
|
||||
{
|
||||
name: 'info',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([1556270891000, 1556289770000]) },
|
||||
{ type: 'number', values: new ArrayVector([1, 0]) },
|
||||
{ type: 'time', values: [1556270891000, 1556289770000] },
|
||||
{ type: 'number', values: [1, 0] },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'error',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([1556289770000]) },
|
||||
{ type: 'number', values: new ArrayVector([1]) },
|
||||
{ type: 'time', values: [1556289770000] },
|
||||
{ type: 'number', values: [1] },
|
||||
],
|
||||
},
|
||||
]);
|
||||
@ -425,15 +424,15 @@ describe('dataFrameToLogsModel', () => {
|
||||
{
|
||||
name: 'info',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([1556270891000, 1556289770000]) },
|
||||
{ type: 'number', values: new ArrayVector([1, 0]) },
|
||||
{ type: 'time', values: [1556270891000, 1556289770000] },
|
||||
{ type: 'number', values: [1, 0] },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'error',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([1556289770000]) },
|
||||
{ type: 'number', values: new ArrayVector([1]) },
|
||||
{ type: 'time', values: [1556289770000] },
|
||||
{ type: 'number', values: [1] },
|
||||
],
|
||||
},
|
||||
]);
|
||||
@ -698,15 +697,15 @@ describe('dataFrameToLogsModel', () => {
|
||||
{
|
||||
name: 'error',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([0, 1000, 2000]) },
|
||||
{ type: 'number', values: new ArrayVector([1, 0, 1]) },
|
||||
{ type: 'time', values: [0, 1000, 2000] },
|
||||
{ type: 'number', values: [1, 0, 1] },
|
||||
],
|
||||
},
|
||||
{
|
||||
name: 'debug',
|
||||
fields: [
|
||||
{ type: 'time', values: new ArrayVector([1000, 2000]) },
|
||||
{ type: 'number', values: new ArrayVector([1, 0]) },
|
||||
{ type: 'time', values: [1000, 2000] },
|
||||
{ type: 'number', values: [1, 0] },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
@ -3,7 +3,6 @@ import { delay, take } from 'rxjs/operators';
|
||||
import { createFetchResponse } from 'test/helpers/createFetchResponse';
|
||||
|
||||
import {
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
DataFrameJSON,
|
||||
DataSourceApi,
|
||||
@ -238,7 +237,7 @@ const expectDataFrameWithValues = ({ time, values }: { time: number[]; values: n
|
||||
name: 'time',
|
||||
state: null,
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector(time),
|
||||
values: time,
|
||||
} as Field,
|
||||
{
|
||||
config: {},
|
||||
@ -246,7 +245,7 @@ const expectDataFrameWithValues = ({ time, values }: { time: number[]; values: n
|
||||
name: 'value',
|
||||
state: null,
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(values),
|
||||
values: values,
|
||||
} as Field,
|
||||
],
|
||||
length: values.length,
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {
|
||||
AbsoluteTimeRange,
|
||||
ArrayVector,
|
||||
FieldType,
|
||||
Labels,
|
||||
LogLevel,
|
||||
@ -322,12 +321,12 @@ describe('mergeLogsVolumeDataFrames', () => {
|
||||
{
|
||||
name: 'Time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1, 2, 3]),
|
||||
values: [1, 2, 3],
|
||||
},
|
||||
{
|
||||
name: 'Value',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([3, 3, 1]),
|
||||
values: [3, 3, 1],
|
||||
config: {
|
||||
displayNameFromDS: 'info',
|
||||
},
|
||||
@ -339,12 +338,12 @@ describe('mergeLogsVolumeDataFrames', () => {
|
||||
{
|
||||
name: 'Time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1, 2, 3, 5]),
|
||||
values: [1, 2, 3, 5],
|
||||
},
|
||||
{
|
||||
name: 'Value',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([1, 2, 3, 0]),
|
||||
values: [1, 2, 3, 0],
|
||||
config: {
|
||||
displayNameFromDS: 'debug',
|
||||
},
|
||||
@ -356,12 +355,12 @@ describe('mergeLogsVolumeDataFrames', () => {
|
||||
{
|
||||
name: 'Time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([1, 6]),
|
||||
values: [1, 6],
|
||||
},
|
||||
{
|
||||
name: 'Value',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector([2, 1]),
|
||||
values: [2, 1],
|
||||
config: {
|
||||
displayNameFromDS: 'error',
|
||||
},
|
||||
@ -385,12 +384,12 @@ describe('getLogsVolumeDimensions', () => {
|
||||
{
|
||||
name: 'time',
|
||||
type: FieldType.time,
|
||||
values: new ArrayVector([]),
|
||||
values: [],
|
||||
},
|
||||
{
|
||||
name: 'value',
|
||||
type: FieldType.number,
|
||||
values: new ArrayVector(values),
|
||||
values: values,
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
DataFrameJSON,
|
||||
DataFrameView,
|
||||
@ -181,8 +180,8 @@ export class BlugeSearcher implements GrafanaSearcher {
|
||||
// Append the raw values to the same array buffer
|
||||
const length = frame.length + view.dataFrame.length;
|
||||
for (let i = 0; i < frame.fields.length; i++) {
|
||||
const values = (view.dataFrame.fields[i].values as ArrayVector).buffer;
|
||||
values.push(...frame.fields[i].values.toArray());
|
||||
const values = view.dataFrame.fields[i].values;
|
||||
values.push(...frame.fields[i].values);
|
||||
}
|
||||
view.dataFrame.length = length;
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
import {
|
||||
toDataFrame,
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
FieldType,
|
||||
toDataFrameDTO,
|
||||
@ -344,6 +343,7 @@ describe('Prepare time series transformer', () => {
|
||||
};
|
||||
|
||||
const frames = prepareTimeSeriesTransformer.transformer(config, ctx)(source);
|
||||
|
||||
expect(frames).toEqual([
|
||||
toEquableDataFrame({
|
||||
name: 'wants-to-be-many',
|
||||
@ -422,7 +422,6 @@ function toEquableDataFrame(source: any): DataFrame {
|
||||
fields: source.fields.map((field: any) => {
|
||||
return {
|
||||
...field,
|
||||
values: new ArrayVector(field.values),
|
||||
config: {},
|
||||
};
|
||||
}),
|
||||
|
@ -11,7 +11,6 @@ import {
|
||||
FieldMatcherID,
|
||||
Field,
|
||||
MutableDataFrame,
|
||||
ArrayVector,
|
||||
} from '@grafana/data';
|
||||
import { Labels } from 'app/types/unified-alerting-dto';
|
||||
|
||||
@ -115,11 +114,11 @@ export function toTimeSeriesMulti(data: DataFrame[]): DataFrame[] {
|
||||
fields: [
|
||||
{
|
||||
...timeField,
|
||||
values: new ArrayVector(b.time),
|
||||
values: b.time,
|
||||
},
|
||||
{
|
||||
...field,
|
||||
values: new ArrayVector(b.value),
|
||||
values: b.value,
|
||||
labels: b.labels,
|
||||
},
|
||||
],
|
||||
|
@ -69,10 +69,7 @@ export function timeSeriesToTableTransform(options: TimeSeriesTableTransformerOp
|
||||
};
|
||||
refId2frameField[refId] = frameField;
|
||||
|
||||
// NOTE: MutableDataFrame.addField() makes copies, including any .values buffers
|
||||
// since we do .values.add() later on the *originals*, we pass a custom MutableVectorCreator
|
||||
// which will re-use the existing empty .values buffer by reference
|
||||
const table = new MutableDataFrame(undefined, (buffer) => buffer ?? []);
|
||||
const table = new MutableDataFrame();
|
||||
for (const label of Object.values(labelFields)) {
|
||||
table.addField(label);
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ describe('CloudWatchMetricsQueryRunner', () => {
|
||||
expect(getFrameDisplayName(result.data[0])).toBe(
|
||||
data.results.A.series?.length && data.results.A.series[0].target
|
||||
);
|
||||
expect(result.data[0].fields[1].values.buffer[0]).toBe(
|
||||
expect(result.data[0].fields[1].values[0]).toBe(
|
||||
data.results.A.series?.length && data.results.A.series[0].datapoints[0][0]
|
||||
);
|
||||
});
|
||||
@ -333,7 +333,7 @@ describe('CloudWatchMetricsQueryRunner', () => {
|
||||
expect(getFrameDisplayName(result.data[0])).toBe(
|
||||
data.results.A.series?.length && data.results.A.series[0].target
|
||||
);
|
||||
expect(result.data[0].fields[1].values.buffer[0]).toBe(
|
||||
expect(result.data[0].fields[1].values[0]).toBe(
|
||||
data.results.A.series?.length && data.results.A.series[0].datapoints[0][0]
|
||||
);
|
||||
});
|
||||
|
@ -2,7 +2,6 @@ import { map } from 'lodash';
|
||||
import { Observable, of, throwError } from 'rxjs';
|
||||
|
||||
import {
|
||||
ArrayVector,
|
||||
CoreApp,
|
||||
DataLink,
|
||||
DataQueryRequest,
|
||||
@ -236,13 +235,13 @@ describe('ElasticDatasource', () => {
|
||||
name: 'Time',
|
||||
type: FieldType.time,
|
||||
config: {},
|
||||
values: new ArrayVector([1000]),
|
||||
values: [1000],
|
||||
},
|
||||
{
|
||||
name: 'Value',
|
||||
type: FieldType.number,
|
||||
config: {},
|
||||
values: new ArrayVector([10]),
|
||||
values: [10],
|
||||
},
|
||||
],
|
||||
length: 1,
|
||||
@ -997,11 +996,11 @@ describe('enhanceDataFrame', () => {
|
||||
fields: [
|
||||
{
|
||||
name: 'urlField',
|
||||
values: new ArrayVector([]),
|
||||
values: [],
|
||||
},
|
||||
{
|
||||
name: 'traceField',
|
||||
values: new ArrayVector([]),
|
||||
values: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
@ -1065,7 +1064,7 @@ describe('enhanceDataFrame', () => {
|
||||
fields: [
|
||||
{
|
||||
name: 'someField',
|
||||
values: new ArrayVector([]),
|
||||
values: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ArrayVector, FieldDTO } from '@grafana/data';
|
||||
import { FieldDTO } from '@grafana/data';
|
||||
|
||||
import { TraceResponse } from './types';
|
||||
|
||||
@ -51,7 +51,7 @@ export const testResponse: TraceResponse = {
|
||||
};
|
||||
|
||||
function toVectors(fields: FieldDTO[]) {
|
||||
return fields.map((f) => ({ ...f, values: new ArrayVector<any>(f.values as any[]) }));
|
||||
return fields.map((f) => ({ ...f, values: f.values }));
|
||||
}
|
||||
|
||||
export const testResponseDataFrameFields = toVectors([
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ArrayVector, DataFrameView, dateTime, MutableDataFrame } from '@grafana/data';
|
||||
import { DataFrameView, dateTime, MutableDataFrame } from '@grafana/data';
|
||||
|
||||
import { createGraphFrames, mapPromMetricsToServiceMap } from './graphTransform';
|
||||
import { bigResponse } from './testResponse';
|
||||
@ -74,19 +74,19 @@ describe('mapPromMetricsToServiceMap', () => {
|
||||
);
|
||||
|
||||
expect(nodes.fields).toMatchObject([
|
||||
{ name: 'id', values: new ArrayVector(['db', 'app', 'lb']) },
|
||||
{ name: 'title', values: new ArrayVector(['db', 'app', 'lb']) },
|
||||
{ name: 'mainstat', values: new ArrayVector([1000, 2000, NaN]) },
|
||||
{ name: 'secondarystat', values: new ArrayVector([0.17, 0.33, NaN]) },
|
||||
{ name: 'arc__success', values: new ArrayVector([0.8, 0.25, 1]) },
|
||||
{ name: 'arc__failed', values: new ArrayVector([0.2, 0.75, 0]) },
|
||||
{ name: 'id', values: ['db', 'app', 'lb'] },
|
||||
{ name: 'title', values: ['db', 'app', 'lb'] },
|
||||
{ name: 'mainstat', values: [1000, 2000, NaN] },
|
||||
{ name: 'secondarystat', values: [0.17, 0.33, NaN] },
|
||||
{ name: 'arc__success', values: [0.8, 0.25, 1] },
|
||||
{ name: 'arc__failed', values: [0.2, 0.75, 0] },
|
||||
]);
|
||||
expect(edges.fields).toMatchObject([
|
||||
{ name: 'id', values: new ArrayVector(['app_db', 'lb_app']) },
|
||||
{ name: 'source', values: new ArrayVector(['app', 'lb']) },
|
||||
{ name: 'target', values: new ArrayVector(['db', 'app']) },
|
||||
{ name: 'mainstat', values: new ArrayVector([1000, 2000]) },
|
||||
{ name: 'secondarystat', values: new ArrayVector([0.17, 0.33]) },
|
||||
{ name: 'id', values: ['app_db', 'lb_app'] },
|
||||
{ name: 'source', values: ['app', 'lb'] },
|
||||
{ name: 'target', values: ['db', 'app'] },
|
||||
{ name: 'mainstat', values: [1000, 2000] },
|
||||
{ name: 'secondarystat', values: [0.17, 0.33] },
|
||||
]);
|
||||
});
|
||||
|
||||
@ -106,12 +106,12 @@ describe('mapPromMetricsToServiceMap', () => {
|
||||
);
|
||||
|
||||
expect(nodes.fields).toMatchObject([
|
||||
{ name: 'id', values: new ArrayVector(['db', 'app', 'lb']) },
|
||||
{ name: 'title', values: new ArrayVector(['db', 'app', 'lb']) },
|
||||
{ name: 'mainstat', values: new ArrayVector([1000, 2000, NaN]) },
|
||||
{ name: 'secondarystat', values: new ArrayVector([0.17, 0.33, NaN]) },
|
||||
{ name: 'arc__success', values: new ArrayVector([0, 0, 1]) },
|
||||
{ name: 'arc__failed', values: new ArrayVector([1, 1, 0]) },
|
||||
{ name: 'id', values: ['db', 'app', 'lb'] },
|
||||
{ name: 'title', values: ['db', 'app', 'lb'] },
|
||||
{ name: 'mainstat', values: [1000, 2000, NaN] },
|
||||
{ name: 'secondarystat', values: [0.17, 0.33, NaN] },
|
||||
{ name: 'arc__success', values: [0, 0, 1] },
|
||||
{ name: 'arc__failed', values: [1, 1, 0] },
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
@ -6,7 +6,6 @@ import {
|
||||
PluginType,
|
||||
DataSourceInstanceSettings,
|
||||
dateTime,
|
||||
ArrayVector,
|
||||
PluginMetaInfo,
|
||||
} from '@grafana/data';
|
||||
|
||||
@ -71,12 +70,12 @@ describe('transformTraceList()', () => {
|
||||
test('extracts traceIDs from log lines', () => {
|
||||
const frame = createTableFrame(lokiDataFrame, 't1', 'tempo', ['traceID=(\\w+)', 'traceID=(\\w\\w)']);
|
||||
expect(frame.fields[0].name).toBe('Time');
|
||||
expect(frame.fields[0].values.get(0)).toBe('2020-02-12T15:05:15.265Z');
|
||||
expect(frame.fields[0].values[0]).toBe('2020-02-12T15:05:15.265Z');
|
||||
expect(frame.fields[1].name).toBe('traceID');
|
||||
expect(frame.fields[1].values.get(0)).toBe('asdfa1234');
|
||||
expect(frame.fields[1].values[0]).toBe('asdfa1234');
|
||||
// Second match in new line
|
||||
expect(frame.fields[0].values.get(1)).toBe('2020-02-12T15:05:15.265Z');
|
||||
expect(frame.fields[1].values.get(1)).toBe('as');
|
||||
expect(frame.fields[0].values[1]).toBe('2020-02-12T15:05:15.265Z');
|
||||
expect(frame.fields[1].values[1]).toBe('as');
|
||||
});
|
||||
});
|
||||
|
||||
@ -106,20 +105,20 @@ describe('createTableFrameFromSearch()', () => {
|
||||
test('transforms search response to dataFrame', () => {
|
||||
const frame = createTableFrameFromSearch(tempoSearchResponse.traces as TraceSearchMetadata[], defaultSettings);
|
||||
expect(frame.fields[0].name).toBe('traceID');
|
||||
expect(frame.fields[0].values.get(0)).toBe('e641dcac1c3a0565');
|
||||
expect(frame.fields[0].values[0]).toBe('e641dcac1c3a0565');
|
||||
|
||||
// TraceID must have unit = 'string' to prevent the ID from rendering as Infinity
|
||||
expect(frame.fields[0].config.unit).toBe('string');
|
||||
|
||||
expect(frame.fields[1].name).toBe('traceName');
|
||||
expect(frame.fields[1].values.get(0)).toBe('c10d7ca4e3a00354 ');
|
||||
expect(frame.fields[1].values[0]).toBe('c10d7ca4e3a00354 ');
|
||||
|
||||
expect(frame.fields[2].name).toBe('startTime');
|
||||
expect(frame.fields[2].values.get(0)).toBe('2022-01-28 03:00:28');
|
||||
expect(frame.fields[2].values.get(1)).toBe('2022-01-27 22:56:06');
|
||||
expect(frame.fields[2].values[0]).toBe('2022-01-28 03:00:28');
|
||||
expect(frame.fields[2].values[1]).toBe('2022-01-27 22:56:06');
|
||||
|
||||
expect(frame.fields[3].name).toBe('traceDuration');
|
||||
expect(frame.fields[3].values.get(0)).toBe(65);
|
||||
expect(frame.fields[3].values[0]).toBe(65);
|
||||
});
|
||||
});
|
||||
|
||||
@ -129,23 +128,20 @@ describe('createTableFrameFromTraceQlQuery()', () => {
|
||||
const frame = frameList[0];
|
||||
// Trace ID field
|
||||
expect(frame.fields[0].name).toBe('traceID');
|
||||
expect(frame.fields[0].values.get(0)).toBe('b1586c3c8c34d');
|
||||
expect(frame.fields[0].values[0]).toBe('b1586c3c8c34d');
|
||||
expect(frame.fields[0].config.unit).toBe('string');
|
||||
expect(frame.fields[0].values).toBeInstanceOf(ArrayVector);
|
||||
// Start time field
|
||||
expect(frame.fields[1].name).toBe('startTime');
|
||||
expect(frame.fields[1].type).toBe('string');
|
||||
expect(frame.fields[1].values.get(1)).toBe('2022-01-27 22:56:06');
|
||||
expect(frame.fields[1].values).toBeInstanceOf(ArrayVector);
|
||||
expect(frame.fields[1].values[1]).toBe('2022-01-27 22:56:06');
|
||||
// Trace name field
|
||||
expect(frame.fields[2].name).toBe('traceName');
|
||||
expect(frame.fields[2].type).toBe('string');
|
||||
expect(frame.fields[2].values.get(0)).toBe('lb HTTP Client');
|
||||
expect(frame.fields[2].values).toBeInstanceOf(ArrayVector);
|
||||
expect(frame.fields[2].values[0]).toBe('lb HTTP Client');
|
||||
// Duration field
|
||||
expect(frame.fields[3].name).toBe('traceDuration');
|
||||
expect(frame.fields[3].type).toBe('number');
|
||||
expect(frame.fields[3].values.get(2)).toBe(44);
|
||||
expect(frame.fields[3].values[2]).toBe(44);
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -77,7 +77,7 @@ export function createTableFrame(
|
||||
for (let field of logsFrame.fields) {
|
||||
let hasMatch = false;
|
||||
if (field.type === FieldType.string) {
|
||||
const values = field.values.toArray();
|
||||
const values = field.values;
|
||||
for (let i = 0; i < values.length; i++) {
|
||||
const line = values[i];
|
||||
if (line) {
|
||||
|
@ -1,5 +1,3 @@
|
||||
import { ArrayVector } from '@grafana/data';
|
||||
|
||||
import { ZipkinSpan } from '../types';
|
||||
|
||||
export const zipkinResponse: ZipkinSpan[] = [
|
||||
@ -127,4 +125,4 @@ export const traceFrameFields = [
|
||||
[],
|
||||
],
|
||||
},
|
||||
].map((f) => ({ ...f, values: new ArrayVector<any>(f.values) }));
|
||||
].map((f) => ({ ...f, values: f.values }));
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ArrayVector, FieldDTO } from '@grafana/data';
|
||||
import { FieldDTO } from '@grafana/data';
|
||||
|
||||
import { ZipkinSpan } from '../types';
|
||||
|
||||
@ -35,7 +35,7 @@ export const testResponse: ZipkinSpan[] = [
|
||||
];
|
||||
|
||||
function toVectors(fields: FieldDTO[]) {
|
||||
return fields.map((f) => ({ ...f, values: new ArrayVector<any>(f.values as any[]) }));
|
||||
return fields.map((f) => ({ ...f, values: f.values }));
|
||||
}
|
||||
|
||||
export const testResponseDataFrameFields = toVectors([
|
||||
|
@ -1,26 +1,26 @@
|
||||
import { ArrayVector, FieldType, DataFrame, dateTime } from '@grafana/data';
|
||||
import { FieldType, DataFrame, dateTime } from '@grafana/data';
|
||||
|
||||
import { Feed } from './types';
|
||||
|
||||
export function feedToDataFrame(feed: Feed): DataFrame {
|
||||
const date = new ArrayVector<number>([]);
|
||||
const title = new ArrayVector<string>([]);
|
||||
const link = new ArrayVector<string>([]);
|
||||
const content = new ArrayVector<string>([]);
|
||||
const ogImage = new ArrayVector<string | undefined | null>([]);
|
||||
const date: number[] = [];
|
||||
const title: string[] = [];
|
||||
const link: string[] = [];
|
||||
const content: string[] = [];
|
||||
const ogImage: Array<string | undefined | null> = [];
|
||||
|
||||
for (const item of feed.items) {
|
||||
const val = dateTime(item.pubDate);
|
||||
|
||||
try {
|
||||
date.buffer.push(val.valueOf());
|
||||
title.buffer.push(item.title);
|
||||
link.buffer.push(item.link);
|
||||
ogImage.buffer.push(item.ogImage);
|
||||
date.push(val.valueOf());
|
||||
title.push(item.title);
|
||||
link.push(item.link);
|
||||
ogImage.push(item.ogImage);
|
||||
|
||||
if (item.content) {
|
||||
const body = item.content.replace(/<\/?[^>]+(>|$)/g, '');
|
||||
content.buffer.push(body);
|
||||
content.push(body);
|
||||
}
|
||||
} catch (err) {
|
||||
console.warn('Error reading news item:', err, item);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ArrayVector, DataFrame, FieldType, MutableDataFrame } from '@grafana/data';
|
||||
import { DataFrame, FieldType, MutableDataFrame } from '@grafana/data';
|
||||
|
||||
import { NodeDatum, NodeGraphOptions } from './types';
|
||||
import {
|
||||
@ -63,8 +63,8 @@ describe('processNodes', () => {
|
||||
expect.objectContaining(makeNodeFromEdgeDatum({ dataFrameRowIndex: 2, id: '2', incoming: 2, title: '2' })),
|
||||
]);
|
||||
|
||||
expect(nodes[0].mainStat?.values).toEqual(new ArrayVector([undefined, 1, 2]));
|
||||
expect(nodes[0].secondaryStat?.values).toEqual(new ArrayVector([undefined, 1, 2]));
|
||||
expect(nodes[0].mainStat?.values).toEqual([undefined, 1, 2]);
|
||||
expect(nodes[0].secondaryStat?.values).toEqual([undefined, 1, 2]);
|
||||
|
||||
expect(nodes[0].mainStat).toEqual(nodes[1].mainStat);
|
||||
expect(nodes[0].mainStat).toEqual(nodes[2].mainStat);
|
||||
@ -265,7 +265,7 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) {
|
||||
index: 7,
|
||||
name: 'color',
|
||||
type: 'number',
|
||||
values: new ArrayVector([0.5, 0.5, 0.5]),
|
||||
values: [0.5, 0.5, 0.5],
|
||||
};
|
||||
|
||||
return {
|
||||
@ -278,7 +278,7 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) {
|
||||
},
|
||||
name: 'arc__success',
|
||||
type: 'number',
|
||||
values: new ArrayVector([0.5, 0.5, 0.5]),
|
||||
values: [0.5, 0.5, 0.5],
|
||||
},
|
||||
{
|
||||
config: {
|
||||
@ -288,7 +288,7 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) {
|
||||
},
|
||||
name: 'arc__errors',
|
||||
type: 'number',
|
||||
values: new ArrayVector([0.5, 0.5, 0.5]),
|
||||
values: [0.5, 0.5, 0.5],
|
||||
},
|
||||
],
|
||||
color: colorField,
|
||||
@ -300,14 +300,14 @@ function makeNodeDatum(options: Partial<NodeDatum> = {}) {
|
||||
index: 3,
|
||||
name: 'mainstat',
|
||||
type: 'number',
|
||||
values: new ArrayVector([0.1, 0.1, 0.1]),
|
||||
values: [0.1, 0.1, 0.1],
|
||||
},
|
||||
secondaryStat: {
|
||||
config: {},
|
||||
index: 4,
|
||||
name: 'secondarystat',
|
||||
type: 'number',
|
||||
values: new ArrayVector([2, 2, 2]),
|
||||
values: [2, 2, 2],
|
||||
},
|
||||
subTitle: 'service',
|
||||
title: 'service:0',
|
||||
|
@ -1,5 +1,4 @@
|
||||
import {
|
||||
ArrayVector,
|
||||
DataFrame,
|
||||
Field,
|
||||
FieldCache,
|
||||
@ -230,8 +229,8 @@ function computableField(field?: Field) {
|
||||
* @param edgeFields
|
||||
*/
|
||||
function normalizeStatsForNodes(nodesMap: { [id: string]: NodeDatumFromEdge }, edgeFields: EdgeFields): NodeDatum[] {
|
||||
const secondaryStatValues = new ArrayVector();
|
||||
const mainStatValues = new ArrayVector();
|
||||
const secondaryStatValues: any[] = [];
|
||||
const mainStatValues: any[] = [];
|
||||
const secondaryStatField = computableField(edgeFields.secondaryStat)
|
||||
? {
|
||||
...edgeFields.secondaryStat!,
|
||||
@ -347,42 +346,42 @@ function makeNode(index: number) {
|
||||
function nodesFrame() {
|
||||
const fields: any = {
|
||||
[NodeGraphDataFrameFieldNames.id]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.title]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.subTitle]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.mainStat]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.secondaryStat]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.arc + 'success']: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
config: { color: { fixedColor: 'green' } },
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.arc + 'errors']: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
config: { color: { fixedColor: 'red' } },
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.color]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
config: { color: { mode: 'continuous-GrYlRd' } },
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.icon]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
};
|
||||
@ -413,23 +412,23 @@ export function makeEdgesDataFrame(
|
||||
function edgesFrame() {
|
||||
const fields: any = {
|
||||
[NodeGraphDataFrameFieldNames.id]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.source]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.target]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.string,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.mainStat]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
},
|
||||
[NodeGraphDataFrameFieldNames.secondaryStat]: {
|
||||
values: new ArrayVector(),
|
||||
values: [],
|
||||
type: FieldType.number,
|
||||
},
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user