scout_apm v1.0.7 ScoutApm.ScoredItemSet

A capped set type that has a few rules on inclusion.

When you add an item, it must be a tuple of shape: {{:score, integer, key}, item}

Where the key uniquely identifies the item, as a string. The score is a unitless relative "value" of this item, and then the item itself can be any structure

Only the highest score of each key is kept, no duplicates, even if the set has "room" for it.

Only the highest scores will be kept when at capacity. Adding a new element may or may result in the new item evicting an old one, or being simply dropped, based on the comparison of the scores.

Link to this section Summary

Link to this section Types

Link to this type

key()

key() :: String.t()
Link to this type

options()

options() :: %{max_count: pos_integer()}
Link to this type

score()

score() :: {:score, number(), key()}
Link to this type

scored_item()

scored_item() :: {score(), any()}
Link to this type

t()

t() :: %ScoutApm.ScoredItemSet{
  data: %{required(any()) => scored_item()},
  options: options()
}

Link to this section Functions

Link to this function

absorb(set, scored_item)

absorb(t(), scored_item()) :: t()
Link to this function

new()

new() :: t()
Link to this function

set_max_count(set, max_count)

set_max_count(t(), pos_integer()) :: t()
Link to this function

to_list(set)

to_list(t()) :: [scored_item()]
Link to this function

to_list(set, atom)

to_list(t(), :without_scores) :: [scored_item()]