Skip to content

Commit

Permalink
Add a note about DistinctString collector's Collect return bool
Browse files Browse the repository at this point in the history
  • Loading branch information
electron0zero committed Sep 25, 2024
1 parent 312131c commit cc1c350
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pkg/collector/distinct_string_collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,13 @@ func NewDistinctStringWithDiff(maxDataSize int) *DistinctString {
}
}

// FIXME: also add a benchmark for this to show it goes faster without diff support

// Collect adds a new value to the distinct string collector.
// return indicates if the value was added or not.
// FIXME: return an exceeded flag to stop early
// returns a bool to indicate if the value was added or not.
// you need to call Exceeded to check if the limit was reached
//
// Note: Collect doesn't return exceeded bool like other collectors,
// changing it to be consistent with other collectors requires changes in Searcher interface.
// callbacks because Collect is used in Searcher interface callbacks.
func (d *DistinctString) Collect(s string) bool {
d.mtx.Lock()
defer d.mtx.Unlock()
Expand Down

0 comments on commit cc1c350

Please sign in to comment.