Skip to content

Commit d4df942

Browse files
committed
Comments editing
1 parent a735ac5 commit d4df942

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

pruner/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@
1212
// currently) during mutations. The code also supports pluggable
1313
// rebuilding policies, but those features are not currently exposed.
1414
// A Rebuild method is available for the application to force a
15-
// rebuild.
15+
// rebuild, and DisableRebuild() prevents any automatic rebuilding.
1616
package pruner

pruner/pruner.go

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -151,15 +151,15 @@ func (m *Matcher) DisableRebuild() {
151151
//
152152
// Currently an AddPattern, DeletePattern, or MatchesForFields can
153153
// trigger a rebuild. When a rebuild is triggered, it's executed
154-
// synchronous, the the Add/Delete method doesn't return until the
155-
// rebuild is complete.
154+
// synchronously: the the Add/Delete/Match method doesn't return until
155+
// the rebuild is complete.
156156
type rebuildTrigger interface {
157157
// Rebuild should return true to trigger a rebuild.
158158
//
159-
// This method is called by AddPattern and DeletePattern.
160-
// added is true when called by AddPattern; false
161-
// otherwise. These methods do not return until the rebuild is
162-
// complete, so beware.
159+
// This method is called by AddPatter,DeletePattern, and
160+
// MatchesForFields. added is true when called by AddPattern;
161+
// false otherwise. These methods currently do not return
162+
// until the rebuild is complete, so beware.
163163
Rebuild(added bool, s *Stats) bool
164164
}
165165

@@ -178,9 +178,9 @@ func NewMatcher(s LivePatternsState) *Matcher {
178178
}
179179
}
180180

181-
// maybeRebuild calls rebuildTrigger (if not) and then calls rebuild()
182-
// if that trigger said to do that. If rebuildTrigger is nil, no
183-
// rebuild is executed.
181+
// maybeRebuild calls rebuildTrigger and calls rebuild() if that
182+
// trigger said to do that. If rebuildTrigger is nil, no rebuild is
183+
// executed.
184184
//
185185
// This method assumes the caller has a write lock.
186186
func (m *Matcher) maybeRebuild(added bool) error {
@@ -194,8 +194,9 @@ func (m *Matcher) maybeRebuild(added bool) error {
194194
return nil
195195
}
196196

197-
// AddPattern calls the underlying AddPattern method and then maybe
198-
// rebuilds the index (if the AddPattern succeeded).
197+
// AddPattern calls the underlying quamina.CoreMatcher.AddPattern
198+
// method and then maybe rebuilds the index (if the AddPattern
199+
// succeeded).
199200
func (m *Matcher) AddPattern(x quamina.X, pat string) error {
200201
var err error
201202

@@ -216,17 +217,20 @@ func (m *Matcher) AddPattern(x quamina.X, pat string) error {
216217
}
217218

218219
// NewFJ just calls quamina.FJ.
220+
//
221+
// Here for convenience only.
219222
func NewFJ(m *Matcher) quamina.Flattener {
220223
return quamina.NewFJ(m.Matcher)
221224
}
222225

223226
// NewFJ calls quamina.NewFJ with this Matcher's core quamina.Matcher
227+
//
228+
// Here for convenience only.
224229
func (m *Matcher) NewFJ() quamina.Flattener {
225230
return quamina.NewFJ(m.Matcher)
226231
}
227232

228-
// MatchesForJSONEvent calls the underlying MatchesForJSONEvent method
229-
// and then maybe rebuilds the index.
233+
// MatchesForJSONEvent calls MatchesForFields with a new Flattener.
230234
func (m *Matcher) MatchesForJSONEvent(event []byte) ([]quamina.X, error) {
231235
fs, err := m.NewFJ().Flatten(event)
232236
if err != nil {
@@ -235,6 +239,9 @@ func (m *Matcher) MatchesForJSONEvent(event []byte) ([]quamina.X, error) {
235239
return m.MatchesForFields(fs)
236240
}
237241

242+
// MatchesForFields calls the underlying
243+
// quamina.CoreMatcher.MatchesForFields and then maybe rebuilds the
244+
// index.
238245
func (m *Matcher) MatchesForFields(fields []quamina.Field) ([]quamina.X, error) {
239246

240247
xs, err := m.Matcher.MatchesForFields(fields)
@@ -246,9 +253,6 @@ func (m *Matcher) MatchesForFields(fields []quamina.Field) ([]quamina.X, error)
246253

247254
acc := make([]quamina.X, 0, len(xs))
248255

249-
// We're updating stats.Filtered, so we need a write lock. If
250-
// we forget about stats.Filtered, we can live with only a
251-
// read lock here.
252256
var emitted, filtered int64
253257
for _, x := range xs {
254258
have, err := m.live.Contains(x)
@@ -272,16 +276,9 @@ func (m *Matcher) MatchesForFields(fields []quamina.Field) ([]quamina.X, error)
272276
return acc, nil
273277
}
274278

275-
// DeletePattern "removes" the pattern from the index and maybe
276-
// rebuilds the index.
277-
//
278-
// The return boolean when true indicates that at least one pattern
279-
// for x was removed.
279+
// DeletePattern removes the pattern from the index and maybe rebuilds
280+
// the index.
280281
func (m *Matcher) DeletePattern(x quamina.X) error {
281-
// Maybe better to return (int,error) as in
282-
// LivePatternStats.Delete(), or maybe just return an error
283-
// and nothing else.
284-
285282
n, err := m.live.Delete(x)
286283
if err == nil {
287284
if 0 < n {

pruner/state.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type LivePatternsState interface {
1616
// X.
1717
Add(x quamina.X, pattern string) error
1818

19-
// Delete removes all patterns associated with the given x and
19+
// Delete removes all patterns associated with the given X and
2020
// returns the number of removed patterns.
2121
Delete(x quamina.X) (int, error)
2222

@@ -25,9 +25,6 @@ type LivePatternsState interface {
2525

2626
// Contains returns true if x is in the live set; false
2727
// otherwise.
28-
//
29-
// Since a pattern can't be the empty string, that zero value
30-
// indicates no corresponding pattern.
3128
Contains(x quamina.X) (bool, error)
3229
}
3330

0 commit comments

Comments
 (0)