hashmap

package
v4.1.14 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 11, 2025 License: GPL-2.0, BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package hashmap implemets a modified version of Go's map type using type parameters. See https://github.com/golang/go/blob/master/src/runtime/map.go

Index

Constants

This section is empty.

Variables

View Source
var NilAggFlowMapWithMetadata = AggFlowMapWithMetadata{}

NilAggFlowMapWithMetadata denotes an empty / "nil" AggFlowMapWithMetadata

Functions

This section is empty.

Types

type AggFlowMap

type AggFlowMap struct {
	PrimaryMap   *Map
	SecondaryMap *Map
}

AggFlowMap stores all flows where the source port from the FlowLog has been aggregated Just a convenient alias for the map type itself

func NewAggFlowMap

func NewAggFlowMap(n ...int) *AggFlowMap

NewAggFlowMap instantiates a new NewAggFlowMap with an underlying hashmap for both IPv4 and IPv6 entries

func (AggFlowMap) Clear

func (a AggFlowMap) Clear()

Clear frees as many resources as possible by making them eligible for GC

func (AggFlowMap) ClearFast

func (a AggFlowMap) ClearFast()

ClearFast nils all main resources, making them eligible for GC (but probably not as effectively as Clear())

func (*AggFlowMap) Flatten

func (a *AggFlowMap) Flatten() (primaryList List, secondaryList List)

Flatten converts a flow map to a flat table / list

func (AggFlowMap) IsNil

func (a AggFlowMap) IsNil() bool

IsNil returns if an AggFlowMap is nil (used e.g. in cases of error)

func (AggFlowMap) Iter

func (a AggFlowMap) Iter(opts ...MetaIterOption) *MetaIter

Iter provides a map Iter to allow traversal of both underlying maps (IPv4 and IPv6)

func (AggFlowMap) Len

func (a AggFlowMap) Len() int

Len returns the number of valents in the map

func (AggFlowMap) Merge

func (a AggFlowMap) Merge(b AggFlowMap)

Merge allows to incorporate the content of a map b into an existing map a

func (AggFlowMap) SetOrUpdate

func (a AggFlowMap) SetOrUpdate(key Key, isIPv4 bool, eA, eB, eC, eD uint64)

SetOrUpdate either creates a new entry based on the provided values or updates any existing valent (if exists). This way may be very specific, but it avoids intermediate allocation of a value type valent in case of an update

type AggFlowMapWithMetadata

type AggFlowMapWithMetadata struct {
	*AggFlowMap

	Interface string `json:"iface"`

	Stats *workload.Stats
}

AggFlowMapWithMetadata provides a wrapper around the map with ancillary data

func NewAggFlowMapWithMetadata

func NewAggFlowMapWithMetadata(n ...int) AggFlowMapWithMetadata

NewAggFlowMapWithMetadata instantiates a new AggFlowMapWithMetadata with an underlying hashmap for both IPv4 and IPv6 entries

func (AggFlowMapWithMetadata) IsNil

func (a AggFlowMapWithMetadata) IsNil() bool

IsNil returns if an AggFlowMapWithMetadata is nil (used e.g. in cases of error)

func (AggFlowMapWithMetadata) Merge

Merge allows to incorporate the content of a map b into an existing map a

type Item

type Item struct {
	types.Key
	Val
}

Item denotes a flat key / value pair

type Iter

type Iter struct {
	// contains filtered or unexported fields
}

Iter provides a map Iter to allow traversal

func (*Iter) Key

func (it *Iter) Key() Key

Key returns the key at the current iterator position

func (*Iter) Next

func (it *Iter) Next() bool

Next updates the iterator to the next element (returning false if none exists)

func (*Iter) Val

func (it *Iter) Val() Val

Val returns the value / valent at the current iterator position

type Key

type Key = []byte

Key defines the Key type of the map

type KeyVal

type KeyVal struct {
	Key Key
	Val Val
}

KeyVal denotes a key / value pair

type KeyVals

type KeyVals []KeyVal

KeyVals denotes a list / slice of key / value pairs

type List

type List []Item

List denotes a list of key / value pairs

func (List) Sort

func (l List) Sort() List

Sort orders relevant flow columns so that they become more compressible

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map denotes the main type of the hashmap implementation

func New

func New(n ...int) *Map

New instantiates a new Map (a size hint can be provided)

func NewHint

func NewHint(hint int) *Map

NewHint instantiates a new Map with a hint as to how many valents will be inserted.

func (*Map) Clear

func (m *Map) Clear()

Clear frees as many resources as possible by making them eligible for GC

func (*Map) ClearFast

func (m *Map) ClearFast()

ClearFast nils all main resources, making them eligible for GC (but probably not as effectively as Clear())

func (*Map) Get

func (m *Map) Get(key Key) (Val, bool)

Get returns the valent associated with key and true if that key exists

func (*Map) Iter

func (m *Map) Iter() *Iter

Iter instantiates an Iter to traverse the map.

func (*Map) Len

func (m *Map) Len() int

Len returns the number of valents in the map

func (*Map) Merge

func (m *Map) Merge(m2 *Map)

Merge allows to incorporate the content of a map m2 into an existing map m (providing additional in-place counter updates). It re-uses / duplicates code from the iterator part to minimize function call overhead and allocations

func (*Map) Set

func (m *Map) Set(key Key, val Val)

Set either creates a new entry based on the provided values or updates any existing valent (if exists).

func (*Map) SetOrUpdate

func (m *Map) SetOrUpdate(key Key, eA, eB, eC, eD uint64)

SetOrUpdate either creates a new entry based on the provided values or updates any existing valent (if exists). This way may be very specific, but it avoids intermediate allocation of a value type valent in case of an update

type MetaIter

type MetaIter struct {
	*Iter // primary iterator
	// contains filtered or unexported fields
}

MetaIter denotes a wrapper around an primary & secondary hashmap construct, allowing easy access to a global iterator running through both sub-maps

func (*MetaIter) Next

func (i *MetaIter) Next() (ok bool)

Next updates the iterator to the next element (returning false if none exists)

type MetaIterOption

type MetaIterOption func(it *MetaIter)

MetaIterOption denotes a functional option to a MetaIter

func WithFilter

func WithFilter(filter ValFilter) MetaIterOption

WithFilter sets a filter for the MetaIter

type NamedAggFlowMapWithMetadata

type NamedAggFlowMapWithMetadata map[string]*AggFlowMapWithMetadata

NamedAggFlowMapWithMetadata provides wrapper around a map of AggFlowMapWithMetadata instances (e.g. interface -> AggFlowMapWithMetadata associations)

func NewNamedAggFlowMapWithMetadata

func NewNamedAggFlowMapWithMetadata(names []string) (m NamedAggFlowMapWithMetadata)

NewNamedAggFlowMapWithMetadata instantiates a new NewNamedAggFlowMapWithMetadata based on a list of names, initializing an instance of AggFlowMapWithMetadata per element

func (NamedAggFlowMapWithMetadata) Clear

func (n NamedAggFlowMapWithMetadata) Clear()

Clear frees as many resources as possible by making them eligible for GC

func (NamedAggFlowMapWithMetadata) ClearFast

func (n NamedAggFlowMapWithMetadata) ClearFast()

ClearFast nils all main resources, making them eligible for GC (but probably not as effectively as Clear())

func (NamedAggFlowMapWithMetadata) Len

func (n NamedAggFlowMapWithMetadata) Len() (l int)

Len returns the number of entries in all maps

type Val

type Val = types.Counters

Val defines the value / valent type of the map

type ValFilter

type ValFilter func(Val) bool

ValFilter denotes a generic value filter (returning true if a certain filter condition is met)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL