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:
Ryan McKinley
2023-04-14 07:03:45 -07:00
committed by GitHub
parent 6d53c87862
commit e65163ba4e
57 changed files with 374 additions and 448 deletions

View File

@@ -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: {},
};
}),

View File

@@ -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,
},
],

View File

@@ -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);
}