core

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: May 8, 2023 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDuplicateKey is returned when a duplicate key is detected during an indexing operation.
	ErrDuplicateKey = errors.New("duplicate key")

	// ErrItemNotFound is returned when an item is not found in a bucket.
	ErrItemNotFound = errors.New("item not found")

	// ErrKeyNotFound is returned when a key is not found during an indexing operation.
	ErrKeyNotFound = errors.New("key not found")

	// ErrMalformedKey is returned when a key is malformed during an indexing operation.
	ErrMalformedKey = errors.New("malformed key")

	// ErrMultipleItemsFound is returned when multiple items are found in a bucket.
	ErrMultipleItemsFound = errors.New("multiple items found")

	// ErrNoIndices is returned when an operation is performed on a bucket without any indices.
	ErrNoIndices = errors.New("no indices given")

	// ErrNoItem is returned when an operation is performed on a bucket without an item.
	ErrNoItem = errors.New("no item given")

	// ErrNoIndex is returned when an operation is performed on a bucket without an index.
	ErrNoIndex = errors.New("no index given")

	// ErrNoKey is returned when an operation is performed on a bucket without a key.
	ErrNoKey = errors.New("no key given")

	// ErrNoQuery is returned when an operation is performed on a bucket without a query.
	ErrNoQuery = errors.New("no query given")

	// ErrNoValue is returned when an operation is performed on a bucket without a value.
	ErrNoValue = errors.New("no value given")

	// ErrNotReady is returned when an operation is performed on a bucket that is not ready.
	ErrNotReady = errors.New("not ready")
)

Functions

This section is empty.

Types

type Derivator

type Derivator func(item any) (any, error)

Derivator is a function type that derives an indexing value from an item. It is used to provide indexes for an item when it is added to a bucket.

type Index

type Index interface {
	Get(key any) ([]int, error)
	Set(key any, id int) error
	Delete(id int)
	Clear()
}

Index is a generic interface for an index that maps a generic key to one or more IDs It is thread-safe. It is used by Bucket to provide indexes for its items. It supports the following operations:

  • Get(T) ([]int, error)
  • Set(T, int) error
  • Delete(key) error
  • Clear()

(where T is the type of the key

and int is the type of the ID
and []int is the type of the IDs
and error is the type of the error
and bool is the type of the boolean

)

Jump to

Keyboard shortcuts

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