Documentation
¶
Index ¶
- func Maxf(l, r float64) float64
- func Minf(l, r float64) float64
- func Sumf(slice []float64) float64
- type ProbabilityDistribution
- type Rate
- type TSMaxFloatHeap
- func (mh *TSMaxFloatHeap) At(idx int) float64
- func (mh *TSMaxFloatHeap) Clear()
- func (mh *TSMaxFloatHeap) Len() int
- func (mh *TSMaxFloatHeap) Less(i, j int) bool
- func (mh *TSMaxFloatHeap) Pop() interface{}
- func (mh *TSMaxFloatHeap) Push(item interface{})
- func (mh *TSMaxFloatHeap) PushSlice(items ...interface{})
- func (mh *TSMaxFloatHeap) Swap(i, j int)
- func (mh *TSMaxFloatHeap) TopN(n int) ([]float64, error)
- type TimeDistribution
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ProbabilityDistribution ¶
type ProbabilityDistribution struct { Max float64 `json:"max"` Min float64 `json:"min"` Mean float64 `json:"mean"` Stddev float64 `json:"stddev"` VLen int `json:"v_len"` Values *TSMaxFloatHeap `json:"values"` sync.RWMutex // contains filtered or unexported fields }
func NewProbabilityDistribution ¶
func NewProbabilityDistribution() *ProbabilityDistribution
func (*ProbabilityDistribution) Add ¶
func (pd *ProbabilityDistribution) Add(value float64)
Add a value to the distribution
func (*ProbabilityDistribution) Clear ¶
func (pd *ProbabilityDistribution) Clear()
func (*ProbabilityDistribution) JSON ¶
func (pd *ProbabilityDistribution) JSON() (string, error)
JSON returns the probability distribution as a JSON string
func (*ProbabilityDistribution) Len ¶
func (pd *ProbabilityDistribution) Len() int
type Rate ¶
type Rate struct {
// contains filtered or unexported fields
}
Rate records the rate of requests to a time distribution
type TSMaxFloatHeap ¶
type TSMaxFloatHeap struct { sync.RWMutex // This is public for extensiblity. Beware deadlock, though! // contains filtered or unexported fields }
TSMaxFloatHeap is a thread safe max heap of floats for always-ordered data
func NewTSMaxFloatHeap ¶
func NewTSMaxFloatHeap() *TSMaxFloatHeap
func NewTSMaxFloatHeapFromSlice ¶
func NewTSMaxFloatHeapFromSlice(items ...interface{}) *TSMaxFloatHeap
func (*TSMaxFloatHeap) At ¶
func (mh *TSMaxFloatHeap) At(idx int) float64
func (*TSMaxFloatHeap) Clear ¶
func (mh *TSMaxFloatHeap) Clear()
func (*TSMaxFloatHeap) Len ¶
func (mh *TSMaxFloatHeap) Len() int
func (*TSMaxFloatHeap) Less ¶
func (mh *TSMaxFloatHeap) Less(i, j int) bool
func (*TSMaxFloatHeap) Pop ¶
func (mh *TSMaxFloatHeap) Pop() interface{}
func (*TSMaxFloatHeap) Push ¶
func (mh *TSMaxFloatHeap) Push(item interface{})
func (*TSMaxFloatHeap) PushSlice ¶
func (mh *TSMaxFloatHeap) PushSlice(items ...interface{})
Push implements a thread-safe push operation into a probability heap
func (*TSMaxFloatHeap) Swap ¶
func (mh *TSMaxFloatHeap) Swap(i, j int)
type TimeDistribution ¶
type TimeDistribution struct { KeyedRate map[string]*Rate // Maps some key to a probability distribution Interval []int // Represents a list of times, (1 second, 1 minute, 1 hour, etc) sync.RWMutex }
TODO(jparr721) - Add different back ends for badger db and redis for storage. TimeDistribution keeps track of input rates over time intervals via some keyed value
func NewTimeDistribution ¶
func NewTimeDistribution(interval []int) *TimeDistribution
func (*TimeDistribution) Clear ¶
func (td *TimeDistribution) Clear()
Clears the time distribution keeping the interval present
func (*TimeDistribution) Increment ¶
func (td *TimeDistribution) Increment(key string)
Click to show internal directories.
Click to hide internal directories.