Skip to content

Commit

Permalink
Allow creation of arbitrary presision HLL sketch
Browse files Browse the repository at this point in the history
Adds the ability to create a spare or non-sparse hll graph of the
provided precision via the hyperloglog::NewSketch function.
Provides capabilities requested in  axiomhq#32
  • Loading branch information
Chris Gray authored and Chris Gray committed May 1, 2023
1 parent 3ddf4ba commit ee79bdd
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions hyperloglog.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ func New() *Sketch {
return New14()
}

// NewSketch returns a HyperLogLog Sketch with 2^precision registers
func NewSketch(precision uint8, sparse bool) (*Sketch, error) {
sk, err := newSketch(precision, sparse)
if err != nil {
return nil, err
}
return sk, err
}

// New14 returns a HyperLogLog Sketch with 2^14 registers (precision 14)
func New14() *Sketch {
sk, _ := newSketch(14, true)
Expand Down

0 comments on commit ee79bdd

Please sign in to comment.