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
10 changes: 9 additions & 1 deletion count/count_min_sketch.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,8 @@ func (c *CountMinSketch) Serialize(w io.Writer) error {
return nil
}

func (c *CountMinSketch) Deserialize(b []byte, seed int64) (*CountMinSketch, error) {
// NewCountMinSketchFromSlice deserializes a Count-Min sketch from a byte slice.
func NewCountMinSketchFromSlice(b []byte, seed int64) (*CountMinSketch, error) {
r := bytes.NewReader(b)
var err error

Expand Down Expand Up @@ -354,3 +355,10 @@ func (c *CountMinSketch) Deserialize(b []byte, seed int64) (*CountMinSketch, err

return cms, nil
}

// Deserialize deserializes a Count-Min sketch from a byte slice.
//
// Deprecated: use NewCountMinSketchFromSlice instead.
func (c *CountMinSketch) Deserialize(b []byte, seed int64) (*CountMinSketch, error) {
return NewCountMinSketchFromSlice(b, seed)
}
4 changes: 2 additions & 2 deletions count/count_min_sketch_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func Test_CountMinSketch(t *testing.T) {
err = c.Serialize(b)
assert.NoError(t, err)

d, err := c.Deserialize(b.Bytes(), seed)
d, err := NewCountMinSketchFromSlice(b.Bytes(), seed)
assert.NoError(t, err)
assert.Equal(t, c, d)
assert.NotEqual(t, &c, d)
Expand All @@ -290,7 +290,7 @@ func Test_CountMinSketch(t *testing.T) {
err = c.Serialize(b)
assert.NoError(t, err)

d, err = c.Deserialize(b.Bytes(), seed)
d, err = NewCountMinSketchFromSlice(b.Bytes(), seed)
assert.NoError(t, err)
assert.Equal(t, c, d)
assert.NotEqual(t, &c, d)
Expand Down
2 changes: 1 addition & 1 deletion examples/count_min_example_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func TestCountMinSketch(t *testing.T) {
err = sketch.Serialize(&buf)
assert.NoError(t, err)

restored, err := sketch.Deserialize(buf.Bytes(), seed)
restored, err := count.NewCountMinSketchFromSlice(buf.Bytes(), seed)
assert.NoError(t, err)
assert.Equal(t, sketch.GetTotalWeight(), restored.GetTotalWeight())
}
Loading