-
Notifications
You must be signed in to change notification settings - Fork 12
/
examples_test.go
70 lines (55 loc) · 1.19 KB
/
examples_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// Copyright (c) 2015, RetailNext, Inc.
// This material contains trade secrets and confidential information of
// RetailNext, Inc. Any use, reproduction, disclosure or dissemination
// is strictly prohibited without the explicit written permission
// of RetailNext, Inc.
// All rights reserved.
package hllpp
import "fmt"
func Example() {
h := New()
h.Add([]byte("barclay"))
h.Add([]byte("reginald"))
h.Add([]byte("barclay"))
h.Add([]byte("broccoli"))
fmt.Println(h.Count())
// Output: 3
}
func ExampleNewWithConfig() {
h, err := NewWithConfig(Config{
Precision: 12,
SparsePrecision: 14,
})
if err != nil {
panic(err)
}
h.Add([]byte("qapla'"))
h.Add([]byte("qapla'"))
fmt.Println(h.Count())
// Output: 1
}
func ExampleHLLPP_Marshal() {
h := New()
h.Add([]byte("hobbledehoyhood"))
serialized := h.Marshal()
h, err := Unmarshal(serialized)
if err != nil {
panic(err)
}
fmt.Println(h.Count())
// Output: 1
}
func ExampleHLLPP_Merge() {
h := New()
h.Add([]byte("picard"))
h.Add([]byte("janeway"))
other := New()
other.Add([]byte("picard"))
other.Add([]byte("kirk"))
err := h.Merge(other)
if err != nil {
panic(err)
}
fmt.Println(h.Count())
// Output: 3
}