Documentation ¶
Index ¶
Constants ¶
const EPSILON float64 = 0.01
EPSILON represents the accuracy of the sketch.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Entry ¶
Entry is an element of the sketch. For the definition of g and delta, see the original paper http://infolab.stanford.edu/~datar/courses/cs361a/papers/quantiles.pdf
func (*Entry) MarshalJSON ¶
MarshalJSON encodes an Entry into an array of values
func (*Entry) UnmarshalJSON ¶
UnmarshalJSON decodes an Entry from an array of values
type GKArray ¶
type GKArray struct { // the last item of Entries will always be the max inserted value Entries Entries `json:"entries"` Incoming []float64 `json:"buf"` // TODO[Charles]: incorporate min in entries so that we can get rid of the field. Min float64 `json:"min"` Max float64 `json:"max"` Count int64 `json:"cnt"` Sum float64 `json:"sum"` Avg float64 `json:"avg"` }
GKArray is a version of GK with a buffer for the incoming values. The expected usage is that Add() is called in the agent, while Merge() and Quantile() are called in the backend; in other words, values are added to the sketch in the agent, sketches are sent to the backend where they are merged with other sketches, and quantile queries are made to the merged sketches only. This allows us to ignore the Incoming buffer once the sketch goes through a Merge. GKArray therefore has two versions of compress:
- compressWithIncoming(incomingEntries []Entry) is used during Merge(), and sets Incoming to nil after compressing so that merged sketches do not allocate unnecessary storage.
- compressAndAllocateBuf() is used during Add(), and allocates Incoming after compressing for further addition of values to the sketch.
func (GKArray) IsValid ¶
IsValid checks that the object is a minimally valid GKArray, i.e., won't cause a panic when calling Add or Merge.
type NoSketchError ¶
type NoSketchError struct{}
NoSketchError is the error returned when not enough samples have been submitted to generate a sketch
func (NoSketchError) Error ¶
func (e NoSketchError) Error() string
type QSketch ¶
type QSketch struct {
GKArray
}
QSketch is a wrapper around GKArray to make it easier if we want to try a different sketch algorithm
type SketchSeries ¶
type SketchSeries struct { Name string `json:"metric"` Tags []string `json:"tags"` Host string `json:"host"` Interval int64 `json:"interval"` Sketches []Sketch `json:"sketches"` ContextKey string `json:"-"` }
SketchSeries holds an array of sketches.
func UnmarshalJSONSketchSeries ¶
func UnmarshalJSONSketchSeries(b []byte) ([]*SketchSeries, error)
UnmarshalJSONSketchSeries deserializes sketch series from JSON
func UnmarshalSketchSeries ¶
func UnmarshalSketchSeries(payload []byte) ([]*SketchSeries, agentpayload.CommonMetadata, error)
UnmarshalSketchSeries deserializes a protobuf byte array into sketch series
type SketchSeriesList ¶
type SketchSeriesList []*SketchSeries
SketchSeriesList represents a list of SketchSeries ready to be serialize
func (SketchSeriesList) Marshal ¶
func (sl SketchSeriesList) Marshal() ([]byte, error)
Marshal serializes sketch series using protocol buffers
func (SketchSeriesList) MarshalJSON ¶
func (sl SketchSeriesList) MarshalJSON() ([]byte, error)
MarshalJSON serializes sketch series to JSON so it can be sent to v1 endpoints
func (SketchSeriesList) SplitPayload ¶
func (sl SketchSeriesList) SplitPayload(times int) ([]marshaler.Marshaler, error)
SplitPayload breaks the payload into times number of pieces