MCPcopy Create free account
hub / github.com/rabbitstack/fibratus / evalSequence

Method evalSequence

pkg/filter/filter.go:343–381  ·  view source on GitHub ↗

evalSequence evaluates the sequence with one, multiple or no join links. The sequence link is first consulted for the global sequence definition, and if it is not defined then the expression sequence link is used.

(
	e *event.Event,
	seqID int,
	expr *ql.SequenceExpr,
	partials map[int][]*event.Event,
	valuer ql.MapValuer,
)

Source from the content-addressed store, hash-verified

341// global sequence definition, and if it is not defined then
342// the expression sequence link is used.
343func (f *filter) evalSequence(
344 e *event.Event,
345 seqID int,
346 expr *ql.SequenceExpr,
347 partials map[int][]*event.Event,
348 valuer ql.MapValuer,
349) bool {
350 // top-level sequence link is defined
351 by := f.seq.By
352 if by == nil {
353 // otherwise, use the expression link
354 by = expr.By
355 }
356
357 var match bool
358 if seqID >= 1 && by != nil {
359 linkID := makeSequenceLinkID(valuer, by)
360 // traverse upstream partials for join equality
361 joins := make([]bool, seqID)
362 outer:
363 for i := range seqID {
364 for _, p := range partials[i] {
365 if CompareSeqLink(linkID, p.SequenceLinks()) {
366 joins[i] = true
367 continue outer
368 }
369 }
370 }
371 match = joinsEqual(joins) && ql.Eval(expr.Expr, valuer, f.hasFunctions)
372 } else {
373 match = ql.Eval(expr.Expr, valuer, f.hasFunctions)
374 }
375
376 if match && by != nil {
377 e.AddSequenceLink(makeSequenceLinkID(valuer, by))
378 }
379
380 return match
381}
382
383func (f *filter) RunSequence(e *event.Event, seqID int, partials map[int][]*event.Event, rawMatch bool) bool {
384 if f.seq == nil {

Callers 1

RunSequenceMethod · 0.95

Calls 6

EvalFunction · 0.92
makeSequenceLinkIDFunction · 0.85
CompareSeqLinkFunction · 0.85
joinsEqualFunction · 0.85
SequenceLinksMethod · 0.80
AddSequenceLinkMethod · 0.80

Tested by

no test coverage detected