terms

package
v1.28.3 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BLOCK_SIZE = 128
	// if we are only encoding few documents, we can encode the doc ids and tfs as full bytes.
	// Limit for this is currently set to 1
	ENCODE_AS_FULL_BYTES = 1
)

Functions

func DecodeBlockDataReusable added in v1.28.0

func DecodeBlockDataReusable(data []byte, out *BlockData)

func DoBlockMaxWand added in v1.28.0

func DoBlockMaxWand(limit int, results *Terms, averagePropLength float64, additionalExplanations bool,
) *priorityqueue.Queue[[]*DocPointerWithScore]

func DoWand added in v1.28.0

func DoWand(limit int, results *Terms, averagePropLength float64, additionalExplanations bool,
) *priorityqueue.Queue[[]*DocPointerWithScore]

Types

type BlockData added in v1.28.0

type BlockData struct {
	DocIds []byte
	Tfs    []byte
}

func DecodeBlockData added in v1.28.0

func DecodeBlockData(data []byte) *BlockData

func (*BlockData) Encode added in v1.28.0

func (b *BlockData) Encode() []byte

func (*BlockData) Size added in v1.28.0

func (b *BlockData) Size() int

type BlockDataDecoded added in v1.28.0

type BlockDataDecoded struct {
	DocIds []uint64
	Tfs    []uint64
}

type BlockEntry added in v1.28.0

type BlockEntry struct {
	MaxId               uint64
	Offset              uint32
	MaxImpactTf         uint32
	MaxImpactPropLength uint32
}

func DecodeBlockEntry added in v1.28.0

func DecodeBlockEntry(data []byte) *BlockEntry

func (*BlockEntry) Encode added in v1.28.0

func (b *BlockEntry) Encode() []byte

func (*BlockEntry) Size added in v1.28.0

func (b *BlockEntry) Size() int

type DocPointerWithScore

type DocPointerWithScore struct {
	Id uint64
	// A Frequency of 0 indicates a tombstone
	Frequency  float32
	PropLength float32
}

func (*DocPointerWithScore) FromBytes

func (d *DocPointerWithScore) FromBytes(in []byte, isTombstone bool, boost float32) error

func (*DocPointerWithScore) FromBytesInverted added in v1.28.0

func (d *DocPointerWithScore) FromBytesInverted(in []byte, boost float32, propLen float32) error

func (*DocPointerWithScore) FromKeyVal

func (d *DocPointerWithScore) FromKeyVal(key []byte, value []byte, isTombstone bool, boost float32) error

type SortedDocPointerWithScoreMerger

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

func NewSortedDocPointerWithScoreMerger

func NewSortedDocPointerWithScoreMerger() *SortedDocPointerWithScoreMerger

func (*SortedDocPointerWithScoreMerger) Do

type Term

type Term struct {
	Data []DocPointerWithScore
	// contains filtered or unexported fields
}

func NewTerm added in v1.28.0

func NewTerm(queryTerm string, queryTermIndex int, propertyBoost float32, config schema.BM25Config) *Term

func (*Term) Advance added in v1.28.0

func (t *Term) Advance()

func (*Term) AdvanceAtLeast

func (t *Term) AdvanceAtLeast(minID uint64)

func (*Term) AdvanceAtLeastShallow added in v1.28.0

func (t *Term) AdvanceAtLeastShallow(minID uint64)

func (*Term) Count

func (t *Term) Count() int

func (*Term) CurrentBlockImpact added in v1.28.0

func (t *Term) CurrentBlockImpact() float32

func (*Term) CurrentBlockMaxId added in v1.28.0

func (t *Term) CurrentBlockMaxId() uint64

func (*Term) Exhausted

func (t *Term) Exhausted() bool

func (*Term) IdPointer

func (t *Term) IdPointer() uint64

func (*Term) Idf

func (t *Term) Idf() float64

func (*Term) PosPointer

func (t *Term) PosPointer() uint64

func (*Term) QueryTerm

func (t *Term) QueryTerm() string

func (*Term) QueryTermIndex

func (t *Term) QueryTermIndex() int

func (*Term) Score added in v1.28.0

func (t *Term) Score(averagePropLength float64, additionalExplanations bool) (uint64, float64, *DocPointerWithScore)

func (*Term) SetIdPointer added in v1.28.0

func (t *Term) SetIdPointer(idPointer uint64)

func (*Term) SetIdf added in v1.28.0

func (t *Term) SetIdf(idf float64)

func (*Term) SetPosPointer added in v1.28.0

func (t *Term) SetPosPointer(posPointer uint64)

type TermInterface added in v1.28.0

type TermInterface interface {
	// doubles as max impact (with tf=1, the max impact would be 1*Idf), if there
	// is a boost for a queryTerm, simply apply it here once
	Idf() float64
	IdPointer() uint64
	Exhausted() bool
	Count() int
	QueryTermIndex() int
	AdvanceAtLeast(minID uint64)
	AdvanceAtLeastShallow(minID uint64)
	Advance()
	Score(averagePropLength float64, additionalExplanations bool) (uint64, float64, *DocPointerWithScore)
	CurrentBlockImpact() float32
	CurrentBlockMaxId() uint64
}

type Terms

type Terms struct {
	T     []TermInterface
	Count int
}

func (*Terms) AdvanceAllAtLeast

func (t *Terms) AdvanceAllAtLeast(minID uint64, pivot int)

func (*Terms) CompletelyExhausted

func (t *Terms) CompletelyExhausted() bool

func (*Terms) FindFirstNonExhausted

func (t *Terms) FindFirstNonExhausted() (int, bool)

func (*Terms) FindMinID

func (t *Terms) FindMinID(minScore float64) (uint64, int, bool)

func (*Terms) FindMinIDWand added in v1.28.0

func (t *Terms) FindMinIDWand(minScore float64) (uint64, int, bool)

func (*Terms) GetBlockUpperBound added in v1.28.0

func (t *Terms) GetBlockUpperBound(pivot int, pivotId uint64) float32

func (*Terms) Len

func (t *Terms) Len() int

provide sort interface

func (*Terms) Less

func (t *Terms) Less(i, j int) bool

func (*Terms) Pivot

func (t *Terms) Pivot(minScore float64) bool

func (*Terms) ScoreNext

func (t *Terms) ScoreNext(averagePropLength float64, additionalExplanations bool) (uint64, float64, []*DocPointerWithScore)

func (*Terms) SortFirst added in v1.28.0

func (t *Terms) SortFirst()

func (*Terms) SortFull added in v1.28.0

func (t *Terms) SortFull()

func (*Terms) SortPartial added in v1.28.0

func (t *Terms) SortPartial(nextList int)

func (*Terms) Swap

func (t *Terms) Swap(i, j int)

Jump to

Keyboard shortcuts

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