single

package
v0.0.0-...-07dd178 Latest Latest
Warning

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

Go to latest
Published: Dec 29, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDuplicateTerm = fmt.Errorf("duplicate term inserted")
	ErrEmptyIndex    = fmt.Errorf("no terms inserted")
)

Functions

func CompressGob

func CompressGob[T any](items []T) ([]byte, error)

func CompressUint32

func CompressUint32(items []uint32) ([]byte, error)

func CompressUint64

func CompressUint64(items []uint64) ([]byte, error)

func DecompressGob

func DecompressGob[T any](data []byte) (items []T, err error)

func DecompressUint32

func DecompressUint32(data []byte) (items []uint32, err error)

func DecompressUint64

func DecompressUint64(data []byte) (items []uint64, err error)

func PrintSummary

func PrintSummary(filename string, out io.Writer) error

Types

type InvertedIndex

type InvertedIndex[V cmp.Ordered] struct {
	// contains filtered or unexported fields
}

InvertedIndex is a single index piece consists of terms FST + sorted values for each term resembles a sorted map[string][]int NOT CONCURRENT

func (*InvertedIndex[V]) Close

func (i *InvertedIndex[V]) Close() error

func (*InvertedIndex[V]) Len

func (i *InvertedIndex[V]) Len() int64

func (*InvertedIndex[V]) Put

func (i *InvertedIndex[V]) Put(term string, values []V) error

Put remembers all terms and its values, actual writing is delayed until Close()

func (*InvertedIndex[V]) ReadAllValues

func (i *InvertedIndex[V]) ReadAllValues(terms []string) (go_iterators.Iterator[V], error)

func (*InvertedIndex[V]) ReadTerms

func (i *InvertedIndex[V]) ReadTerms() (go_iterators.Iterator[string], error)

func (*InvertedIndex[V]) ReadValues

func (i *InvertedIndex[V]) ReadValues(terms []string, minVal V, maxVal V) (go_iterators.Iterator[V], error)

type InvertedIndexReader

type InvertedIndexReader[V constraints.Ordered] interface {
	// ReadTerms returns sorted iterator
	ReadTerms() (go_iterators.Iterator[string], error)
	// ReadValues returns sorted iterator
	ReadValues(terms []string, min V, max V) (go_iterators.Iterator[V], error)
	ReadAllValues(terms []string) (go_iterators.Iterator[V], error)
	io.Closer
}

func OpenInvertedIndex

func OpenInvertedIndex[V constraints.Ordered](
	file string,
	unserializeValues func([]byte) ([]V, error),
) (InvertedIndexReader[V], error)

type InvertedIndexWriter

type InvertedIndexWriter[V constraints.Ordered] interface {
	io.Closer // flush FST
	// Put must be called so terms are sorted, values must also be sorted beforehand
	Put(term string, values []V) error
}

func NewInvertedIndexUnit

func NewInvertedIndexUnit[V constraints.Ordered](
	filename string,
	segmentSize uint32,
	serializeValues func([]V) ([]byte, error),
	unserializeValues func([]byte) ([]V, error),
) (InvertedIndexWriter[V], error)

Jump to

Keyboard shortcuts

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