Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
bbloom
Commits
35ef51b7
Commit
35ef51b7
authored
Aug 23, 2019
by
Steven Allen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
api: cleanup docs/api
parent
ff794fa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
7 deletions
+9
-7
bbloom.go
bbloom.go
+9
-7
No files found.
bbloom.go
View file @
35ef51b7
...
...
@@ -112,6 +112,7 @@ type Bloom struct {
content
uint64
}
// ElementsAdded returns the number of elements added to the bloom filter.
func
(
bl
*
Bloom
)
ElementsAdded
()
uint64
{
return
bl
.
content
}
...
...
@@ -206,16 +207,19 @@ func (bl *Bloom) AddIfNotHasTS(entry []byte) (added bool) {
// Clear
// resets the Bloom filter
func
(
bl
*
Bloom
)
Clear
()
{
bl
.
Mtx
.
Lock
()
defer
bl
.
Mtx
.
Unlock
()
for
i
,
_
:=
range
(
*
bl
)
.
bitset
{
bl
.
bitset
[
i
]
=
0
}
bl
.
content
=
0
}
// Set
// set the bit[idx] of bitsit
// ClearTS clears the bloom filter (thread safe).
func
(
bl
*
Bloom
)
ClearTS
()
{
bl
.
Mtx
.
Lock
()
defer
bl
.
Mtx
.
Unlock
()
bl
.
Clear
()
}
func
(
bl
*
Bloom
)
set
(
idx
uint64
)
{
bl
.
bitset
[
idx
>>
6
]
|=
1
<<
(
idx
%
64
)
}
...
...
@@ -227,9 +231,6 @@ func (bl *Bloom) getSet(idx uint64) bool {
return
(
cur
&
bit
)
>
0
}
// IsSet
// check if bit[idx] of bitset is set
// returns true/false
func
(
bl
*
Bloom
)
isSet
(
idx
uint64
)
bool
{
return
bl
.
bitset
[
idx
>>
6
]
&
(
1
<<
(
idx
%
64
))
>
0
}
...
...
@@ -261,6 +262,7 @@ func JSONUnmarshal(dbData []byte) *Bloom {
return
bf
}
// FillRatio returns the fraction of bits set.
func
(
bl
*
Bloom
)
FillRatio
()
float64
{
count
:=
uint64
(
0
)
for
_
,
b
:=
range
bl
.
bitset
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment