commit
59a953db97
|
@ -10,6 +10,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// how many values we will map before emitting
|
||||||
|
const emitBatchSize = 1000
|
||||||
|
|
||||||
// DB represents an interface for creating transactions.
|
// DB represents an interface for creating transactions.
|
||||||
type DB interface {
|
type DB interface {
|
||||||
Begin() (Tx, error)
|
Begin() (Tx, error)
|
||||||
|
@ -756,6 +759,13 @@ func MapStddev(itr Iterator, e *Emitter, tmax int64) {
|
||||||
|
|
||||||
for k, v := itr.Next(); k != 0; k, v = itr.Next() {
|
for k, v := itr.Next(); k != 0; k, v = itr.Next() {
|
||||||
values = append(values, v.(float64))
|
values = append(values, v.(float64))
|
||||||
|
// Emit in batches.
|
||||||
|
// unbounded emission of data can lead to excessive memory use
|
||||||
|
// or other potential performance problems.
|
||||||
|
if len(values) == emitBatchSize {
|
||||||
|
e.Emit(Key{tmax, itr.Tags()}, values)
|
||||||
|
values = []float64{}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if len(values) > 0 {
|
if len(values) > 0 {
|
||||||
e.Emit(Key{tmax, itr.Tags()}, values)
|
e.Emit(Key{tmax, itr.Tags()}, values)
|
||||||
|
|
Loading…
Reference in New Issue