SSE/NG: Add expression metadata for EvalMatch (#32213)

- Add the ability to stick metadata attached to a value in expressions. Currently uses Frame.Meta.Custom.
- None of this is consumed by anything yet, so an incremental step.
This commit is contained in:
Kyle Brandt
2021-03-23 12:23:54 -04:00
committed by GitHub
parent 7bb79158ed
commit 1cd8981be4
4 changed files with 76 additions and 9 deletions
+8
View File
@@ -97,6 +97,14 @@ func (s Series) SetLabels(ls data.Labels) { s.Frame.Fields[s.ValueIdx].Labels =
func (s Series) GetName() string { return s.Frame.Name }
func (s Series) GetMeta() interface{} {
return s.Frame.Meta.Custom
}
func (s Series) SetMeta(v interface{}) {
s.Frame.SetMeta(&data.FrameMeta{Custom: v})
}
// AsDataFrame returns the underlying *data.Frame.
func (s Series) AsDataFrame() *data.Frame { return s.Frame }
+18
View File
@@ -30,6 +30,8 @@ type Value interface {
Value() interface{}
GetLabels() data.Labels
SetLabels(data.Labels)
GetMeta() interface{}
SetMeta(interface{})
AsDataFrame() *data.Frame
}
@@ -48,6 +50,14 @@ func (s Scalar) GetLabels() data.Labels { return nil }
func (s Scalar) SetLabels(ls data.Labels) {}
func (s Scalar) GetMeta() interface{} {
return s.Frame.Meta.Custom
}
func (s Scalar) SetMeta(v interface{}) {
s.Frame.SetMeta(&data.FrameMeta{Custom: v})
}
// AsDataFrame returns the underlying *data.Frame.
func (s Scalar) AsDataFrame() *data.Frame { return s.Frame }
@@ -105,3 +115,11 @@ func NewNumber(name string, labels data.Labels) Number {
),
}
}
func (n Number) GetMeta() interface{} {
return n.Frame.Meta.Custom
}
func (n Number) SetMeta(v interface{}) {
n.Frame.SetMeta(&data.FrameMeta{Custom: v})
}