priority

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package priority creates a subordinate-superiors map of identifications. These maps can be flattened into sorted lists for use by the bytematcher and containermatcher engines. Multiple priority lists can be added to priority sets. These contain the priorities of different identifiers within a bytematcher or containermatcher.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Filterable

type Filterable interface {
	Next() int
	Mark(bool)
}

type List

type List [][]int

func (List) String

func (l List) String() string

func (List) Subset

func (l List) Subset(indexes []int, prev int) List

take a list of indexes, subtract the length of the previous priority list in a set (or 0) to get relative indexes, then map those against a priority list. Re-number according to indexes and return the common subset.

type Map

type Map map[string][]string

a priority map links subordinate results to a list of priority results

func (Map) Add

func (m Map) Add(subordinate string, superior string)

add a subordinate-superior relationship to the priority map

func (Map) Apply added in v1.10.0

func (m Map) Apply(hits []string) []string

Apply checks a list of hits against a priority map and returns a subset of that list for any hits that don't have superiors also in that list

func (Map) Complete

func (m Map) Complete()

After adding all priorities, walk the priority map to make sure that it is consistent, i.e. that for any format with a superior fmt, then anything superior to that superior fmt is also marked as superior to the base fmt, all the way down the tree

func (Map) Difference

func (m Map) Difference(mb Map) Map

func (Map) Elements

func (m Map) Elements() [][2]string

func (Map) Filter

func (m Map) Filter(fmts []string) Map

Filter returns a new Priority Map that just contains formats in the provided slice

func (Map) List

func (m Map) List(keys []string) List

return a priority list using the indexes from the supplied slice of keys (keys can be duplicated in that slice)

type Set

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

A priority set holds a number of priority lists

func Load

func Load(ls *persist.LoadSaver) *Set

func (*Set) Add

func (s *Set) Add(l List, length, bof, eof int)

Add a priority list to a set. The length is the number of signatures the priority list applies to, not the length of the priority list. This length will only differ when no priorities are set for a given set of signatures.

func (*Set) Index

func (s *Set) Index(i int) (int, int)

Index return the index of the s.lists for the wait list, and return the previous tally previous tally is necessary for adding to the values in the priority list to give real priorities

func (*Set) Save

func (s *Set) Save(ls *persist.LoadSaver)

func (*Set) WaitSet

func (s *Set) WaitSet(hints ...core.Hint) *WaitSet

WaitSet creates a new WaitSet given a list of hints

type WaitSet

type WaitSet struct {
	*Set
	// contains filtered or unexported fields
}

A wait set is a mutating structure that holds the set of indexes that should be waited for while matching underway

func (*WaitSet) ApplyFilter

func (w *WaitSet) ApplyFilter(f Filterable)

func (*WaitSet) Check

func (w *WaitSet) Check(i int) bool

Check a signature index against the appropriate priority list. Should we continue trying to match this signature?

func (*WaitSet) Filter

func (w *WaitSet) Filter(l []int) []int

Filter a waitset with a list of potential matches, return only those that we are still waiting on. Return nil if none.

func (*WaitSet) MaxOffsets

func (w *WaitSet) MaxOffsets() (int, int)

MaxOffsets returns max/min offset info in order to override the max/min offsets set on the bytematcher when any identifiers have been excluded.

func (*WaitSet) Put

func (w *WaitSet) Put(i int) bool

Set the priority list & return a boolean indicating whether the WaitSet is satisfied such that matching can stop (i.e. no priority list is nil, and all are empty)

func (*WaitSet) PutAt

func (w *WaitSet) PutAt(i int, bof, eof int64) bool

Set the priority list & return a boolean indicating whether the WaitSet is satisfied such that matching can stop (i.e. no priority list is nil, and all are empty)

func (*WaitSet) WaitingOn

func (w *WaitSet) WaitingOn() []int

For periodic checking - what signatures are we currently waiting on? Accumulates values from all the priority lists within the set. Returns nil if *any* of the priority lists is nil.

Jump to

Keyboard shortcuts

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