-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
receive/multitsdb: add cuckoo filter on metric names
Signed-off-by: Mindaugas Niaura <mindaugas.niaura@vinted.com>
- Loading branch information
Showing
18 changed files
with
190 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package filter | ||
|
||
import ( | ||
"sync" | ||
|
||
cuckoo "github.com/seiflotfy/cuckoofilter" | ||
) | ||
|
||
type CuckooFilterMetricNameFilter struct { | ||
filter *cuckoo.Filter | ||
mtx sync.RWMutex | ||
} | ||
|
||
func NewCuckooFilterMetricNameFilter(capacity uint) *CuckooFilterMetricNameFilter { | ||
return &CuckooFilterMetricNameFilter{ | ||
filter: cuckoo.NewFilter(capacity), | ||
} | ||
} | ||
|
||
func (f *CuckooFilterMetricNameFilter) MatchesMetricName(metricName string) bool { | ||
f.mtx.RLock() | ||
defer f.mtx.RUnlock() | ||
return f.filter.Lookup([]byte(metricName)) | ||
} | ||
|
||
func (f *CuckooFilterMetricNameFilter) ResetAddMetricName(metricNames ...string) { | ||
f.mtx.Lock() | ||
defer f.mtx.Unlock() | ||
f.filter.Reset() | ||
for _, metricName := range metricNames { | ||
f.filter.Insert([]byte(metricName)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package filter | ||
|
||
type MetricNameFilter interface { | ||
MatchesMetricName(metricName string) bool | ||
ResetAddMetricName(metricNames ...string) | ||
} | ||
|
||
type AllowAllMetricNameFilter struct{} | ||
|
||
func (f AllowAllMetricNameFilter) MatchesMetricName(metricName string) bool { | ||
return true | ||
} | ||
|
||
func (f AllowAllMetricNameFilter) ResetAddMetricName(metricNames ...string) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.