Estimate returns the estimated cardinality over the last staleTime window.
()
| 94 | |
| 95 | // Estimate returns the estimated cardinality over the last staleTime window. |
| 96 | func (c *Cardinality) Estimate() uint64 { |
| 97 | c.mu.RLock() |
| 98 | window := c.cachedMerge.Clone() |
| 99 | current := c.sketches[c.current].Clone() |
| 100 | c.mu.RUnlock() |
| 101 | _ = window.Merge(current) |
| 102 | return window.Estimate() |
| 103 | } |
| 104 | |
| 105 | // Advance should be called by an external ticker every sketchDuration to advance the ring. |
| 106 | // It advances at least 1 step per call. |