You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.
Currently the data Package has the Frame structure, with its Fields and Vectors. (Currently there are only *time.Time and *float64 vectors).
// Frame is a columnar container for data.typeFramestruct {
Namestring`json:"name"`FieldsFields`json:"fields"`LabelsLabels`json:"labels"`RefIDstring`json:"refId"`// GrafanaType
}
// Field holds information and Type and its values.typeFieldstruct {
Namestring`json:"name"`TypeFieldType`json:"type"`VectorVector`json:"values"`// KMB thinks this should be vectors
}
and
// Vector is an Interface for the Vectors within a Field of Frame.typeVectorinterface {
// SetValue sets val at idx of the Vector. It will panic if the vector is not initialized, idx is out of range, or// val is not of the expected type.SetValue(idxint, valinterface{})
// GetValue returns the value at idx of the Vector. It will panic if the vector is not initialized or if idx is out of range.GetValue(idxint) interface{}
// Make initializes the vector and makes of length len.Make(lenint)
Len() intcopy() Vector
}
However, the mathexp package has certains "types/shapes" of data.Frame, in particular Scalar, Number, and Series. For example:
// Series has *time.Time and *float64 fields.typeSeriesstruct{ *data.Frame }
// Type returns the Value type and allows it to fulfill the Value interface.func (sSeries) Type() parse.ReturnType { returnparse.TypeSeriesSet }
// Value returns the actual value allows it to fulfill the Value interface.func (sSeries) Value() interface{} { return&s }
// AsDataFrame returns the underlying *data.Frame.func (sSeries) AsDataFrame() *data.Frame { returns.Frame }
// GetPoint returns the time and value at the specified index.func (sSeries) GetPoint(pointIdxint) (*time.Time, *float64) {
returns.GetTime(pointIdx), s.GetValue(pointIdx)
}
// SetPoint sets the time and value on the corresponding vectors at the specified index.func (sSeries) SetPoint(pointIdxint, t*time.Time, f*float64) {
s.Fields[0].Vector.SetValue(pointIdx, t) // We switch from tsdb's package value,time to time,values.Fields[1].Vector.SetValue(pointIdx, f)
}
// Len returns the length of the series.func (sSeries) Len() int {
returns.Fields[0].Vector.Len()
}
// GetTime returns the time at the specified index.func (sSeries) GetTime(pointIdxint) *time.Time {
returns.Fields[0].Vector.GetValue(pointIdx).(*time.Time)
}
I'm not sure these shapes of DataFrames should be part of the data package that is open source. We probably want them to be available, but that might make iterating on them more annoying.
The text was updated successfully, but these errors were encountered:
Currently the
data
Package has theFrame
structure, with itsFields
andVectors
. (Currently there are only*time.Time
and*float64 vectors
).and
However, the
mathexp
package has certains "types/shapes" of data.Frame, in particularScalar
,Number
, andSeries
. For example:I'm not sure these shapes of DataFrames should be part of the data package that is open source. We probably want them to be available, but that might make iterating on them more annoying.
The text was updated successfully, but these errors were encountered: