Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,10 @@ Streams (Cormode, Korn, Muthukrishnan, Srivastava) to provide a space and time
efficient estimator for streaming quantile estimation.

[![Build Status](https://travis-ci.org/streadway/quantile.svg?branch=master)](https://travis-ci.org/streadway/quantile)


## Improved API

This fork improves the currecntly existing API in allowing developers to customize **buffer** and **pool** size.

Original developers kept ratio between the two at 1/2.
12 changes: 6 additions & 6 deletions quantile.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,29 +100,29 @@ var defaultInvariants = []Estimate{Unknown(0.1)}
// query, use a Known estimation for each quantile you will query. For
// example:
//
// quantile.New(quantile.Known(0.50, 0.01), quantile.Known(0.95, 0.001), quantile.Known(0.99, 0.0005))
// quantile.New(quantile.Known(0.50, 0.01), quantile.Known(0.95, 0.001), quantile.Known(0.99, 0.0005))
//
// When you will query for multiple different quantiles, and know the error
// tolerance, use the Bias invariant. For example:
//
// quantile.New(quantile.Unknown(0.01))
// quantile.New(quantile.Unknown(0.01))
//
// Targeted estimators consume significantly less resources than Biased estimators.
//
// Passing no parameters will create an estimator that has a tolerance of 0.1, equivalent to:
//
// quantile.New(quantile.Unknown(0.1))
// quantile.New(quantile.Unknown(0.1))
//
// Estimators are not safe to use from multiple goroutines.
func New(invariants ...Estimate) *Estimator {
func New(bufferSize uint64, poolSize uint64, invariants ...Estimate) *Estimator {
if len(invariants) == 0 {
invariants = defaultInvariants
}

return &Estimator{
invariants: invariants,
buffer: make([]float64, 0, 512),
pool: make(chan *item, 1024),
buffer: make([]float64, 0, bufferSize),
pool: make(chan *item, poolSize),
}
}

Expand Down