inverted_index

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InvertedIndex

type InvertedIndex struct {
	File             *os.File
	FilePath         string
	MaxIndexKeyLen   uint32
	ValuesStartPoint uint64
	FileSize         uint64
	// contains filtered or unexported fields
}

func NewInvertedIndex

func NewInvertedIndex(filePath string, maxIndexKeyLen *uint32, dbMaxKeys *uint64, dbRedundantBlocks *uint16) (*InvertedIndex, error)

NewInvertedIndex initializes a new Inverted Index

The max keys used in the search file are `max_index_key_len` * `db_max_keys` Since we each db key will be represented in the index a number of `max_index_key_len` times for example the key `food` must have the following index keys: `f`, `fo`, `foo`, `food`.

func (*InvertedIndex) Add

func (idx *InvertedIndex) Add(key []byte, kvAddr uint64, expiry uint64) error

Add adds a key's kv address in the corresponding prefixes' lists to update the inverted index

func (*InvertedIndex) Clear

func (idx *InvertedIndex) Clear() error

Clear clears all the data in the search index, except the header, and its original variables

func (*InvertedIndex) Close

func (idx *InvertedIndex) Close() error

Close closes the buffer pool, freeing up any resources

func (*InvertedIndex) Eq

func (idx *InvertedIndex) Eq(other *InvertedIndex) bool

Eq checks if the other InvertedIndex instance equals the current inverted index

func (*InvertedIndex) Remove

func (idx *InvertedIndex) Remove(key []byte) error

Remove deletes the key's kv address from all prefixes' lists in the inverted index

func (*InvertedIndex) Search

func (idx *InvertedIndex) Search(term []byte, skip uint64, limit uint64) ([]uint64, error)

Search returns list of db key-value addresses corresponding to the given term

It skips the first `skip` number of results and returns not more than `limit` number of items. This is to avoid using up more memory than can be handled by the host machine.

If `limit` is 0, all items are returned since it would make no sense for someone to search for zero items.

Jump to

Keyboard shortcuts

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