index

package
v1.9.13-beta2 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CompoundIndex

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

CompoundIndex provides nested lookups: group -> subgroup -> OrderedIndex. Designed for queries like: WHERE colony=$1 AND state=$2 ORDER BY priorityTime. Thread-safe via internal RWMutex.

func NewCompoundIndex

func NewCompoundIndex() *CompoundIndex

NewCompoundIndex creates a new CompoundIndex.

func (*CompoundIndex) Add

func (c *CompoundIndex) Add(group string, subgroup int, entry IndexEntry[string])

Add inserts an entry into the index at the given group and subgroup.

func (*CompoundIndex) AscendFirst

func (c *CompoundIndex) AscendFirst(group string, subgroup int, n int, fn func(IndexEntry[string]) bool)

AscendFirst calls fn for the first n entries in the given group/subgroup in ascending order. Returns immediately if group/subgroup doesn't exist.

func (*CompoundIndex) Clear

func (c *CompoundIndex) Clear()

Clear removes all entries.

func (*CompoundIndex) Count

func (c *CompoundIndex) Count(group string, subgroup int) int

Count returns the number of entries in the given group/subgroup.

func (*CompoundIndex) CountAll

func (c *CompoundIndex) CountAll(group string) int

CountAll returns the total count across all subgroups for a group.

func (*CompoundIndex) CountBySubgroup

func (c *CompoundIndex) CountBySubgroup(subgroup int) int

CountBySubgroup returns the total count for a subgroup across all groups.

func (*CompoundIndex) DescendFirst

func (c *CompoundIndex) DescendFirst(group string, subgroup int, n int, fn func(IndexEntry[string]) bool)

DescendFirst calls fn for the first n entries in the given group/subgroup in descending order.

func (*CompoundIndex) Get

func (c *CompoundIndex) Get(group string, subgroup int) *OrderedIndex[string]

Get returns the OrderedIndex for a given group and subgroup, or nil if not found.

func (*CompoundIndex) Remove

func (c *CompoundIndex) Remove(group string, subgroup int, entry IndexEntry[string])

Remove removes an entry from the index at the given group and subgroup.

type IndexEntry

type IndexEntry[K comparable] struct {
	SortKey    int64
	PrimaryKey K
}

IndexEntry is a btree entry pairing a sort key with a primary key.

type MapIndex

type MapIndex[K comparable, SK comparable] struct {
	// contains filtered or unexported fields
}

MapIndex maps secondary keys to sets of primary keys for equality lookups. Thread-safe via internal RWMutex.

func NewMapIndex

func NewMapIndex[K comparable, SK comparable]() *MapIndex[K, SK]

NewMapIndex creates a new MapIndex.

func (*MapIndex[K, SK]) Add

func (m *MapIndex[K, SK]) Add(key K, secondaryKey SK)

Add associates a primary key with a secondary key.

func (*MapIndex[K, SK]) Clear

func (m *MapIndex[K, SK]) Clear()

Clear removes all entries from the index.

func (*MapIndex[K, SK]) Count

func (m *MapIndex[K, SK]) Count(secondaryKey SK) int

Count returns the number of primary keys associated with the given secondary key.

func (*MapIndex[K, SK]) Lookup

func (m *MapIndex[K, SK]) Lookup(secondaryKey SK) []K

Lookup returns all primary keys associated with the given secondary key. Returns nil if none found.

func (*MapIndex[K, SK]) Remove

func (m *MapIndex[K, SK]) Remove(key K, secondaryKey SK)

Remove disassociates a primary key from a secondary key.

type OrderedIndex

type OrderedIndex[K comparable] struct {
	// contains filtered or unexported fields
}

OrderedIndex provides sorted access to primary keys via a btree. Thread-safe via internal RWMutex.

func NewOrderedIndex

func NewOrderedIndex[K comparable](keyLess func(a, b K) bool) *OrderedIndex[K]

NewOrderedIndex creates a new OrderedIndex. Entries are sorted by SortKey ascending, with ties broken by primary key string representation.

func NewStringOrderedIndex

func NewStringOrderedIndex() *OrderedIndex[string]

NewStringOrderedIndex creates an OrderedIndex with string primary keys.

func (*OrderedIndex[K]) Add

func (o *OrderedIndex[K]) Add(entry IndexEntry[K])

Add inserts an entry into the index.

func (*OrderedIndex[K]) AscendFirst

func (o *OrderedIndex[K]) AscendFirst(n int, fn func(IndexEntry[K]) bool)

AscendFirst calls fn for the first n entries in ascending order. Iteration stops when fn returns false or n entries have been visited.

func (*OrderedIndex[K]) AscendGreaterThan

func (o *OrderedIndex[K]) AscendGreaterThan(threshold int64, fn func(IndexEntry[K]) bool)

AscendGreaterThan calls fn for entries with SortKey > threshold. Iteration stops when fn returns false.

func (*OrderedIndex[K]) AscendRange

func (o *OrderedIndex[K]) AscendRange(min, max int64, fn func(IndexEntry[K]) bool)

AscendRange calls fn for entries with SortKey in [min, max] (inclusive). Iteration stops when fn returns false.

func (*OrderedIndex[K]) Clear

func (o *OrderedIndex[K]) Clear()

Clear removes all entries.

func (*OrderedIndex[K]) DescendFirst

func (o *OrderedIndex[K]) DescendFirst(n int, fn func(IndexEntry[K]) bool)

DescendFirst calls fn for the first n entries in descending order. Iteration stops when fn returns false or n entries have been visited.

func (*OrderedIndex[K]) Len

func (o *OrderedIndex[K]) Len() int

Len returns the number of entries in the index.

func (*OrderedIndex[K]) Remove

func (o *OrderedIndex[K]) Remove(entry IndexEntry[K])

Remove removes an entry from the index.

Jump to

Keyboard shortcuts

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