mapValuer for each field present in the AST, we run the accessors and extract the field values that are supplied to the valuer. The valuer feeds the expression with correct values.
(evt *event.Event)
| 493 | // supplied to the valuer. The valuer feeds the |
| 494 | // expression with correct values. |
| 495 | func (f *filter) mapValuer(evt *event.Event) map[string]any { |
| 496 | valuer := valuerPool.Get().(map[string]any) |
| 497 | for _, field := range f.fields { |
| 498 | for _, accessor := range f.accessors { |
| 499 | if !accessor.IsFieldAccessible(evt) { |
| 500 | continue |
| 501 | } |
| 502 | v, err := accessor.Get(field, evt) |
| 503 | if v == nil || err != nil { |
| 504 | if v == nil { |
| 505 | valuer[field.String()] = defaultAccessorValue(field) |
| 506 | } |
| 507 | if err != nil && !errs.IsParamNotFound(err) { |
| 508 | valuer[field.String()] = defaultAccessorValue(field) |
| 509 | accessorErrors.Add(err.Error(), 1) |
| 510 | } |
| 511 | continue |
| 512 | } |
| 513 | valuer[field.String()] = v |
| 514 | break |
| 515 | } |
| 516 | } |
| 517 | return valuer |
| 518 | } |
| 519 | |
| 520 | // addField appends a new field to the filter fields list. |
| 521 | func (f *filter) addField(field *ql.FieldLiteral) { |
no test coverage detected