Documentation
¶
Overview ¶
Package problemspans provides functionality for tracking and managing key spans that have been identified as problematic. It allows users to add spans with associated expiration times, check if a given key range overlaps any active (non-expired) spans, and remove spans when issues are resolved.
This package is designed for efficiently tracking key ranges that may need special handling.
Key Attributes:
**Span Registration:** Add spans with specified expiration times so that they automatically become inactive after a set duration.
**Overlap Detection:** Quickly check if a key range overlaps with any active problematic spans.
**Span Excise:** Remove or adjust spans to reflect changes as issues are resolved.
**Level-Based Organization:** The package offers a structure to organize and manage problematic spans per level, with built-in support for concurrent operations.
Index ¶
- type ByLevel
- func (bl *ByLevel) Add(level int, bounds base.UserKeyBounds, expiration time.Duration)
- func (bl *ByLevel) Excise(bounds base.UserKeyBounds)
- func (bl *ByLevel) Init(numLevels int, cmp base.Compare)
- func (bl *ByLevel) InitForTesting(numLevels int, cmp base.Compare, nowFn func() crtime.Mono)
- func (bl *ByLevel) IsEmpty() bool
- func (bl *ByLevel) Len() int
- func (bl *ByLevel) Overlaps(level int, bounds base.UserKeyBounds) bool
- func (bl *ByLevel) String() string
- type Set
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ByLevel ¶
type ByLevel struct {
// contains filtered or unexported fields
}
ByLevel maintains a set of spans (separated by LSM level) with expiration times and allows checking for overlap against active (non-expired) spans.
When the spans added to the set are not overlapping, all operations are logarithmic.
ByLevel is safe for concurrent use.
func (*ByLevel) Add ¶
Add a span on a specific level. The span automatically expires after the given duration.
func (*ByLevel) Excise ¶
func (bl *ByLevel) Excise(bounds base.UserKeyBounds)
Excise a span from all levels. Any overlapping active (non-expired) spans are split or trimmed accordingly.
func (*ByLevel) InitForTesting ¶
InitForTesting is used by tests which mock the time source.
func (*ByLevel) IsEmpty ¶
IsEmpty returns true if there are no problem spans (the "normal" case). It can be used in fast paths to avoid checking for specific overlaps.
func (*ByLevel) Len ¶
Len returns the number of non-overlapping spans that have not expired. Two spans that touch are both counted if they have different expiration times.
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set maintains a set of spans with expiration times and allows checking for overlap against non-expired spans.
When the spans added to the set are not overlapping, all operations are logarithmic.
Set is not safe for concurrent use.
func (*Set) Add ¶
func (s *Set) Add(bounds base.UserKeyBounds, expiration time.Duration)
Add a span to the set. The span automatically expires after the given duration.
func (*Set) Excise ¶
func (s *Set) Excise(bounds base.UserKeyBounds)
Excise removes a span fragment from all spans in the set. Any overlapping non-expired spans are cut accordingly.
func (*Set) Len ¶
Len returns the number of non-overlapping spans that have not expired. Two spans that touch are both counted if they have different expiration times.