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:
@@ -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 }
|
||||
|
||||
|
||||
@@ -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})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user