Skip to content

Commit 2c44011

Browse files
authored
Merge pull request #124 from proost/fix-varopt-items-sketch-update
fix: VarOptItemsSketch update
2 parents 9ffd023 + b11a98e commit 2c44011

4 files changed

Lines changed: 565 additions & 334 deletions

File tree

sampling/reservoir_items_sketch.go

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,7 @@ import (
3030
"github.com/apache/datasketches-go/internal"
3131
)
3232

33-
// ResizeFactor controls how the internal array grows.
34-
// Note: Go's slice append has automatic resizing, so this is kept for
35-
// API compatibility with the Java version. Can be removed if not needed.
36-
// TODO: In Java, this is abstracted into a common package. Consider if this should be moved to a common package in the future.
37-
type ResizeFactor int
38-
3933
const (
40-
ResizeX1 ResizeFactor = 1
41-
ResizeX2 ResizeFactor = 2
42-
ResizeX4 ResizeFactor = 4
43-
ResizeX8 ResizeFactor = 8
44-
4534
defaultResizeFactor = ResizeX8
4635
minK = 2
4736

@@ -95,7 +84,7 @@ func NewReservoirItemsSketch[T any](
9584

9685
ceilingLgK, _ := internal.ExactLog2(common.CeilingPowerOf2(k))
9786
initialLgSize := startingSubMultiple(
98-
ceilingLgK, int(math.Log2(float64(options.resizeFactor))), minLgArrItems,
87+
ceilingLgK, int(float64(options.resizeFactor)), minLgArrItems,
9988
)
10089
return &ReservoirItemsSketch[T]{
10190
k: k,

sampling/sampling.go

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package sampling
19+
20+
// ResizeFactor controls how the internal array grows.
21+
// Note: Go's slice append has automatic resizing, so this is kept for
22+
// API compatibility with the Java version. Can be removed if not needed.
23+
// TODO: In Java, this is abstracted into a common package. Consider if this should be moved to a common package in the future.
24+
type ResizeFactor int
25+
26+
const (
27+
ResizeX1 ResizeFactor = 0
28+
ResizeX2 ResizeFactor = 1
29+
ResizeX4 ResizeFactor = 2
30+
ResizeX8 ResizeFactor = 3
31+
)

0 commit comments

Comments
 (0)