Files
dependabot[bot]GitHubdependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>Zach Lesliegithub-actions[bot] <github-actions[bot]@users.noreply.github.com>
2c30aeb642 Bump github.com/alicebob/miniredis/v2 from 2.14.3 to 2.21.0 (#1529)
* Bump github.com/alicebob/miniredis/v2 from 2.14.3 to 2.21.0

Bumps [github.com/alicebob/miniredis/v2](https://github.com/alicebob/miniredis) from 2.14.3 to 2.21.0.
- [Release notes](https://github.com/alicebob/miniredis/releases)
- [Changelog](https://github.com/alicebob/miniredis/blob/master/CHANGELOG.md)
- [Commits](https://github.com/alicebob/miniredis/compare/v2.14.3...v2.21.0)

---
updated-dependencies:
- dependency-name: github.com/alicebob/miniredis/v2
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Commit serverless gomod changes

* Update serverless gomod

* Commit only when needed

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Zach Leslie <[email protected]>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2022-06-30 09:07:10 -06:00

43 lines
851 B
Go

package miniredis
import (
"github.com/alicebob/miniredis/v2/hyperloglog"
)
type hll struct {
inner *hyperloglog.Sketch
}
func newHll() *hll {
return &hll{
inner: hyperloglog.New14(),
}
}
// Add returns true if cardinality has been changed, or false otherwise.
func (h *hll) Add(item []byte) bool {
return h.inner.Insert(item)
}
// Count returns the estimation of a set cardinality.
func (h *hll) Count() int {
return int(h.inner.Estimate())
}
// Merge merges the other hll into original one (not making a copy but doing this in place).
func (h *hll) Merge(other *hll) {
_ = h.inner.Merge(other.inner)
}
// Bytes returns raw-bytes representation of hll data structure.
func (h *hll) Bytes() []byte {
dataBytes, _ := h.inner.MarshalBinary()
return dataBytes
}
func (h *hll) copy() *hll {
return &hll{
inner: h.inner.Clone(),
}
}