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

Function defaultAccessorValue

pkg/filter/accessor.go:261–282  ·  view source on GitHub ↗

defaultAccessorValue provides the default value for the field. This value is typically assigned when the accessor returns an error or nil value, but the map valuer must contain the resolved field name in case of filters using the not operator.

(field Field)

Source from the content-addressed store, hash-verified

259// error or nil value, but the map valuer must contain the resolved
260// field name in case of filters using the not operator.
261func defaultAccessorValue(field Field) any {
262 switch field.Name.Type() {
263 case params.Uint8, params.Int64, params.Int8, params.Int32, params.Int16,
264 params.Uint16, params.Port, params.Uint32, params.Uint64, params.PID,
265 params.TID, params.Flags, params.Flags64:
266 return 0
267 case params.Float, params.Double:
268 return 0.0
269 case params.Time:
270 return zeroTime
271 case params.Bool:
272 return false
273 case params.IP, params.IPv4, params.IPv6:
274 return zeroIP
275 case params.Binary:
276 return zeroByte
277 case params.Slice:
278 return zeroSlice
279 default:
280 return ""
281 }
282}

Callers 2

evalBoundSequenceMethod · 0.85
mapValuerMethod · 0.85

Calls 1

TypeMethod · 0.65

Tested by

no test coverage detected