problemspans

package
v2.1.3 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2025 License: BSD-3-Clause Imports: 10 Imported by: 0

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

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

func (bl *ByLevel) Add(level int, bounds base.UserKeyBounds, expiration time.Duration)

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) Init

func (bl *ByLevel) Init(numLevels int, cmp base.Compare)

Init must be called before using the ByLevel.

func (*ByLevel) InitForTesting

func (bl *ByLevel) InitForTesting(numLevels int, cmp base.Compare, nowFn func() crtime.Mono)

InitForTesting is used by tests which mock the time source.

func (*ByLevel) IsEmpty

func (bl *ByLevel) IsEmpty() bool

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

func (bl *ByLevel) Len() int

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.

func (*ByLevel) Overlaps

func (bl *ByLevel) Overlaps(level int, bounds base.UserKeyBounds) bool

Overlaps returns true if any active (non-expired) span on the given level overlaps the given bounds.

func (*ByLevel) String

func (bl *ByLevel) String() string

String prints all active (non-expired) span fragments.

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) Init

func (s *Set) Init(cmp base.Compare)

Init must be called before a Set can be used.

func (*Set) IsEmpty

func (s *Set) IsEmpty() bool

IsEmpty returns true if the set contains no non-expired spans.

func (*Set) Len

func (s *Set) Len() int

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.

func (*Set) Overlaps

func (s *Set) Overlaps(bounds base.UserKeyBounds) bool

Overlaps returns true if the bounds overlap with a non-expired span.

func (*Set) String

func (s *Set) String() string

String prints all active (non-expired) span fragments.

Jump to

Keyboard shortcuts

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