Documentation
¶
Index ¶
- Constants
- Variables
- func Load(data *segment.Data) (segment.Segment, error)
- func Merge(segments []segment.Segment, drops []*roaring.Bitmap, mergeBufferSize int) segment.Merger
- func New(results []segment.Document, normCalc func(string, int) float32) (segment.Segment, uint64, error)
- type CollectionStats
- type DictEntry
- type Dictionary
- func (d *Dictionary) Close() error
- func (d *Dictionary) Contains(key []byte) (bool, error)
- func (d *Dictionary) Iterator(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte) segment.DictionaryIterator
- func (d *Dictionary) OrPostingsDense(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte, dense []uint64) (bool, error)
- func (d *Dictionary) PostingsList(term []byte, except *roaring.Bitmap, prealloc segment.PostingsList) (segment.PostingsList, error)
- func (d *Dictionary) TermsIterator(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte) segment.DictionaryIterator
- type DictionaryIterator
- type DocumentValueReader
- type Location
- type Merger
- type NumericField
- type NumericValueVisitor
- type Options
- type Posting
- type PostingsIterator
- func (i *PostingsIterator) ActualBitmap() *roaring.Bitmap
- func (i *PostingsIterator) Advance(docNum uint64) (segment.Posting, error)
- func (i *PostingsIterator) BlockBound(docNum uint64) (maxFreq int, minNorm float64, end uint64, ok bool)
- func (i *PostingsIterator) Close() error
- func (i *PostingsIterator) Count() uint64
- func (i *PostingsIterator) DocNum1Hit() (uint64, bool)
- func (i *PostingsIterator) Empty() bool
- func (i *PostingsIterator) Next() (segment.Posting, error)
- func (i *PostingsIterator) NextBatch(docs []uint64, freqs []int, norms []float64) (int, error)
- func (i *PostingsIterator) ReplaceActual(abm *roaring.Bitmap)
- func (i *PostingsIterator) Size() int
- func (i *PostingsIterator) SkipBlocks(competitive func(maxFreq int, minNorm float64) bool) (uint64, error)
- type PostingsList
- type Segment
- func (s *Segment) CRC() uint32
- func (s *Segment) ChunkMode() uint32
- func (s *Segment) CollectionStats(field string) (segment.CollectionStats, error)
- func (s *Segment) Count() uint64
- func (s *Segment) Dictionary(field string) (segment.Dictionary, error)
- func (s *Segment) DocTimeMax() uint64
- func (s *Segment) DocTimeMin() uint64
- func (s *Segment) DocValueOffset() uint64
- func (s *Segment) DocsMatchingTerms(terms []segment.Term) (*roaring.Bitmap, error)
- func (s *Segment) DocumentValueReader(fields []string) (segment.DocumentValueReader, error)
- func (s *Segment) Fields() []string
- func (s *Segment) FieldsIndexOffset() uint64
- func (s *Segment) NumDocs() uint64
- func (s *Segment) SearchVectors(ctx context.Context, field string, query []float32, k int, metric vec.Metric, ...) ([]vec.Match, error)
- func (s *Segment) Size() int
- func (s *Segment) StoredChunkCacheStats() (hits, misses uint64, entries int)
- func (s *Segment) StoredIndexOffset() uint64
- func (s *Segment) Timestamp() (minimum, maximum int64)
- func (s *Segment) Type() string
- func (s *Segment) Version() uint32
- func (s *Segment) VisitStoredFields(num uint64, visitor segment.StoredFieldVisitor) error
- func (s *Segment) WriteTo(w io.Writer, _ chan struct{}) (int64, error)
Constants ¶
const MinReadableVersion = versionTermDocValues
MinReadableVersion is the oldest segment version this package loads.
const Type string = "ice"
const Version uint32 = 5
Version 5 adds per-chunk freq/norm bounds (block max) to postings.
Variables ¶
var StoredChunkCacheSize = 100
StoredChunkCacheSize is the default number of decompressed stored-field chunks each segment keeps in its LRU cache; New and Load read it when a segment is opened. A chunk holds defaultDocumentChunkSize documents. Zero disables caching. Use Options to set it per index instead of globally.
Functions ¶
Types ¶
type CollectionStats ¶
type CollectionStats struct {
// contains filtered or unexported fields
}
func (*CollectionStats) DocumentCount ¶
func (c *CollectionStats) DocumentCount() uint64
func (*CollectionStats) Merge ¶
func (c *CollectionStats) Merge(other segment.CollectionStats)
func (*CollectionStats) SumTotalTermFrequency ¶
func (c *CollectionStats) SumTotalTermFrequency() uint64
func (*CollectionStats) TotalDocumentCount ¶
func (c *CollectionStats) TotalDocumentCount() uint64
type Dictionary ¶
type Dictionary struct {
// contains filtered or unexported fields
}
Dictionary is the representation of the term dictionary
func (*Dictionary) Close ¶
func (d *Dictionary) Close() error
func (*Dictionary) Iterator ¶
func (d *Dictionary) Iterator(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte) segment.DictionaryIterator
Iterator returns an iterator which only visits terms having the the vellum automaton and start/end key range
func (*Dictionary) OrPostingsDense ¶ added in v1.3.3
func (d *Dictionary) OrPostingsDense(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte, dense []uint64) (bool, error)
OrPostingsDense ORs the postings of every term the automaton accepts in [startKeyInclusive, endKeyExclusive) into dense, a bitset of the segment's documents, walking the dictionary once. It returns false, leaving dense partly written, if a posting falls outside dense.
func (*Dictionary) PostingsList ¶
func (d *Dictionary) PostingsList(term []byte, except *roaring.Bitmap, prealloc segment.PostingsList) (segment.PostingsList, error)
PostingsList returns the postings list for the specified term
func (*Dictionary) TermsIterator ¶ added in v1.3.3
func (d *Dictionary) TermsIterator(a segment.Automaton, startKeyInclusive, endKeyExclusive []byte) segment.DictionaryIterator
TermsIterator is Iterator without reading each term's postings for its count: entries report a Count of 0. Use it when only terms are needed.
type DictionaryIterator ¶
type DictionaryIterator struct {
// contains filtered or unexported fields
}
DictionaryIterator is an iterator for term dictionary
func (*DictionaryIterator) Close ¶
func (i *DictionaryIterator) Close() error
func (*DictionaryIterator) Next ¶
func (i *DictionaryIterator) Next() (segment.DictionaryEntry, error)
Next returns the next entry in the dictionary
type DocumentValueReader ¶
type DocumentValueReader struct {
// contains filtered or unexported fields
}
func (*DocumentValueReader) VisitDocumentNumbers ¶ added in v1.3.0
func (d *DocumentValueReader) VisitDocumentNumbers(number uint64, visitor segment.DocumentValueVisitor, numVisitor segment.NumericValueVisitor) error
VisitDocumentNumbers is like VisitDocumentValues but numeric column fields go to numVisitor as int64 instead of prefix coded terms.
func (*DocumentValueReader) VisitDocumentValues ¶
func (d *DocumentValueReader) VisitDocumentValues(number uint64, visitor segment.DocumentValueVisitor) error
type Location ¶
type Location struct {
// contains filtered or unexported fields
}
Location represents the location of a single occurrence
func (*Location) Field ¶
Field returns the name of the field (useful in composite fields to know which original field the value came from)
type Merger ¶
type Merger struct {
// contains filtered or unexported fields
}
func (*Merger) DocumentNumbers ¶
type NumericField ¶ added in v1.3.0
type NumericField = segment.NumericField
NumericField is the segment API's typed numeric field; kept as an alias so existing callers in this package keep compiling.
type NumericValueVisitor ¶ added in v1.3.0
type NumericValueVisitor = segment.NumericValueVisitor
NumericValueVisitor receives typed values of numeric column fields.
type Options ¶ added in v1.3.0
type Options struct {
// StoredChunkCacheSize bounds decompressed stored-field chunks kept per
// segment; zero disables caching.
StoredChunkCacheSize int
}
Options tunes segments opened by its New and Load methods, which match the signatures of the package-level New and Load.
func DefaultOptions ¶ added in v1.3.0
func DefaultOptions() Options
DefaultOptions returns Options mirroring the package-level defaults.
type Posting ¶
type Posting struct {
// contains filtered or unexported fields
}
Posting is a single entry in a postings list
func (*Posting) Frequency ¶
Frequency returns the frequencies of occurrence of this term in this doc/field
type PostingsIterator ¶
type PostingsIterator struct {
Actual roaring.IntPeekable
ActualBM *roaring.Bitmap
// contains filtered or unexported fields
}
PostingsIterator provides a way to iterate through the postings list
func (*PostingsIterator) ActualBitmap ¶
func (i *PostingsIterator) ActualBitmap() *roaring.Bitmap
ActualBitmap returns the underlying actual bitmap which can be used up the stack for optimizations
func (*PostingsIterator) Advance ¶
func (i *PostingsIterator) Advance(docNum uint64) (segment.Posting, error)
Advance returns the posting at the specified docNum or it is not present the next posting, or if the end is reached, nil
func (*PostingsIterator) BlockBound ¶ added in v1.4.0
func (i *PostingsIterator) BlockBound(docNum uint64) (maxFreq int, minNorm float64, end uint64, ok bool)
BlockBound returns the largest freq and smallest norm of the freq/norm chunk holding docNum, and the first docNum past that chunk. ok is false when the segment stores no chunk bounds (before version 5) or the list has no freq/norm chunks.
func (*PostingsIterator) Close ¶
func (i *PostingsIterator) Close() error
func (*PostingsIterator) Count ¶
func (i *PostingsIterator) Count() uint64
func (*PostingsIterator) DocNum1Hit ¶
func (i *PostingsIterator) DocNum1Hit() (uint64, bool)
DocNum1Hit returns the docNum and true if this is "1-hit" optimized and the docNum is available.
func (*PostingsIterator) Empty ¶
func (i *PostingsIterator) Empty() bool
func (*PostingsIterator) Next ¶
func (i *PostingsIterator) Next() (segment.Posting, error)
Next returns the next posting on the postings list, or nil at the end
func (*PostingsIterator) NextBatch ¶ added in v1.3.3
NextBatch reads up to len(docs) postings into docs, freqs and norms, which must be the same length, and returns how many it read; 0 means the end. It is Next in bulk for iterators without locations.
func (*PostingsIterator) ReplaceActual ¶
func (i *PostingsIterator) ReplaceActual(abm *roaring.Bitmap)
ReplaceActual replaces the ActualBM with the provided bitmap
func (*PostingsIterator) Size ¶
func (i *PostingsIterator) Size() int
func (*PostingsIterator) SkipBlocks ¶ added in v1.4.0
func (i *PostingsIterator) SkipBlocks(competitive func(maxFreq int, minNorm float64) bool) (uint64, error)
SkipBlocks skips, from the next posting on, the rest of every freq/norm chunk whose bounds competitive rejects, stopping at the first chunk it accepts, and returns how many postings it skipped. competitive gets the chunk's largest freq and smallest norm. Chunk bounds exist in version 5+ segments; elsewhere, and on lists with deletions, it skips nothing.
type PostingsList ¶
type PostingsList struct {
// contains filtered or unexported fields
}
PostingsList is an in-memory representation of a postings list
func (*PostingsList) Count ¶
func (p *PostingsList) Count() uint64
Count returns the number of items on this postings list
func (*PostingsList) Iterator ¶
func (p *PostingsList) Iterator(includeFreq, includeNorm, includeLocs bool, prealloc segment.PostingsIterator) (segment.PostingsIterator, error)
Iterator returns an iterator for this postings list
func (*PostingsList) OrInto ¶
func (p *PostingsList) OrInto(receiver *roaring.Bitmap)
func (*PostingsList) Size ¶
func (p *PostingsList) Size() int
type Segment ¶
type Segment struct {
// contains filtered or unexported fields
}
func (*Segment) CollectionStats ¶
func (s *Segment) CollectionStats(field string) (segment.CollectionStats, error)
func (*Segment) Dictionary ¶
func (s *Segment) Dictionary(field string) (segment.Dictionary, error)
DictionaryReader returns the term dictionary for the specified field
func (*Segment) DocTimeMax ¶
DocTimeMax returns the maximum timestamp of documents in the file footer
func (*Segment) DocTimeMin ¶
DocTimeMin returns the minimum timestamp of documents in the file footer
func (*Segment) DocValueOffset ¶
DocValueOffset returns the docValue offset in the file footer
func (*Segment) DocsMatchingTerms ¶
func (*Segment) DocumentValueReader ¶
func (s *Segment) DocumentValueReader(fields []string) (segment.DocumentValueReader, error)
func (*Segment) FieldsIndexOffset ¶
FieldsIndexOffset returns the fields index offset in the file footer
func (*Segment) SearchVectors ¶
func (s *Segment) SearchVectors(ctx context.Context, field string, query []float32, k int, metric vec.Metric, accept func(uint64) bool) ([]vec.Match, error)
SearchVectors exhaustively searches encoded vectors in stored field values. Repeated fields contribute their best score per document. Results are ordered by descending score, then ascending segment-local document number. accept is an optional prefilter; callers must use it to exclude live-index deletions. Every matching value in an accepted document must be valid, even outside top k.
func (*Segment) StoredChunkCacheStats ¶ added in v1.3.0
StoredChunkCacheStats returns hits, misses and resident entries of the decompressed stored-field chunk cache.
func (*Segment) StoredIndexOffset ¶
StoredIndexOffset returns the stored value index offset in the file footer
func (*Segment) VisitStoredFields ¶
func (s *Segment) VisitStoredFields(num uint64, visitor segment.StoredFieldVisitor) error
VisitStoredFields invokes the DocFieldValueVistor for each stored field for the specified doc number