mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -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:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user