Documentation ¶
Index ¶
- Variables
- func Dist(hash, i, capacity int64) int64
- func HashKey(key []byte) int64
- func HashUint64(key uint64) int64
- type HashMap
- func (m *HashMap) AverageProbeCount() float64
- func (m *HashMap) Cap() int64
- func (m *HashMap) Elem(i int64) (key []byte, value interface{})
- func (m *HashMap) Get(key []byte) interface{}
- func (m *HashMap) Keys() [][]byte
- func (m *HashMap) Len() int64
- func (m *HashMap) PrometheusCollectors() []prometheus.Collector
- func (m *HashMap) Put(key []byte, val interface{})
- func (m *HashMap) PutQuiet(key []byte, val interface{})
- func (m *HashMap) Reset()
- type Metrics
- type Options
Constants ¶
This section is empty.
Variables ¶
var DefaultOptions = Options{ Capacity: 256, LoadFactor: 90, MetricsEnabled: true, }
DefaultOptions represents a default set of options to pass to NewHashMap().
Functions ¶
func Dist ¶
Dist returns the probe distance for a hash in a slot index. NOTE: Capacity must be a power of 2.
func HashUint64 ¶
HashUint64 computes a hash of an int64. Hash is always non-zero.
Types ¶
type HashMap ¶
type HashMap struct {
// contains filtered or unexported fields
}
HashMap represents a hash map that implements Robin Hood Hashing. https://cs.uwaterloo.ca/research/tr/1986/CS-86-14.pdf
func NewHashMap ¶
NewHashMap initialises a new Hashmap with the provided options.
func (*HashMap) AverageProbeCount ¶
AverageProbeCount returns the average number of probes for each element.
func (*HashMap) PrometheusCollectors ¶
func (m *HashMap) PrometheusCollectors() []prometheus.Collector
PrometheusCollectors returns the metrics associated with this hashmap.
func (*HashMap) Put ¶
Put stores the value at key in the Hashmap, overwriting an existing value if one exists. If the maximum load of the Hashmap is reached, the Hashmap will first resize itself.
type Metrics ¶
type Metrics struct { LoadFactor *prometheus.GaugeVec // Load factor of the hashmap. Size *prometheus.GaugeVec // Number of items in hashmap. GetDuration *prometheus.HistogramVec // Sample of get times. LastGetDuration *prometheus.GaugeVec // Sample of most recent get time. InsertDuration *prometheus.HistogramVec // Sample of insertion times. LastInsertDuration *prometheus.GaugeVec // Sample of most recent insertion time. LastGrowDuration *prometheus.GaugeVec // Most recent growth time. MeanProbeCount *prometheus.GaugeVec // Average number of probes for each element. // These metrics have an extra label status = {"hit", "miss"} Gets *prometheus.CounterVec // Number of times item retrieved. Puts *prometheus.CounterVec // Number of times item inserted. }
func NewMetrics ¶
func NewMetrics(namespace, subsystem string, labels prometheus.Labels) *Metrics
NewMetrics initialises prometheus metrics for tracking an RHH hashmap.
func (*Metrics) PrometheusCollectors ¶
func (m *Metrics) PrometheusCollectors() []prometheus.Collector
PrometheusCollectors satisfies the prom.PrometheusCollector interface.