Documentation
¶
Overview ¶
Package interval provides revision-bound persistent interval sets. Sets are immutable: every mutation returns a new root while older roots remain safe for concurrent readers.
Index ¶
- Constants
- Variables
- type Entry
- type Options
- type QueryOptions
- type Result
- type Set
- func (s *Set[T]) All(ctx context.Context, options QueryOptions) (Result[T], error)
- func (s *Set[T]) At(ctx context.Context, offset int64, options QueryOptions) (Result[T], error)
- func (s *Set[T]) Get(id string) (Entry[T], bool)
- func (s *Set[T]) Intersect(ctx context.Context, start, end int64, options QueryOptions) (Result[T], error)
- func (s *Set[T]) Len() int64
- func (s *Set[T]) Put(entry Entry[T]) (*Set[T], error)
- func (s *Set[T]) PutAll(ctx context.Context, entries []Entry[T]) (*Set[T], error)
- func (s *Set[T]) Remove(id string) (*Set[T], bool, error)
- func (s *Set[T]) RemoveAll(ctx context.Context, ids []string) (*Set[T], bool, error)
- func (s *Set[T]) Revision() uint64
- func (s *Set[T]) Stats() Stats
- func (s *Set[T]) Transform(ctx context.Context, changes coordinate.ChangeMap) (*Set[T], error)
- type Stats
Constants ¶
View Source
const ( DefaultMaxEntries = 1_048_576 MaximumEntries = 16_777_216 DefaultMaxIDBytes = 4 << 10 MaximumIDBytes = 1 << 20 DefaultMaxResults = 100_000 MaximumResults = 1_000_000 )
Variables ¶
View Source
var ( ErrInvalidContext = errors.New("interval: nil context") ErrInvalidOptions = errors.New("interval: invalid options") ErrInvalidSet = errors.New("interval: invalid set") ErrInvalidEntry = errors.New("interval: invalid entry") ErrInvalidRange = errors.New("interval: invalid range") ErrRevisionMismatch = errors.New("interval: revision mismatch") ErrLengthMismatch = errors.New("interval: document length mismatch") ErrLimitExceeded = errors.New("interval: configured limit exceeded") )
Functions ¶
This section is empty.
Types ¶
type Entry ¶
type Entry[T any] struct { ID string Range coordinate.AnchoredRange Layer int64 Value T }
Entry attaches an opaque value and host-defined layer to one anchored byte range. ID is the stable update/removal key.
type QueryOptions ¶
type QueryOptions struct {
MaxResults int
}
type Set ¶
type Set[T any] struct { // contains filtered or unexported fields }
Set is one immutable interval-set revision.
func (*Set[T]) Intersect ¶
func (s *Set[T]) Intersect( ctx context.Context, start, end int64, options QueryOptions, ) (Result[T], error)
Intersect returns entries overlapping [start,end), plus zero-width entries whose point lies inside that range.
func (*Set[T]) PutAll ¶
PutAll atomically applies entries in input order. Repeated IDs use their final value.
Click to show internal directories.
Click to hide internal directories.