Skip to content
Merged
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
13 changes: 1 addition & 12 deletions sampling/reservoir_items_sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,7 @@ import (
"github.com/apache/datasketches-go/internal"
)

// ResizeFactor controls how the internal array grows.
// Note: Go's slice append has automatic resizing, so this is kept for
// API compatibility with the Java version. Can be removed if not needed.
// TODO: In Java, this is abstracted into a common package. Consider if this should be moved to a common package in the future.
type ResizeFactor int

const (
ResizeX1 ResizeFactor = 1
ResizeX2 ResizeFactor = 2
ResizeX4 ResizeFactor = 4
ResizeX8 ResizeFactor = 8

defaultResizeFactor = ResizeX8
minK = 2

Expand Down Expand Up @@ -95,7 +84,7 @@ func NewReservoirItemsSketch[T any](

ceilingLgK, _ := internal.ExactLog2(common.CeilingPowerOf2(k))
initialLgSize := startingSubMultiple(
ceilingLgK, int(math.Log2(float64(options.resizeFactor))), minLgArrItems,
ceilingLgK, int(float64(options.resizeFactor)), minLgArrItems,
)
return &ReservoirItemsSketch[T]{
k: k,
Expand Down
31 changes: 31 additions & 0 deletions sampling/sampling.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package sampling

// ResizeFactor controls how the internal array grows.
// Note: Go's slice append has automatic resizing, so this is kept for
// API compatibility with the Java version. Can be removed if not needed.
// TODO: In Java, this is abstracted into a common package. Consider if this should be moved to a common package in the future.
type ResizeFactor int

const (
ResizeX1 ResizeFactor = 0
ResizeX2 ResizeFactor = 1
ResizeX4 ResizeFactor = 2
ResizeX8 ResizeFactor = 3
)
Loading
Loading