index

package
v0.0.0-...-2032768 Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSymbolNotFound = errors.New("symbol not found")

Functions

This section is empty.

Types

type PostingListOffset

type PostingListOffset struct {
	LabelValue string
	Off        index.Range
}

PostingListOffset contains the start and end offset of a posting list. The Start is inclusive and is the byte offset of the number_of_entries field of a posting list. The End is exclusive and is typically the byte offset of the CRC32 field. The End might be bigger than the actual posting ending, but not larger than the whole index file.

type PostingOffsetTable

type PostingOffsetTable interface {
	// PostingsOffset returns the byte range of the postings section for the label with the given name and value.
	// The Start is inclusive and is the byte offset of the number_of_entries field of a posting list.
	// The End is exclusive and is typically the byte offset of the CRC32 field.
	// The End might be bigger than the actual posting ending, but not larger than the whole index file.
	PostingsOffset(name string, value string) (rng index.Range, found bool, err error)

	// LabelValuesOffsets returns all postings lists for the label named name that match filter and have the prefix provided.
	// The ranges of each posting list are the same as returned by PostingsOffset.
	// The returned label values are sorted lexicographically (which the same as sorted by posting offset).
	LabelValuesOffsets(name, prefix string, filter func(string) bool) ([]PostingListOffset, error)

	// LabelNames returns a sorted list of all label names in this table.
	LabelNames() ([]string, error)

	NewSparsePostingOffsetTable() (table *indexheaderpb.PostingOffsetTable)
}

func NewPostingOffsetTable

func NewPostingOffsetTable(factory *streamencoding.DecbufFactory, tableOffset int, indexVersion int, indexLastPostingListEndBound uint64, postingOffsetsInMemSampling int, doChecksum bool) (PostingOffsetTable, error)

type PostingOffsetTableV1

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

func (*PostingOffsetTableV1) LabelNames

func (t *PostingOffsetTableV1) LabelNames() ([]string, error)

func (*PostingOffsetTableV1) LabelValuesOffsets

func (t *PostingOffsetTableV1) LabelValuesOffsets(name, prefix string, filter func(string) bool) ([]PostingListOffset, error)

func (*PostingOffsetTableV1) NewSparsePostingOffsetTable

func (t *PostingOffsetTableV1) NewSparsePostingOffsetTable() (table *indexheaderpb.PostingOffsetTable)

func (*PostingOffsetTableV1) PostingsOffset

func (t *PostingOffsetTableV1) PostingsOffset(name string, value string) (index.Range, bool, error)

type PostingOffsetTableV2

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

func NewPostingOffsetTableFromSparseHeader

func NewPostingOffsetTableFromSparseHeader(factory *streamencoding.DecbufFactory, postingsOffsetTable *indexheaderpb.PostingOffsetTable, tableOffset int, postingOffsetsInMemSampling int) (table *PostingOffsetTableV2, err error)

func (*PostingOffsetTableV2) LabelNames

func (t *PostingOffsetTableV2) LabelNames() ([]string, error)

func (*PostingOffsetTableV2) LabelValuesOffsets

func (t *PostingOffsetTableV2) LabelValuesOffsets(name, prefix string, filter func(string) bool) (_ []PostingListOffset, err error)

func (*PostingOffsetTableV2) NewSparsePostingOffsetTable

func (t *PostingOffsetTableV2) NewSparsePostingOffsetTable() (table *indexheaderpb.PostingOffsetTable)

NewSparsePostingOffsetTable loads all postings offset table data into a sparse index-header to be persisted to disk

func (*PostingOffsetTableV2) PostingsOffset

func (t *PostingOffsetTableV2) PostingsOffset(name string, value string) (r index.Range, found bool, err error)

type Symbols

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

func NewSymbols

func NewSymbols(factory *streamencoding.DecbufFactory, version, offset int, doChecksum bool) (s *Symbols, err error)

NewSymbols returns a Symbols object for symbol lookups.

func NewSymbolsFromSparseHeader

func NewSymbolsFromSparseHeader(factory *streamencoding.DecbufFactory, symbols *indexheaderpb.Symbols, version int, offset int) (s *Symbols, err error)

NewSymbolsFromSparseHeader reads from sparse index header and returns a Symbols object for symbol lookups.

func (*Symbols) ForEachSymbol

func (s *Symbols) ForEachSymbol(syms []string, f func(sym string, offset uint32) error) (err error)

ForEachSymbol performs a reverse lookup on each syms and passes the symbol and offset to f. For TSDB index v1, the symbol reference is the offset of the symbol in the index header file (not the TSDB index file). For TSDB index v2, the symbol reference is the sequence number of the symbol (starting at 0).

If the reference of a symbol cannot be looked up, iteration stops immediately and the error is returned. If f returns an error, iteration stops immediately and the error is returned. ForEachSymbol returns an error with cause ErrSymbolNotFound if any symbol cannot be found.

func (*Symbols) Lookup

func (s *Symbols) Lookup(o uint32) (sym string, err error)

Lookup takes a symbol reference and returns the symbol string. For TSDB index v1, the reference is expected to be the offset of the symbol in the index header file (not the TSDB index file). For TSDB index v2, the reference is expected to be the sequence number of the symbol (starting at 0). If the symbol reference is beyond the last symbol in the symbols table, the return error's cause will be ErrSymbolNotFound.

func (*Symbols) NewSparseSymbol

func (s *Symbols) NewSparseSymbol() (sparse *indexheaderpb.Symbols)

NewSparseSymbol loads all symbols data into an index-header sparse to be persisted to disk

func (*Symbols) Reader

func (s *Symbols) Reader() SymbolsReader

func (*Symbols) ReverseLookup

func (s *Symbols) ReverseLookup(sym string) (o uint32, err error)

ReverseLookup returns an error with cause ErrSymbolNotFound if the symbol cannot be found.

type SymbolsReader

type SymbolsReader interface {
	io.Closer

	// Read should return the string for the requested symbol.
	// Read should be called only with increasing symbols IDs;
	// this also means that it is not valid to call Read with the same symbol ID multiple times.
	Read(uint32) (string, error)
}

SymbolsReader sequentially reads symbols from a TSDB block index.

type SymbolsTableReaderV1

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

func (*SymbolsTableReaderV1) Close

func (r *SymbolsTableReaderV1) Close() error

func (*SymbolsTableReaderV1) Read

func (r *SymbolsTableReaderV1) Read(o uint32) (string, error)

type SymbolsTableReaderV2

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

func (*SymbolsTableReaderV2) Close

func (r *SymbolsTableReaderV2) Close() error

func (*SymbolsTableReaderV2) Read

func (r *SymbolsTableReaderV2) Read(o uint32) (string, error)

Jump to

Keyboard shortcuts

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