token

package
v0.75.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TableEntrySize = unsafe.Sizeof(TableEntry{}) + unsafe.Sizeof(&TableEntry{})
	FieldDataSize  = unsafe.Sizeof(FieldData{}) + unsafe.Sizeof(&FieldData{})
)
View Source
const CacheKeyTable = 1

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block struct {
	Payload     []byte
	Offsets     []uint32
	FreqIndexes []uint16 // indexes of tokens which have doc freqs (frequencies)
	Freqs       []uint32 // frequencies of certain tokens (how many docs have this token included at least once)
}

func (*Block) GetFreq added in v0.75.0

func (b *Block) GetFreq(index int) uint32

GetFreq returns frequency for a token if stored or 0 otherwise

func (*Block) GetToken

func (b *Block) GetToken(index int) []byte

func (*Block) Len

func (b *Block) Len() int

func (*Block) LettersBitset added in v0.75.0

func (b *Block) LettersBitset() util.LettersBitset

func (Block) Pack

func (b Block) Pack(dst []byte, buf []uint32) []byte

func (*Block) Size

func (b *Block) Size() int

func (*Block) Unpack

func (b *Block) Unpack(data []byte, fracVer config.BinaryDataVersion, unpackBuf *UnpackBuffer) error

type BlockLoader

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

BlockLoader is responsible for Reading from disk, unpacking and caching tokens blocks. NOT THREAD SAFE. Do not use concurrently. Use your own BlockLoader instance for each search query

func NewBlockLoader

func NewBlockLoader(
	fracName string,
	fracVer config.BinaryDataVersion,
	reader *storage.IndexReader,
	c *cache.Cache[*Block],
) *BlockLoader

func (*BlockLoader) Load

func (l *BlockLoader) Load(index uint32) *Block

type FieldData

type FieldData struct {
	MinVal  string
	Entries []*TableEntry // expect that TableEntry are necessarily ordered by StartTID here
}

type FieldTable

type FieldTable struct {
	Field   string
	Entries []*TableEntry // expect that TableEntry are necessarily ordered by StartTID here
}

type Provider

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

func NewProvider

func NewProvider(loader *BlockLoader, entries []*TableEntry) *Provider

func (*Provider) FindContains added in v0.72.0

func (tp *Provider) FindContains(needle []byte) ([]uint32, error)

func (*Provider) FindToken added in v0.72.0

func (tp *Provider) FindToken(searcher pattern.Searcher) ([]uint32, error)

func (*Provider) FirstTID

func (tp *Provider) FirstTID() uint32

func (*Provider) GetToken

func (tp *Provider) GetToken(tid uint32) []byte

func (*Provider) LastTID

func (tp *Provider) LastTID() uint32

func (*Provider) Ordered

func (tp *Provider) Ordered() bool

type Table

type Table map[string]*FieldData

func TableFromBlocks

func TableFromBlocks(blocks []TableBlock) Table

func (Table) GetEntryByTID

func (t Table) GetEntryByTID(tid uint32, field string) *TableEntry

func (Table) SelectEntries

func (t Table) SelectEntries(field, hint string) []*TableEntry

SelectEntries returns monotonic and continuous sequence of token table entries

func (Table) Size

func (t Table) Size() int

Size calculates a very approximate amount of memory occupied

type TableBlock

type TableBlock struct {
	FieldsTables []FieldTable
}

TableBlock represents how token.Table is stored on disk

func (TableBlock) Pack

func (b TableBlock) Pack(buf []byte) []byte

func (*TableBlock) Unpack

func (b *TableBlock) Unpack(data []byte, fracVer config.BinaryDataVersion)

type TableEntry

type TableEntry struct {
	StartIndex uint32 // offset from the beginning of the block to the first token pointed to by the TableEntry
	StartTID   uint32 // first TID of TableEntry
	BlockIndex uint32 // sequence number of the physical block of tokens in the file
	ValCount   uint32

	MinVal string // only saved for the first entry in block
	MaxVal string

	Letters util.LettersBitset // case-insensitive English letters present in entry tokens
}

TableEntry is part of token.Table and points to a fragment of token.Block

func (*TableEntry) GetIndexInTokensBlock

func (t *TableEntry) GetIndexInTokensBlock(tid uint32) int

func (*TableEntry) GetLastTID added in v0.74.0

func (t *TableEntry) GetLastTID() uint32

type TableLoader

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

func NewTableLoader

func NewTableLoader(
	fracName string,
	fracVer config.BinaryDataVersion,
	isLegacy bool,
	reader *storage.IndexReader,
	c *cache.Cache[Table],
) *TableLoader

func (*TableLoader) Load

func (l *TableLoader) Load() Table

type UnpackBuffer added in v0.75.0

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

func (*UnpackBuffer) Reset added in v0.75.0

func (b *UnpackBuffer) Reset(fracVer config.BinaryDataVersion)

Jump to

Keyboard shortcuts

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