Documentation ¶
Index ¶
- Constants
- Variables
- func WriteBinary(ctx context.Context, bkt objstore.BucketReader, id ulid.ULID, filename string) (err error)
- func WriteJSON(logger log.Logger, indexFn string, fn string) error
- type BinaryReader
- func (r *BinaryReader) Close() error
- func (r BinaryReader) IndexVersion() int
- func (r BinaryReader) LabelNames() []string
- func (r BinaryReader) LabelValues(name string) ([]string, error)
- func (r BinaryReader) LookupSymbol(o uint32) (string, error)
- func (r BinaryReader) PostingsOffset(name string, value string) (index.Range, error)
- type BinaryTOC
- type FileWriter
- func (fw *FileWriter) AddPadding(size int) error
- func (fw *FileWriter) Close() error
- func (fw *FileWriter) Flush() error
- func (fw *FileWriter) Pos() uint64
- func (fw *FileWriter) Remove() error
- func (fw *FileWriter) Write(bufs ...[]byte) error
- func (fw *FileWriter) WriteAt(buf []byte, pos uint64) error
- type JSONReader
- func (r *JSONReader) Close() error
- func (r *JSONReader) IndexVersion() int
- func (r *JSONReader) LabelNames() []string
- func (r *JSONReader) LabelValues(name string) ([]string, error)
- func (r *JSONReader) LookupSymbol(o uint32) (string, error)
- func (r *JSONReader) PostingsOffset(name, value string) (index.Range, error)
- type Reader
Constants ¶
const ( // BinaryFormatV1 represents first version of index-header file. BinaryFormatV1 = 1 // MagicIndex are 4 bytes at the head of an index-header file. MagicIndex = 0xBAAAD792 )
const ( // JSONVersion1 is a enumeration of index-cache.json versions supported by Thanos. JSONVersion1 = iota + 1 )
Variables ¶
var NotFoundRangeErr = errors.New("range not found")
NotFoundRangeErr is an error returned by PostingsOffset when there is no posting for given name and value pairs.
Functions ¶
func WriteBinary ¶ added in v0.11.0
func WriteBinary(ctx context.Context, bkt objstore.BucketReader, id ulid.ULID, filename string) (err error)
WriteBinary build index-header file from the pieces of index in object storage.
Types ¶
type BinaryReader ¶ added in v0.11.0
type BinaryReader struct {
// contains filtered or unexported fields
}
func NewBinaryReader ¶ added in v0.11.0
func NewBinaryReader(ctx context.Context, logger log.Logger, bkt objstore.BucketReader, dir string, id ulid.ULID, postingOffsetsInMemSampling int) (*BinaryReader, error)
NewBinaryReader loads or builds new index-header if not present on disk.
func (*BinaryReader) Close ¶ added in v0.11.0
func (r *BinaryReader) Close() error
func (BinaryReader) IndexVersion ¶ added in v0.11.0
func (r BinaryReader) IndexVersion() int
func (BinaryReader) LabelNames ¶ added in v0.11.0
func (r BinaryReader) LabelNames() []string
func (BinaryReader) LabelValues ¶ added in v0.11.0
func (r BinaryReader) LabelValues(name string) ([]string, error)
func (BinaryReader) LookupSymbol ¶ added in v0.11.0
func (r BinaryReader) LookupSymbol(o uint32) (string, error)
func (BinaryReader) PostingsOffset ¶ added in v0.11.0
TODO(bwplotka): Get advantage of multi value offset fetch.
type BinaryTOC ¶ added in v0.11.0
type BinaryTOC struct { // Symbols holds start to the same symbols section as index related to this index header. Symbols uint64 // PostingsOffsetTable holds start to the the same Postings Offset Table section as index related to this index header. PostingsOffsetTable uint64 }
BinaryTOC is a table of content for index-header file.
type FileWriter ¶ added in v0.11.0
type FileWriter struct {
// contains filtered or unexported fields
}
func NewFileWriter ¶ added in v0.11.0
func NewFileWriter(name string, size int) (*FileWriter, error)
TODO(bwplotka): Added size to method, upstream this.
func (*FileWriter) AddPadding ¶ added in v0.11.0
func (fw *FileWriter) AddPadding(size int) error
AddPadding adds zero byte padding until the file size is a multiple size.
func (*FileWriter) Close ¶ added in v0.11.0
func (fw *FileWriter) Close() error
func (*FileWriter) Flush ¶ added in v0.11.0
func (fw *FileWriter) Flush() error
func (*FileWriter) Pos ¶ added in v0.11.0
func (fw *FileWriter) Pos() uint64
func (*FileWriter) Remove ¶ added in v0.11.0
func (fw *FileWriter) Remove() error
func (*FileWriter) Write ¶ added in v0.11.0
func (fw *FileWriter) Write(bufs ...[]byte) error
type JSONReader ¶
type JSONReader struct {
// contains filtered or unexported fields
}
JSONReader is a reader based on index-cache.json files.
func NewJSONReader ¶
func NewJSONReader(ctx context.Context, logger log.Logger, bkt objstore.InstrumentedBucketReader, dir string, id ulid.ULID) (*JSONReader, error)
NewJSONReader loads or builds new index-cache.json if not present on disk or object storage.
func (*JSONReader) Close ¶ added in v0.11.0
func (r *JSONReader) Close() error
func (*JSONReader) IndexVersion ¶
func (r *JSONReader) IndexVersion() int
func (*JSONReader) LabelNames ¶
func (r *JSONReader) LabelNames() []string
LabelNames returns a list of label names.
func (*JSONReader) LabelValues ¶
func (r *JSONReader) LabelValues(name string) ([]string, error)
LabelValues returns label values for single name.
func (*JSONReader) LookupSymbol ¶
func (r *JSONReader) LookupSymbol(o uint32) (string, error)
func (*JSONReader) PostingsOffset ¶
func (r *JSONReader) PostingsOffset(name, value string) (index.Range, error)
type Reader ¶
type Reader interface { io.Closer // IndexVersion returns version of index. IndexVersion() int // PostingsOffset returns start and end offsets of postings for given name and value. // The end offset might be bigger than the actual posting ending, but not larger than the whole index file. // NotFoundRangeErr is returned when no index can be found for given name and value. // TODO(bwplotka): Move to PostingsOffsets(name string, value ...string) []index.Range and benchmark. PostingsOffset(name string, value string) (index.Range, error) // LookupSymbol returns string based on given reference. // Error is return if the symbol can't be found. LookupSymbol(o uint32) (string, error) // LabelValues returns all label values for given label name or error. // If no values are found for label name, or label name does not exists, // then empty string is returned and no error. LabelValues(name string) ([]string, error) // LabelNames returns all label names. LabelNames() []string }
Reader is an interface allowing to read essential, minimal number of index fields from the small portion of index file called header.