indexes

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ByField added in v0.1.0

type ByField[R record.Record] interface {
	Add(index Index[R])
	Insert(item R)
	Delete(item R)
	Update(oldItem, item R)
	SelectForCondition(condition where.Condition[R]) (
		indexExists bool,
		count int,
		ids []storage.IDIterator,
		idsUnique bool,
		err error,
	)
}

func CreateByField added in v0.1.0

func CreateByField[R record.Record]() ByField[R]

type ConcurrentStorage added in v0.1.0

type ConcurrentStorage interface {
	RLock()
	RUnlock()
	Unwrap() Storage
	Get(key Key) storage.IDStorage
	GetOrCreate(key Key) storage.IDStorage
}

ConcurrentStorage wrapped Storage for concurrent safe access.

func CreateConcurrentStorage added in v0.1.0

func CreateConcurrentStorage(original Storage, storeOnlyUniqID bool) ConcurrentStorage

type Index added in v0.1.0

type Index[R record.Record] interface {
	Field() record.Field
	Unique() bool
	Compute() IndexComputer[R]
	Weight(condition where.Condition[R]) (canApplyIndex bool, weight IndexWeight)
	Select(condition where.Condition[R]) (count int, ids []storage.IDIterator, err error)
	ConcurrentStorage() ConcurrentStorage
}

type IndexComputer added in v0.1.0

type IndexComputer[R record.Record] interface {
	ForRecord(item R) Key
	ForValue(value any) Key
	Check(indexKey Key, comparator where.FieldComparator[R]) (bool, error)
}

type IndexWeight added in v0.1.0

type IndexWeight uint8
const (
	IndexWeightLow    IndexWeight = 10
	IndexWeightMedium IndexWeight = 20
	IndexWeightHigh   IndexWeight = 30
)

type Key added in v0.1.0

type Key interface {
	Less(than Key) bool
}

type Storage added in v0.1.0

type Storage interface {
	Get(key Key) storage.IDStorage
	Set(key Key, records storage.IDStorage)
}

Storage is base interface for indexes.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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