Documentation ¶
Index ¶
- Constants
- Variables
- func AppendSeriesEntry(dst []byte, flag uint8, id tsdb.SeriesIDTyped, key []byte) []byte
- func AppendSeriesKey(dst []byte, name []byte, tags models.Tags) []byte
- func CompareSeriesKeys(a, b []byte) int
- func GenerateSeriesKeys(names [][]byte, tagsSlice []models.Tags) [][]byte
- func IsValidSeriesEntryFlag(flag byte) bool
- func IsValidSeriesSegmentFilename(filename string) bool
- func JoinSeriesOffset(segmentID uint16, pos uint32) int64
- func ParseSeriesKey(data []byte) (name []byte, tags models.Tags)
- func ParseSeriesKeyInto(data []byte, dstTags models.Tags) ([]byte, models.Tags)
- func ParseSeriesSegmentFilename(filename string) (uint16, error)
- func PrometheusCollectors() []prometheus.Collector
- func ReadSeriesEntry(data []byte) (flag uint8, id tsdb.SeriesIDTyped, key []byte, sz int64)
- func ReadSeriesKey(data []byte) (key, remainder []byte)
- func ReadSeriesKeyFromSegments(a []*SeriesSegment, offset int64) []byte
- func ReadSeriesKeyLen(data []byte) (sz int, remainder []byte)
- func ReadSeriesKeyMeasurement(data []byte) (name, remainder []byte)
- func ReadSeriesKeyTag(data []byte) (key, value, remainder []byte)
- func ReadSeriesKeyTagN(data []byte) (n int, remainder []byte)
- func SeriesKeySize(name []byte, tags models.Tags) int
- func SeriesKeysSize(names [][]byte, tagsSlice []models.Tags) int
- func SeriesSegmentSize(id uint16) uint32
- func SplitSeriesOffset(offset int64) (segmentID uint16, pos uint32)
- type Config
- type IDData
- type SeriesFile
- func (f *SeriesFile) Acquire() (*lifecycle.Reference, error)
- func (f *SeriesFile) Close() error
- func (f *SeriesFile) CreateSeriesListIfNotExists(collection *tsdb.SeriesCollection) error
- func (f *SeriesFile) DeleteSeriesIDs(ids []tsdb.SeriesID) error
- func (f *SeriesFile) DisableCompactions()
- func (f *SeriesFile) DisableMetrics()
- func (f *SeriesFile) EnableCompactions()
- func (f *SeriesFile) FileSize() (n int64, err error)
- func (f *SeriesFile) HasSeries(name []byte, tags models.Tags, buf []byte) bool
- func (f *SeriesFile) IsDeleted(id tsdb.SeriesID) bool
- func (f *SeriesFile) Open(ctx context.Context) error
- func (f *SeriesFile) Partitions() []*SeriesPartition
- func (f *SeriesFile) Path() string
- func (f *SeriesFile) Series(id tsdb.SeriesID) ([]byte, models.Tags)
- func (f *SeriesFile) SeriesCount() uint64
- func (f *SeriesFile) SeriesID(name []byte, tags models.Tags, buf []byte) tsdb.SeriesID
- func (f *SeriesFile) SeriesIDPartition(id tsdb.SeriesID) *SeriesPartition
- func (f *SeriesFile) SeriesIDPartitionID(id tsdb.SeriesID) int
- func (f *SeriesFile) SeriesIDTyped(name []byte, tags models.Tags, buf []byte) tsdb.SeriesIDTyped
- func (f *SeriesFile) SeriesIDTypedBySeriesKey(key []byte) tsdb.SeriesIDTyped
- func (f *SeriesFile) SeriesIDs() []tsdb.SeriesID
- func (f *SeriesFile) SeriesKey(id tsdb.SeriesID) []byte
- func (f *SeriesFile) SeriesKeyName(id tsdb.SeriesID) []byte
- func (f *SeriesFile) SeriesKeyPartition(key []byte) *SeriesPartition
- func (f *SeriesFile) SeriesKeyPartitionID(key []byte) int
- func (f *SeriesFile) SeriesKeys(ids []tsdb.SeriesID) [][]byte
- func (f *SeriesFile) SeriesKeysPartitionIDs(keys [][]byte) []int
- func (f *SeriesFile) SeriesPartitionPath(i int) string
- func (f *SeriesFile) SetDefaultMetricLabels(labels prometheus.Labels)
- func (f *SeriesFile) WithLogger(log *zap.Logger)
- type SeriesIndex
- func (idx *SeriesIndex) Clone() *SeriesIndex
- func (idx *SeriesIndex) Close() (err error)
- func (idx *SeriesIndex) Count() uint64
- func (idx *SeriesIndex) Delete(id tsdb.SeriesID)
- func (idx *SeriesIndex) FindIDByNameTags(segments []*SeriesSegment, name []byte, tags models.Tags, buf []byte) tsdb.SeriesIDTyped
- func (idx *SeriesIndex) FindIDBySeriesKey(segments []*SeriesSegment, key []byte) tsdb.SeriesIDTyped
- func (idx *SeriesIndex) FindIDListByNameTags(segments []*SeriesSegment, names [][]byte, tagsSlice []models.Tags, buf []byte) (ids []tsdb.SeriesIDTyped, ok bool)
- func (idx *SeriesIndex) FindOffsetByID(id tsdb.SeriesID) int64
- func (idx *SeriesIndex) GrowBy(delta int)
- func (idx *SeriesIndex) InMemCount() uint64
- func (idx *SeriesIndex) InMemSize() uint64
- func (idx *SeriesIndex) Insert(key []byte, id tsdb.SeriesIDTyped, offset int64)
- func (idx *SeriesIndex) IsDeleted(id tsdb.SeriesID) bool
- func (idx *SeriesIndex) OnDiskCount() uint64
- func (idx *SeriesIndex) OnDiskSize() uint64
- func (idx *SeriesIndex) Open() (err error)
- func (idx *SeriesIndex) Recover(segments []*SeriesSegment) error
- type SeriesIndexHeader
- type SeriesPartition
- func (p *SeriesPartition) AppendSeriesIDs(a []tsdb.SeriesID) []tsdb.SeriesID
- func (p *SeriesPartition) Close() (err error)
- func (p *SeriesPartition) Compacting() bool
- func (p *SeriesPartition) CreateSeriesListIfNotExists(collection *tsdb.SeriesCollection, keyPartitionIDs []int) error
- func (p *SeriesPartition) DeleteSeriesIDs(ids []tsdb.SeriesID) error
- func (p *SeriesPartition) DisableCompactions()
- func (p *SeriesPartition) DiskSize() uint64
- func (p *SeriesPartition) EnableCompactions()
- func (p *SeriesPartition) FileSize() (n int64, err error)
- func (p *SeriesPartition) FindIDBySeriesKey(key []byte) tsdb.SeriesID
- func (p *SeriesPartition) FindIDTypedBySeriesKey(key []byte) tsdb.SeriesIDTyped
- func (p *SeriesPartition) ID() int
- func (p *SeriesPartition) Index() *SeriesIndex
- func (p *SeriesPartition) IndexPath() string
- func (p *SeriesPartition) IsDeleted(id tsdb.SeriesID) bool
- func (p *SeriesPartition) Open() error
- func (p *SeriesPartition) Path() string
- func (p *SeriesPartition) Segments() []*SeriesSegment
- func (p *SeriesPartition) Series(id tsdb.SeriesID) ([]byte, models.Tags)
- func (p *SeriesPartition) SeriesCount() uint64
- func (p *SeriesPartition) SeriesKey(id tsdb.SeriesID) []byte
- type SeriesPartitionCompactor
- type SeriesSegment
- func (s *SeriesSegment) AppendSeriesIDs(a []tsdb.SeriesID) []tsdb.SeriesID
- func (s *SeriesSegment) CanWrite(data []byte) bool
- func (s *SeriesSegment) Clone() *SeriesSegment
- func (s *SeriesSegment) Close() (err error)
- func (s *SeriesSegment) CloseForWrite() (err error)
- func (s *SeriesSegment) CompactToPath(path string, index *SeriesIndex) error
- func (s *SeriesSegment) Data() []byte
- func (s *SeriesSegment) Flush() error
- func (s *SeriesSegment) ForEachEntry(fn func(flag uint8, id tsdb.SeriesIDTyped, offset int64, key []byte) error) error
- func (s *SeriesSegment) ID() uint16
- func (s *SeriesSegment) InitForWrite() (err error)
- func (s *SeriesSegment) MaxSeriesID() tsdb.SeriesID
- func (s *SeriesSegment) Open() error
- func (s *SeriesSegment) Path() string
- func (s *SeriesSegment) Size() int64
- func (s *SeriesSegment) Slice(pos uint32) []byte
- func (s *SeriesSegment) WriteLogEntry(data []byte) (offset int64, err error)
- type SeriesSegmentHeader
- type Verify
- func (v Verify) VerifyIndex(indexPath string, segments []*SeriesSegment, ids map[uint64]IDData) (valid bool, err error)
- func (v Verify) VerifyPartition(partitionPath string) (valid bool, err error)
- func (v Verify) VerifySegment(segmentPath string, ids map[uint64]IDData) (valid bool, err error)
- func (v Verify) VerifySeriesFile(filePath string) (valid bool, err error)
Constants ¶
const ( SeriesIndexVersion = 1 SeriesIndexMagic = "SIDX" )
const ( // SeriesIDSize is the size in bytes of a series key ID. SeriesIDSize = 8 SeriesOffsetSize = 8 SeriesIndexElemSize = SeriesOffsetSize + SeriesIDSize SeriesIndexLoadFactor = 90 // rhh load factor SeriesIndexHeaderSize = 0 + 4 + 1 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 8 + 0 )
const ( SeriesSegmentVersion = 1 SeriesSegmentMagic = "SSEG" SeriesSegmentHeaderSize = 4 + 1 // magic + version )
const ( SeriesEntryFlagSize = 1 SeriesEntryHeaderSize = 1 + 8 // flag + id SeriesEntryInsertFlag = 0x01 SeriesEntryTombstoneFlag = 0x02 )
Series entry constants.
const ( // DefaultLargeSeriesWriteThreshold is the number of series per write // that requires the series index be pregrown before insert. DefaultLargeSeriesWriteThreshold = 10000 )
const DefaultSeriesPartitionCompactThreshold = 1 << 17 // 128K
DefaultSeriesPartitionCompactThreshold is the number of series IDs to hold in the in-memory series map before compacting and rebuilding the on-disk representation.
const (
// SeriesFilePartitionN is the number of partitions a series file is split into.
SeriesFilePartitionN = 8
)
Variables ¶
var ( ErrSeriesFileClosed = errors.New("tsdb: series file closed") ErrInvalidSeriesPartitionID = errors.New("tsdb: invalid series partition id") )
var ( ErrSeriesPartitionClosed = errors.New("tsdb: series partition closed") ErrSeriesPartitionCompactionCancelled = errors.New("tsdb: series partition compaction cancelled") )
var ( ErrInvalidSeriesSegment = errors.New("invalid series segment") ErrInvalidSeriesSegmentVersion = errors.New("invalid series segment version") ErrSeriesSegmentNotWritable = errors.New("series segment not writable") )
var ErrInvalidSeriesIndex = errors.New("invalid series index")
Functions ¶
func AppendSeriesEntry ¶
func AppendSeriesKey ¶
AppendSeriesKey serializes name and tags to a byte slice. The total length is prepended as a uvarint.
func CompareSeriesKeys ¶
func GenerateSeriesKeys ¶
GenerateSeriesKeys generates series keys for a list of names & tags using a single large memory block.
func IsValidSeriesEntryFlag ¶
IsValidSeriesEntryFlag returns true if flag is valid.
func IsValidSeriesSegmentFilename ¶
IsValidSeriesSegmentFilename returns true if filename is a 4-character lowercase hexadecimal number.
func JoinSeriesOffset ¶
JoinSeriesOffset returns an offset that combines the 2-byte segmentID and 4-byte pos.
func ParseSeriesKey ¶
ParseSeriesKey extracts the name & tags from a series key.
func ParseSeriesKeyInto ¶
ParseSeriesKeyInto extracts the name and tags for data, parsing the tags into dstTags, which is then returened.
The returned dstTags may have a different length and capacity.
func ParseSeriesSegmentFilename ¶
ParseSeriesSegmentFilename returns the id represented by the hexadecimal filename.
func PrometheusCollectors ¶
func PrometheusCollectors() []prometheus.Collector
PrometheusCollectors returns all the metrics associated with the tsdb package.
func ReadSeriesEntry ¶
func ReadSeriesKey ¶
ReadSeriesKey returns the series key from the beginning of the buffer.
func ReadSeriesKeyFromSegments ¶
func ReadSeriesKeyFromSegments(a []*SeriesSegment, offset int64) []byte
ReadSeriesKeyFromSegments returns a series key from an offset within a set of segments.
func ReadSeriesKeyLen ¶
func ReadSeriesKeyTag ¶
func ReadSeriesKeyTagN ¶
func SeriesKeySize ¶
SeriesKeySize returns the number of bytes required to encode a series key.
func SeriesKeysSize ¶
SeriesKeysSize returns the number of bytes required to encode a list of name/tags.
func SeriesSegmentSize ¶
SeriesSegmentSize returns the maximum size of the segment. The size goes up by powers of 2 starting from 4MB and reaching 256MB.
func SplitSeriesOffset ¶
SplitSeriesOffset splits a offset into its 2-byte segmentID and 4-byte pos parts.
Types ¶
type Config ¶
type Config struct { // LargeSeriesWriteThreshold is the threshold before a write requires // preallocation to improve throughput. Currently used in the series file. LargeSeriesWriteThreshold int `toml:"large-series-write-threshold"` }
Config contains all of the configuration related to tsdb.
type SeriesFile ¶
type SeriesFile struct { LargeWriteThreshold int Logger *zap.Logger // contains filtered or unexported fields }
SeriesFile represents the section of the index that holds series data.
func NewSeriesFile ¶
func NewSeriesFile(path string) *SeriesFile
NewSeriesFile returns a new instance of SeriesFile.
func (*SeriesFile) Acquire ¶
func (f *SeriesFile) Acquire() (*lifecycle.Reference, error)
Acquire ensures that the series file won't be closed until after the reference has been released.
func (*SeriesFile) CreateSeriesListIfNotExists ¶
func (f *SeriesFile) CreateSeriesListIfNotExists(collection *tsdb.SeriesCollection) error
CreateSeriesListIfNotExists creates a list of series in bulk if they don't exist. It overwrites the collection's Keys and SeriesIDs fields. The collection's SeriesIDs slice will have IDs for every name+tags, creating new series IDs as needed. If any SeriesID is zero, then a type conflict has occurred for that series.
func (*SeriesFile) DeleteSeriesIDs ¶
func (f *SeriesFile) DeleteSeriesIDs(ids []tsdb.SeriesID) error
DeleteSeriesID flags a list of series as permanently deleted. If a series is reintroduced later then it must create a new id.
func (*SeriesFile) DisableCompactions ¶
func (f *SeriesFile) DisableCompactions()
DisableCompactions prevents new compactions from running.
func (*SeriesFile) DisableMetrics ¶
func (f *SeriesFile) DisableMetrics()
DisableMetrics ensures that activity is not collected via the prometheus metrics. DisableMetrics must be called before Open.
func (*SeriesFile) EnableCompactions ¶
func (f *SeriesFile) EnableCompactions()
EnableCompactions allows compactions to run.
func (*SeriesFile) FileSize ¶
func (f *SeriesFile) FileSize() (n int64, err error)
FileSize returns the size of all partitions, in bytes.
func (*SeriesFile) IsDeleted ¶
func (f *SeriesFile) IsDeleted(id tsdb.SeriesID) bool
IsDeleted returns true if the ID has been deleted before.
func (*SeriesFile) Open ¶
func (f *SeriesFile) Open(ctx context.Context) error
Open memory maps the data file at the file's path.
func (*SeriesFile) Partitions ¶
func (f *SeriesFile) Partitions() []*SeriesPartition
Partitions returns all partitions.
func (*SeriesFile) SeriesCount ¶
func (f *SeriesFile) SeriesCount() uint64
SeriesCount returns the number of series.
func (*SeriesFile) SeriesIDPartition ¶
func (f *SeriesFile) SeriesIDPartition(id tsdb.SeriesID) *SeriesPartition
func (*SeriesFile) SeriesIDPartitionID ¶
func (f *SeriesFile) SeriesIDPartitionID(id tsdb.SeriesID) int
func (*SeriesFile) SeriesIDTyped ¶
func (f *SeriesFile) SeriesIDTyped(name []byte, tags models.Tags, buf []byte) tsdb.SeriesIDTyped
SeriesIDTyped returns the typed series id for the series.
func (*SeriesFile) SeriesIDTypedBySeriesKey ¶
func (f *SeriesFile) SeriesIDTypedBySeriesKey(key []byte) tsdb.SeriesIDTyped
SeriesIDTypedBySeriesKey returns the typed series id for the series.
func (*SeriesFile) SeriesIDs ¶
func (f *SeriesFile) SeriesIDs() []tsdb.SeriesID
SeriesIDs returns a slice of series IDs in all partitions, sorted. This may return a lot of data at once, so use sparingly.
func (*SeriesFile) SeriesKey ¶
func (f *SeriesFile) SeriesKey(id tsdb.SeriesID) []byte
SeriesKey returns the series key for a given id.
func (*SeriesFile) SeriesKeyName ¶
func (f *SeriesFile) SeriesKeyName(id tsdb.SeriesID) []byte
SeriesKeyName returns the measurement name for a series id.
func (*SeriesFile) SeriesKeyPartition ¶
func (f *SeriesFile) SeriesKeyPartition(key []byte) *SeriesPartition
func (*SeriesFile) SeriesKeyPartitionID ¶
func (f *SeriesFile) SeriesKeyPartitionID(key []byte) int
func (*SeriesFile) SeriesKeys ¶
func (f *SeriesFile) SeriesKeys(ids []tsdb.SeriesID) [][]byte
SeriesKeys returns a list of series keys from a list of ids.
func (*SeriesFile) SeriesKeysPartitionIDs ¶
func (f *SeriesFile) SeriesKeysPartitionIDs(keys [][]byte) []int
func (*SeriesFile) SeriesPartitionPath ¶
func (f *SeriesFile) SeriesPartitionPath(i int) string
SeriesPartitionPath returns the path to a given partition.
func (*SeriesFile) SetDefaultMetricLabels ¶
func (f *SeriesFile) SetDefaultMetricLabels(labels prometheus.Labels)
SetDefaultMetricLabels sets the default labels for metrics on the Series File. It must be called before the SeriesFile is opened.
func (*SeriesFile) WithLogger ¶
func (f *SeriesFile) WithLogger(log *zap.Logger)
WithLogger sets the logger on the SeriesFile and all underlying partitions. It must be called before Open.
type SeriesIndex ¶
type SeriesIndex struct {
// contains filtered or unexported fields
}
SeriesIndex represents an index of key-to-id & id-to-offset mappings.
func NewSeriesIndex ¶
func NewSeriesIndex(path string) *SeriesIndex
func (*SeriesIndex) Clone ¶
func (idx *SeriesIndex) Clone() *SeriesIndex
Clone returns a copy of idx for use during compaction. In-memory maps are not cloned.
func (*SeriesIndex) Close ¶
func (idx *SeriesIndex) Close() (err error)
Close unmaps the index file.
func (*SeriesIndex) Count ¶
func (idx *SeriesIndex) Count() uint64
Count returns the number of series in the index.
func (*SeriesIndex) Delete ¶
func (idx *SeriesIndex) Delete(id tsdb.SeriesID)
Delete marks the series id as deleted.
func (*SeriesIndex) FindIDByNameTags ¶
func (idx *SeriesIndex) FindIDByNameTags(segments []*SeriesSegment, name []byte, tags models.Tags, buf []byte) tsdb.SeriesIDTyped
func (*SeriesIndex) FindIDBySeriesKey ¶
func (idx *SeriesIndex) FindIDBySeriesKey(segments []*SeriesSegment, key []byte) tsdb.SeriesIDTyped
func (*SeriesIndex) FindIDListByNameTags ¶
func (idx *SeriesIndex) FindIDListByNameTags(segments []*SeriesSegment, names [][]byte, tagsSlice []models.Tags, buf []byte) (ids []tsdb.SeriesIDTyped, ok bool)
func (*SeriesIndex) FindOffsetByID ¶
func (idx *SeriesIndex) FindOffsetByID(id tsdb.SeriesID) int64
func (*SeriesIndex) GrowBy ¶
func (idx *SeriesIndex) GrowBy(delta int)
GrowBy preallocates the in-memory hashmap to a larger size.
func (*SeriesIndex) InMemCount ¶
func (idx *SeriesIndex) InMemCount() uint64
InMemCount returns the number of series in the in-memory index.
func (*SeriesIndex) InMemSize ¶
func (idx *SeriesIndex) InMemSize() uint64
InMemSize returns the heap size of the index in bytes. The returned value is an estimation and does not include include all allocated memory.
func (*SeriesIndex) Insert ¶
func (idx *SeriesIndex) Insert(key []byte, id tsdb.SeriesIDTyped, offset int64)
func (*SeriesIndex) IsDeleted ¶
func (idx *SeriesIndex) IsDeleted(id tsdb.SeriesID) bool
IsDeleted returns true if series id has been deleted.
func (*SeriesIndex) OnDiskCount ¶
func (idx *SeriesIndex) OnDiskCount() uint64
OnDiskCount returns the number of series in the on-disk index.
func (*SeriesIndex) OnDiskSize ¶
func (idx *SeriesIndex) OnDiskSize() uint64
OnDiskSize returns the on-disk size of the index in bytes.
func (*SeriesIndex) Open ¶
func (idx *SeriesIndex) Open() (err error)
Open memory-maps the index file.
func (*SeriesIndex) Recover ¶
func (idx *SeriesIndex) Recover(segments []*SeriesSegment) error
Recover rebuilds the in-memory index for all new entries.
type SeriesIndexHeader ¶
type SeriesIndexHeader struct { Version uint8 MaxSeriesID tsdb.SeriesID MaxOffset int64 Count uint64 Capacity int64 KeyIDMap struct { Offset int64 Size int64 } IDOffsetMap struct { Offset int64 Size int64 } }
SeriesIndexHeader represents the header of a series index.
func NewSeriesIndexHeader ¶
func NewSeriesIndexHeader() SeriesIndexHeader
NewSeriesIndexHeader returns a new instance of SeriesIndexHeader.
func ReadSeriesIndexHeader ¶
func ReadSeriesIndexHeader(data []byte) (hdr SeriesIndexHeader, err error)
ReadSeriesIndexHeader returns the header from data.
type SeriesPartition ¶
type SeriesPartition struct { CompactThreshold int LargeWriteThreshold int Logger *zap.Logger // contains filtered or unexported fields }
SeriesPartition represents a subset of series file data.
func NewSeriesPartition ¶
func NewSeriesPartition(id int, path string) *SeriesPartition
NewSeriesPartition returns a new instance of SeriesPartition.
func (*SeriesPartition) AppendSeriesIDs ¶
func (p *SeriesPartition) AppendSeriesIDs(a []tsdb.SeriesID) []tsdb.SeriesID
AppendSeriesIDs returns a list of all series ids.
func (*SeriesPartition) Close ¶
func (p *SeriesPartition) Close() (err error)
Close unmaps the data files.
func (*SeriesPartition) Compacting ¶
func (p *SeriesPartition) Compacting() bool
Compacting returns if the SeriesPartition is currently compacting.
func (*SeriesPartition) CreateSeriesListIfNotExists ¶
func (p *SeriesPartition) CreateSeriesListIfNotExists(collection *tsdb.SeriesCollection, keyPartitionIDs []int) error
CreateSeriesListIfNotExists creates a list of series in bulk if they don't exist. The ids parameter is modified to contain series IDs for all keys belonging to this partition. If the type does not match the existing type for the key, a zero id is stored.
func (*SeriesPartition) DeleteSeriesIDs ¶
func (p *SeriesPartition) DeleteSeriesIDs(ids []tsdb.SeriesID) error
DeleteSeriesID flags a list of series as permanently deleted. If a series is reintroduced later then it must create a new id.
func (*SeriesPartition) DisableCompactions ¶
func (p *SeriesPartition) DisableCompactions()
func (*SeriesPartition) DiskSize ¶
func (p *SeriesPartition) DiskSize() uint64
DiskSize returns the number of bytes taken up on disk by the partition.
func (*SeriesPartition) EnableCompactions ¶
func (p *SeriesPartition) EnableCompactions()
func (*SeriesPartition) FileSize ¶
func (p *SeriesPartition) FileSize() (n int64, err error)
FileSize returns the size of all partitions, in bytes.
func (*SeriesPartition) FindIDBySeriesKey ¶
func (p *SeriesPartition) FindIDBySeriesKey(key []byte) tsdb.SeriesID
FindIDBySeriesKey return the series id for the series key.
func (*SeriesPartition) FindIDTypedBySeriesKey ¶
func (p *SeriesPartition) FindIDTypedBySeriesKey(key []byte) tsdb.SeriesIDTyped
FindIDTypedBySeriesKey return the typed series id for the series key.
func (*SeriesPartition) Index ¶
func (p *SeriesPartition) Index() *SeriesIndex
Index returns the partition's index.
func (*SeriesPartition) IndexPath ¶
func (p *SeriesPartition) IndexPath() string
IndexPath returns the path to the series index.
func (*SeriesPartition) IsDeleted ¶
func (p *SeriesPartition) IsDeleted(id tsdb.SeriesID) bool
IsDeleted returns true if the ID has been deleted before.
func (*SeriesPartition) Open ¶
func (p *SeriesPartition) Open() error
Open memory maps the data file at the partition's path.
func (*SeriesPartition) Path ¶
func (p *SeriesPartition) Path() string
Path returns the path to the partition.
func (*SeriesPartition) Segments ¶
func (p *SeriesPartition) Segments() []*SeriesSegment
Segments returns the segments in the partition.
func (*SeriesPartition) SeriesCount ¶
func (p *SeriesPartition) SeriesCount() uint64
SeriesCount returns the number of series.
type SeriesPartitionCompactor ¶
type SeriesPartitionCompactor struct {
// contains filtered or unexported fields
}
SeriesPartitionCompactor represents an object reindexes a series partition and optionally compacts segments.
func NewSeriesPartitionCompactor ¶
func NewSeriesPartitionCompactor() *SeriesPartitionCompactor
NewSeriesPartitionCompactor returns a new instance of SeriesPartitionCompactor.
func (*SeriesPartitionCompactor) Compact ¶
func (c *SeriesPartitionCompactor) Compact(p *SeriesPartition) (time.Duration, error)
Compact rebuilds the series partition index.
type SeriesSegment ¶
type SeriesSegment struct {
// contains filtered or unexported fields
}
SeriesSegment represents a log of series entries.
func CloneSeriesSegments ¶
func CloneSeriesSegments(a []*SeriesSegment) []*SeriesSegment
CloneSeriesSegments returns a copy of a slice of segments.
func CreateSeriesSegment ¶
func CreateSeriesSegment(id uint16, path string) (*SeriesSegment, error)
CreateSeriesSegment generates an empty segment at path.
func FindSegment ¶
func FindSegment(a []*SeriesSegment, id uint16) *SeriesSegment
FindSegment returns a segment by id.
func NewSeriesSegment ¶
func NewSeriesSegment(id uint16, path string) *SeriesSegment
NewSeriesSegment returns a new instance of SeriesSegment.
func (*SeriesSegment) AppendSeriesIDs ¶
func (s *SeriesSegment) AppendSeriesIDs(a []tsdb.SeriesID) []tsdb.SeriesID
AppendSeriesIDs appends all the segments ids to a slice. Returns the new slice.
func (*SeriesSegment) CanWrite ¶
func (s *SeriesSegment) CanWrite(data []byte) bool
CanWrite returns true if segment has space to write entry data.
func (*SeriesSegment) Clone ¶
func (s *SeriesSegment) Clone() *SeriesSegment
Clone returns a copy of the segment. Excludes the write handler, if set.
func (*SeriesSegment) CloseForWrite ¶
func (s *SeriesSegment) CloseForWrite() (err error)
func (*SeriesSegment) CompactToPath ¶
func (s *SeriesSegment) CompactToPath(path string, index *SeriesIndex) error
CompactToPath rewrites the segment to a new file and removes tombstoned entries.
func (*SeriesSegment) Flush ¶
func (s *SeriesSegment) Flush() error
Flush flushes the buffer to disk.
func (*SeriesSegment) ForEachEntry ¶
func (s *SeriesSegment) ForEachEntry(fn func(flag uint8, id tsdb.SeriesIDTyped, offset int64, key []byte) error) error
ForEachEntry executes fn for every entry in the segment.
func (*SeriesSegment) ID ¶
func (s *SeriesSegment) ID() uint16
ID returns the id the segment was initialized with.
func (*SeriesSegment) InitForWrite ¶
func (s *SeriesSegment) InitForWrite() (err error)
InitForWrite initializes a write handle for the segment. This is only used for the last segment in the series file.
func (*SeriesSegment) MaxSeriesID ¶
func (s *SeriesSegment) MaxSeriesID() tsdb.SeriesID
MaxSeriesID returns the highest series id in the segment.
func (*SeriesSegment) Open ¶
func (s *SeriesSegment) Open() error
Open memory maps the data file at the file's path.
func (*SeriesSegment) Path ¶
func (s *SeriesSegment) Path() string
func (*SeriesSegment) Size ¶
func (s *SeriesSegment) Size() int64
Size returns the size of the data in the segment. This is only populated once InitForWrite() is called.
func (*SeriesSegment) Slice ¶
func (s *SeriesSegment) Slice(pos uint32) []byte
Slice returns a byte slice starting at pos.
func (*SeriesSegment) WriteLogEntry ¶
func (s *SeriesSegment) WriteLogEntry(data []byte) (offset int64, err error)
WriteLogEntry writes entry data into the segment. Returns the offset of the beginning of the entry.
type SeriesSegmentHeader ¶
type SeriesSegmentHeader struct {
Version uint8
}
SeriesSegmentHeader represents the header of a series segment.
func NewSeriesSegmentHeader ¶
func NewSeriesSegmentHeader() SeriesSegmentHeader
NewSeriesSegmentHeader returns a new instance of SeriesSegmentHeader.
func ReadSeriesSegmentHeader ¶
func ReadSeriesSegmentHeader(data []byte) (hdr SeriesSegmentHeader, err error)
ReadSeriesSegmentHeader returns the header from data.
type Verify ¶
Verify contains configuration for running verification of series files.
func (Verify) VerifyIndex ¶
func (v Verify) VerifyIndex(indexPath string, segments []*SeriesSegment, ids map[uint64]IDData) (valid bool, err error)
VerifyIndex performs verification on an index in a series file. The error is only returned if there was some fatal problem with operating, not if there was a problem with the partition. The ids map must be built from verifying the passed in segments.
func (Verify) VerifyPartition ¶
VerifyPartition performs verifications on a partition of a series file. The error is only returned if there was some fatal problem with operating, not if there was a problem with the partition.
func (Verify) VerifySegment ¶
VerifySegment performs verifications on a segment of a series file. The error is only returned if there was some fatal problem with operating, not if there was a problem with the partition. The ids map is populated with information about the ids stored in the segment.