Skip to content

Commit 97bb825

Browse files
authored
Merge pull request #141 from proost/fix-grow-to-cap
fix: grow cap
2 parents f152ab7 + 2ee7f96 commit 97bb825

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

sampling/reservoir_items_sketch.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ func (s *ReservoirItemsSketch[T]) Update(item T) error {
132132

133133
func (s *ReservoirItemsSketch[T]) growReservoir() {
134134
adjustedSize := adjustedSamplingAllocationSize(s.k, cap(s.data)<<int(s.rf))
135-
s.data = slices.Grow(s.data, adjustedSize-cap(s.data))
135+
s.data = slices.Grow(s.data, adjustedSize)
136136
}
137137

138138
// K returns the maximum reservoir capacity.
@@ -483,7 +483,7 @@ func NewReservoirItemsSketchFromSlice[T any](data []byte, serde ItemsSerDe[T]) (
483483
return nil, err
484484
}
485485

486-
sketch.data = slices.Grow(sketch.data, capacity-cap(sketch.data))
486+
sketch.data = slices.Grow(sketch.data, capacity)
487487

488488
return &ReservoirItemsSketch[T]{
489489
k: k,

0 commit comments

Comments
 (0)