Documentation
¶
Overview ¶
Package tsm1 provides a TSDB in the Time Structured Merge tree format.
Index ¶
- Constants
- Variables
- func BlockCount(block []byte) int
- func BlockType(block []byte) (byte, error)
- func BlockTypeToInfluxQLDataType(typ byte) influxql.DataType
- func CountTimestamps(b []byte) int
- func Digest(dir string, w io.WriteCloser) error
- func DigestWithOptions(dir string, opts DigestOptions, w io.WriteCloser) error
- func ErrCacheMemorySizeLimitExceeded(n, limit uint64) error
- func MetricsGroupFromContext(ctx context.Context) *metrics.Group
- func NewContextWithMetricsGroup(ctx context.Context) context.Context
- func NewEngine(id uint64, idx tsdb.Index, database, path string, walPath string, ...) tsdb.Engine
- func NewIndirectIndex() *indirectIndex
- func ParseTSMFileName(name string) (int, int, error)
- func SeriesAndFieldFromCompositeKey(key []byte) ([]byte, []byte)
- func SeriesFieldKey(seriesKey, field string) string
- func SeriesFieldKeyBytes(seriesKey, field string) []byte
- func ZigZagDecode(v uint64) int64
- func ZigZagEncode(x int64) uint64
- type BatchDeleter
- type BatchDeleters
- type BitReader
- type BlockIterator
- type BooleanDecoder
- type BooleanEncoder
- type BooleanValue
- type BooleanValues
- func (a BooleanValues) Deduplicate() BooleanValues
- func (a BooleanValues) Encode(buf []byte) ([]byte, error)
- func (a BooleanValues) Exclude(min, max int64) BooleanValues
- func (a BooleanValues) FindRange(min, max int64) (int, int)
- func (a BooleanValues) Include(min, max int64) BooleanValues
- func (a BooleanValues) Len() int
- func (a BooleanValues) Less(i, j int) bool
- func (a BooleanValues) MaxTime() int64
- func (a BooleanValues) Merge(b BooleanValues) BooleanValues
- func (a BooleanValues) MinTime() int64
- func (a BooleanValues) Size() int
- func (a BooleanValues) Swap(i, j int)
- type Cache
- func (c *Cache) ApplyEntryFn(f func(key []byte, entry *entry) error) error
- func (c *Cache) ClearSnapshot(success bool)
- func (c *Cache) Count() int
- func (c *Cache) Deduplicate()
- func (c *Cache) Delete(keys [][]byte)
- func (c *Cache) DeleteRange(keys [][]byte, min, max int64)
- func (c *Cache) Free()
- func (c *Cache) Keys() [][]byte
- func (c *Cache) MaxSize() uint64
- func (c *Cache) SetMaxSize(size uint64)
- func (c *Cache) Size() uint64
- func (c *Cache) Snapshot() (*Cache, error)
- func (c *Cache) Split(n int) []*Cache
- func (c *Cache) Statistics(tags map[string]string) []models.Statistic
- func (c *Cache) UpdateAge()
- func (c *Cache) UpdateCompactTime(d time.Duration)
- func (c *Cache) Values(key []byte) Values
- func (c *Cache) Write(key []byte, values []Value) error
- func (c *Cache) WriteMulti(values map[string][]Value) error
- type CacheLoader
- type CacheStatistics
- type CompactionGroup
- type CompactionPlanner
- type Compactor
- func (c *Compactor) Close()
- func (c *Compactor) CompactFast(tsmFiles []string) ([]string, error)
- func (c *Compactor) CompactFull(tsmFiles []string) ([]string, error)
- func (c *Compactor) DisableCompactions()
- func (c *Compactor) DisableSnapshots()
- func (c *Compactor) EnableCompactions()
- func (c *Compactor) EnableSnapshots()
- func (c *Compactor) Open()
- func (c *Compactor) WriteSnapshot(cache *Cache) ([]string, error)
- type DefaultPlanner
- func (c *DefaultPlanner) ForceFull()
- func (c *DefaultPlanner) FullyCompacted() bool
- func (c *DefaultPlanner) Plan(lastWrite time.Time) []CompactionGroup
- func (c *DefaultPlanner) PlanLevel(level int) []CompactionGroup
- func (c *DefaultPlanner) PlanOptimize() []CompactionGroup
- func (c *DefaultPlanner) Release(groups []CompactionGroup)
- type DeleteRangeWALEntry
- type DeleteWALEntry
- type DigestOptions
- type DigestReader
- type DigestTimeRange
- type DigestTimeSpan
- type DigestWriter
- type EmptyValue
- type Engine
- func (e *Engine) Backup(w io.Writer, basePath string, since time.Time) error
- func (e *Engine) Close() error
- func (e *Engine) CreateCursor(ctx context.Context, r *tsdb.CursorRequest) (tsdb.Cursor, error)
- func (e *Engine) CreateIterator(ctx context.Context, measurement string, opt query.IteratorOptions) (query.Iterator, error)
- func (e *Engine) CreateSeriesIfNotExists(key, name []byte, tags models.Tags) error
- func (e *Engine) CreateSeriesListIfNotExists(keys, names [][]byte, tagsSlice []models.Tags) error
- func (e *Engine) CreateSnapshot() (string, error)
- func (e *Engine) DeleteMeasurement(name []byte) error
- func (e *Engine) DeleteSeriesRange(itr tsdb.SeriesIterator, min, max int64) error
- func (e *Engine) Digest() (io.ReadCloser, int64, error)
- func (e *Engine) DiskSize() int64
- func (e *Engine) Export(w io.Writer, basePath string, start time.Time, end time.Time) error
- func (e *Engine) ForEachMeasurementName(fn func(name []byte) error) error
- func (e *Engine) Free() error
- func (e *Engine) HasTagKey(name, key []byte) (bool, error)
- func (e *Engine) Import(r io.Reader, basePath string) error
- func (e *Engine) IsIdle() bool
- func (e *Engine) IteratorCost(measurement string, opt query.IteratorOptions) (query.IteratorCost, error)
- func (e *Engine) KeyCursor(ctx context.Context, key []byte, t int64, ascending bool) *KeyCursor
- func (e *Engine) LastModified() time.Time
- func (e *Engine) LoadMetadataIndex(shardID uint64, index tsdb.Index) error
- func (e *Engine) MeasurementExists(name []byte) (bool, error)
- func (e *Engine) MeasurementFieldSet() *tsdb.MeasurementFieldSet
- func (e *Engine) MeasurementFields(measurement []byte) *tsdb.MeasurementFields
- func (e *Engine) MeasurementNamesByRegex(re *regexp.Regexp) ([][]byte, error)
- func (e *Engine) MeasurementTagKeysByExpr(name []byte, expr influxql.Expr) (map[string]struct{}, error)
- func (e *Engine) MeasurementsSketches() (estimator.Sketch, estimator.Sketch, error)
- func (e *Engine) Open() error
- func (e *Engine) Path() string
- func (e *Engine) Restore(r io.Reader, basePath string) error
- func (e *Engine) ScheduleFullCompaction() error
- func (e *Engine) SeriesN() int64
- func (e *Engine) SeriesSketches() (estimator.Sketch, estimator.Sketch, error)
- func (e *Engine) SetCompactionsEnabled(enabled bool)
- func (e *Engine) SetEnabled(enabled bool)
- func (e *Engine) SetFieldName(measurement []byte, name string)
- func (e *Engine) ShouldCompactCache(lastWriteTime time.Time) bool
- func (e *Engine) Statistics(tags map[string]string) []models.Statistic
- func (e *Engine) TagKeyCardinality(name, key []byte) int
- func (e *Engine) WithLogger(log *zap.Logger)
- func (e *Engine) WritePoints(points []models.Point) error
- func (e *Engine) WriteSnapshot() error
- func (e *Engine) WriteTo(w io.Writer) (n int64, err error)
- type EngineStatistics
- type FileStat
- type FileStore
- func (f *FileStore) Apply(fn func(r TSMFile) error) error
- func (f *FileStore) BlockCount(path string, idx int) int
- func (f *FileStore) Close() error
- func (f *FileStore) Cost(key []byte, min, max int64) query.IteratorCost
- func (f *FileStore) Count() int
- func (f *FileStore) CreateSnapshot() (string, error)
- func (f *FileStore) CurrentGeneration() int
- func (f *FileStore) Delete(keys [][]byte) error
- func (f *FileStore) DeleteRange(keys [][]byte, min, max int64) error
- func (f *FileStore) DiskSizeBytes() int64
- func (f *FileStore) Files() []TSMFile
- func (f *FileStore) Free() error
- func (f *FileStore) KeyCursor(ctx context.Context, key []byte, t int64, ascending bool) *KeyCursor
- func (f *FileStore) Keys() map[string]byte
- func (f *FileStore) LastModified() time.Time
- func (f *FileStore) NextGeneration() int
- func (f *FileStore) Open() error
- func (f *FileStore) Read(key []byte, t int64) ([]Value, error)
- func (f *FileStore) Replace(oldFiles, newFiles []string) error
- func (f *FileStore) ReplaceWithCallback(oldFiles, newFiles []string, updatedFn func(r []TSMFile)) error
- func (f *FileStore) Statistics(tags map[string]string) []models.Statistic
- func (f *FileStore) Stats() []FileStat
- func (f *FileStore) TSMReader(path string) *TSMReader
- func (f *FileStore) Type(key []byte) (byte, error)
- func (f *FileStore) WalkKeys(seek []byte, fn func(key []byte, typ byte) error) error
- func (f *FileStore) WithLogger(log *zap.Logger)
- type FileStoreStatistics
- type FloatDecoder
- type FloatEncoder
- type FloatValue
- type FloatValues
- func (a FloatValues) Deduplicate() FloatValues
- func (a FloatValues) Encode(buf []byte) ([]byte, error)
- func (a FloatValues) Exclude(min, max int64) FloatValues
- func (a FloatValues) FindRange(min, max int64) (int, int)
- func (a FloatValues) Include(min, max int64) FloatValues
- func (a FloatValues) Len() int
- func (a FloatValues) Less(i, j int) bool
- func (a FloatValues) MaxTime() int64
- func (a FloatValues) Merge(b FloatValues) FloatValues
- func (a FloatValues) MinTime() int64
- func (a FloatValues) Size() int
- func (a FloatValues) Swap(i, j int)
- type IndexEntry
- type IndexWriter
- type IntegerDecoder
- type IntegerEncoder
- type IntegerValue
- type IntegerValues
- func (a IntegerValues) Deduplicate() IntegerValues
- func (a IntegerValues) Encode(buf []byte) ([]byte, error)
- func (a IntegerValues) Exclude(min, max int64) IntegerValues
- func (a IntegerValues) FindRange(min, max int64) (int, int)
- func (a IntegerValues) Include(min, max int64) IntegerValues
- func (a IntegerValues) Len() int
- func (a IntegerValues) Less(i, j int) bool
- func (a IntegerValues) MaxTime() int64
- func (a IntegerValues) Merge(b IntegerValues) IntegerValues
- func (a IntegerValues) MinTime() int64
- func (a IntegerValues) Size() int
- func (a IntegerValues) Swap(i, j int)
- type KeyCursor
- func (c *KeyCursor) Close()
- func (c *KeyCursor) Next()
- func (c *KeyCursor) ReadBooleanBlock(buf *[]BooleanValue) ([]BooleanValue, error)
- func (c *KeyCursor) ReadFloatBlock(buf *[]FloatValue) ([]FloatValue, error)
- func (c *KeyCursor) ReadIntegerBlock(buf *[]IntegerValue) ([]IntegerValue, error)
- func (c *KeyCursor) ReadStringBlock(buf *[]StringValue) ([]StringValue, error)
- func (c *KeyCursor) ReadUnsignedBlock(buf *[]UnsignedValue) ([]UnsignedValue, error)
- type KeyIterator
- type StringDecoder
- type StringEncoder
- type StringValue
- type StringValues
- func (a StringValues) Deduplicate() StringValues
- func (a StringValues) Encode(buf []byte) ([]byte, error)
- func (a StringValues) Exclude(min, max int64) StringValues
- func (a StringValues) FindRange(min, max int64) (int, int)
- func (a StringValues) Include(min, max int64) StringValues
- func (a StringValues) Len() int
- func (a StringValues) Less(i, j int) bool
- func (a StringValues) MaxTime() int64
- func (a StringValues) Merge(b StringValues) StringValues
- func (a StringValues) MinTime() int64
- func (a StringValues) Size() int
- func (a StringValues) Swap(i, j int)
- type TSMFile
- type TSMIndex
- type TSMReader
- func (r *TSMReader) BatchDelete() BatchDeleter
- func (t *TSMReader) BlockIterator() *BlockIterator
- func (t *TSMReader) Close() error
- func (t *TSMReader) Contains(key []byte) bool
- func (t *TSMReader) ContainsValue(key []byte, ts int64) bool
- func (t *TSMReader) Delete(keys [][]byte) error
- func (t *TSMReader) DeleteRange(keys [][]byte, minTime, maxTime int64) error
- func (t *TSMReader) Entries(key []byte) []IndexEntry
- func (t *TSMReader) Free() error
- func (t *TSMReader) HasTombstones() bool
- func (t *TSMReader) InUse() bool
- func (t *TSMReader) IndexSize() uint32
- func (t *TSMReader) Key(index int, entries *[]IndexEntry) ([]byte, byte, []IndexEntry)
- func (t *TSMReader) KeyAt(idx int) ([]byte, byte)
- func (t *TSMReader) KeyCount() int
- func (t *TSMReader) KeyRange() ([]byte, []byte)
- func (t *TSMReader) LastModified() int64
- func (t *TSMReader) OverlapsKeyRange(min, max []byte) bool
- func (t *TSMReader) OverlapsTimeRange(min, max int64) bool
- func (t *TSMReader) Path() string
- func (t *TSMReader) Read(key []byte, timestamp int64) ([]Value, error)
- func (t *TSMReader) ReadAll(key []byte) ([]Value, error)
- func (t *TSMReader) ReadAt(entry *IndexEntry, vals []Value) ([]Value, error)
- func (t *TSMReader) ReadBooleanBlockAt(entry *IndexEntry, vals *[]BooleanValue) ([]BooleanValue, error)
- func (t *TSMReader) ReadBytes(e *IndexEntry, b []byte) (uint32, []byte, error)
- func (t *TSMReader) ReadEntries(key []byte, entries *[]IndexEntry) []IndexEntry
- func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, vals *[]FloatValue) ([]FloatValue, error)
- func (t *TSMReader) ReadIntegerBlockAt(entry *IndexEntry, vals *[]IntegerValue) ([]IntegerValue, error)
- func (t *TSMReader) ReadStringBlockAt(entry *IndexEntry, vals *[]StringValue) ([]StringValue, error)
- func (t *TSMReader) ReadUnsignedBlockAt(entry *IndexEntry, vals *[]UnsignedValue) ([]UnsignedValue, error)
- func (t *TSMReader) Ref()
- func (t *TSMReader) Remove() error
- func (t *TSMReader) Rename(path string) error
- func (t *TSMReader) Seek(key []byte) int
- func (t *TSMReader) Size() uint32
- func (t *TSMReader) Stats() FileStat
- func (t *TSMReader) TimeRange() (int64, int64)
- func (t *TSMReader) TombstoneFiles() []FileStat
- func (t *TSMReader) TombstoneRange(key []byte) []TimeRange
- func (t *TSMReader) Type(key []byte) (byte, error)
- func (t *TSMReader) Unref()
- type TSMWriter
- type TimeDecoder
- type TimeEncoder
- type TimeRange
- type Tombstone
- type Tombstoner
- func (t *Tombstoner) Add(keys [][]byte) error
- func (t *Tombstoner) AddRange(keys [][]byte, min, max int64) error
- func (t *Tombstoner) Delete() error
- func (t *Tombstoner) Flush() error
- func (t *Tombstoner) HasTombstones() bool
- func (t *Tombstoner) Rollback() error
- func (t *Tombstoner) TombstoneFiles() []FileStat
- func (t *Tombstoner) Walk(fn func(t Tombstone) error) error
- type UnsignedValue
- type UnsignedValues
- func (a UnsignedValues) Deduplicate() UnsignedValues
- func (a UnsignedValues) Encode(buf []byte) ([]byte, error)
- func (a UnsignedValues) Exclude(min, max int64) UnsignedValues
- func (a UnsignedValues) FindRange(min, max int64) (int, int)
- func (a UnsignedValues) Include(min, max int64) UnsignedValues
- func (a UnsignedValues) Len() int
- func (a UnsignedValues) Less(i, j int) bool
- func (a UnsignedValues) MaxTime() int64
- func (a UnsignedValues) Merge(b UnsignedValues) UnsignedValues
- func (a UnsignedValues) MinTime() int64
- func (a UnsignedValues) Size() int
- func (a UnsignedValues) Swap(i, j int)
- type Value
- func DecodeBlock(block []byte, vals []Value) ([]Value, error)
- func NewBooleanValue(t int64, v bool) Value
- func NewFloatValue(t int64, v float64) Value
- func NewIntegerValue(t int64, v int64) Value
- func NewStringValue(t int64, v string) Value
- func NewUnsignedValue(t int64, v uint64) Value
- func NewValue(t int64, value interface{}) Value
- type Values
- func (a Values) Deduplicate() Values
- func (a Values) Encode(buf []byte) ([]byte, error)
- func (a Values) Exclude(min, max int64) Values
- func (a Values) FindRange(min, max int64) (int, int)
- func (a Values) Include(min, max int64) Values
- func (a Values) InfluxQLType() (influxql.DataType, error)
- func (a Values) Len() int
- func (a Values) Less(i, j int) bool
- func (a Values) MaxTime() int64
- func (a Values) Merge(b Values) Values
- func (a Values) MinTime() int64
- func (a Values) Size() int
- func (a Values) Swap(i, j int)
- type WAL
- func (l *WAL) Close() error
- func (l *WAL) CloseSegment() error
- func (l *WAL) ClosedSegments() ([]string, error)
- func (l *WAL) Delete(keys [][]byte) (int, error)
- func (l *WAL) DeleteRange(keys [][]byte, min, max int64) (int, error)
- func (l *WAL) DiskSizeBytes() int64
- func (l *WAL) LastWriteTime() time.Time
- func (l *WAL) Open() error
- func (l *WAL) Path() string
- func (l *WAL) Remove(files []string) error
- func (l *WAL) Statistics(tags map[string]string) []models.Statistic
- func (l *WAL) WithLogger(log *zap.Logger)
- func (l *WAL) WriteMulti(values map[string][]Value) (int, error)
- type WALEntry
- type WALSegmentReader
- type WALSegmentWriter
- type WALStatistics
- type WalEntryType
- type WriteWALEntry
Constants ¶
const ( // CompactionTempExtension is the extension used for temporary files created during compaction. CompactionTempExtension = "tmp" // TSMFileExtension is the extension used for TSM files. TSMFileExtension = "tsm" )
const ( // BlockFloat64 designates a block encodes float64 values. BlockFloat64 = byte(0) // BlockInteger designates a block encodes int64 values. BlockInteger = byte(1) // BlockBoolean designates a block encodes boolean values. BlockBoolean = byte(2) // BlockString designates a block encodes string values. BlockString = byte(3) // BlockUnsigned designates a block encodes uint64 values. BlockUnsigned = byte(4) )
const ( // The extension used to describe temporary snapshot files. TmpTSMFileExtension = "tmp" // The extension used to describe corrupt snapshot files. BadTSMFileExtension = "bad" )
const ( // DefaultSegmentSize of 10MB is the size at which segment files will be rolled over. DefaultSegmentSize = 10 * 1024 * 1024 // WALFileExtension is the file extension we expect for wal segments. WALFileExtension = "wal" // WALFilePrefix is the prefix on all wal segment files. WALFilePrefix = "_" )
const ( // MagicNumber is written as the first 4 bytes of a data file to // identify the file as a tsm1 formatted file MagicNumber uint32 = 0x16D116D1 // Version indicates the version of the TSM file format. Version byte = 1 )
Variables ¶
var ( // ErrWALClosed is returned when attempting to write to a closed WAL file. ErrWALClosed = fmt.Errorf("WAL closed") // ErrWALCorrupt is returned when reading a corrupt WAL entry. ErrWALCorrupt = fmt.Errorf("corrupted WAL entry") )
var ( //ErrNoValues is returned when TSMWriter.WriteIndex is called and there are no values to write. ErrNoValues = fmt.Errorf("no values written") // ErrTSMClosed is returned when performing an operation against a closed TSM file. ErrTSMClosed = fmt.Errorf("tsm file closed") // ErrMaxKeyLengthExceeded is returned when attempting to write a key that is too long. ErrMaxKeyLengthExceeded = fmt.Errorf("max key length exceeded") // ErrMaxBlocksExceeded is returned when attempting to write a block past the allowed number. ErrMaxBlocksExceeded = fmt.Errorf("max blocks exceeded") )
var ErrFileInUse = fmt.Errorf("file still in use")
ErrFileInUse is returned when attempting to remove or close a TSM file that is still being used.
var ( // ErrSnapshotInProgress is returned if a snapshot is attempted while one is already running. ErrSnapshotInProgress = fmt.Errorf("snapshot in progress") )
Functions ¶
func BlockCount ¶ added in v0.10.0
BlockCount returns the number of timestamps encoded in block.
func BlockType ¶ added in v0.9.6
BlockType returns the type of value encoded in a block or an error if the block type is unknown.
func BlockTypeToInfluxQLDataType ¶ added in v1.5.0
func CountTimestamps ¶ added in v0.10.0
func Digest ¶ added in v1.5.0
func Digest(dir string, w io.WriteCloser) error
Digest writes a digest of dir to w of a full shard dir.
func DigestWithOptions ¶ added in v1.5.0
func DigestWithOptions(dir string, opts DigestOptions, w io.WriteCloser) error
DigestWithOptions writes a digest of dir to w using options to filter by time and key range.
func ErrCacheMemorySizeLimitExceeded ¶ added in v1.1.0
ErrCacheMemorySizeLimitExceeded returns an error indicating an operation could not be completed due to exceeding the cache-max-memory-size setting.
func MetricsGroupFromContext ¶ added in v1.5.0
MetricsGroupFromContext returns the tsm1 metrics.Group associated with the context or nil if no group has been assigned.
func NewContextWithMetricsGroup ¶ added in v1.5.0
NewContextWithMetricsGroup creates a new context with a tsm1 metrics.Group for tracking various metrics when accessing TSM data.
func NewEngine ¶
func NewEngine(id uint64, idx tsdb.Index, database, path string, walPath string, sfile *tsdb.SeriesFile, opt tsdb.EngineOptions) tsdb.Engine
NewEngine returns a new instance of Engine.
func NewIndirectIndex ¶
func NewIndirectIndex() *indirectIndex
NewIndirectIndex returns a new indirect index.
func ParseTSMFileName ¶ added in v0.9.6
ParseTSMFileName parses the generation and sequence from a TSM file name.
func SeriesAndFieldFromCompositeKey ¶ added in v1.0.0
SeriesAndFieldFromCompositeKey returns the series key and the field key extracted from the composite key.
func SeriesFieldKey ¶
SeriesFieldKey combine a series key and field name for a unique string to be hashed to a numeric ID.
func SeriesFieldKeyBytes ¶ added in v1.4.0
func ZigZagDecode ¶
ZigZagDecode converts a previously zigzag encoded uint64 back to a int64.
func ZigZagEncode ¶
ZigZagEncode converts a int64 to a uint64 by zig zagging negative and positive values across even and odd numbers. Eg. [0,-1,1,-2] becomes [0, 1, 2, 3].
Types ¶
type BatchDeleter ¶ added in v1.5.0
type BatchDeleters ¶ added in v1.5.0
type BatchDeleters []BatchDeleter
func (BatchDeleters) Commit ¶ added in v1.5.0
func (a BatchDeleters) Commit() error
func (BatchDeleters) DeleteRange ¶ added in v1.5.0
func (a BatchDeleters) DeleteRange(keys [][]byte, min, max int64) error
func (BatchDeleters) Rollback ¶ added in v1.5.0
func (a BatchDeleters) Rollback() error
type BitReader ¶ added in v0.13.0
type BitReader struct {
// contains filtered or unexported fields
}
BitReader reads bits from an io.Reader.
func NewBitReader ¶ added in v0.13.0
NewBitReader returns a new instance of BitReader that reads from data.
func (*BitReader) CanReadBitFast ¶ added in v0.13.0
CanReadBitFast returns true if calling ReadBitFast() is allowed. Fast bit reads are allowed when at least 2 values are in the buffer. This is because it is not required to refilled the buffer and the caller can inline the calls.
func (*BitReader) ReadBitFast ¶ added in v0.13.0
ReadBitFast is an optimized bit read. IMPORTANT: Only allowed if CanReadFastBit() is true!
type BlockIterator ¶ added in v0.10.0
type BlockIterator struct {
// contains filtered or unexported fields
}
BlockIterator allows iterating over each block in a TSM file in order. It provides raw access to the block bytes without decoding them.
func (*BlockIterator) Err ¶ added in v1.4.0
func (b *BlockIterator) Err() error
Err returns any errors encounter during iteration.
func (*BlockIterator) Next ¶ added in v0.10.0
func (b *BlockIterator) Next() bool
Next returns true if there are more blocks to iterate through.
func (*BlockIterator) PeekNext ¶ added in v0.10.0
func (b *BlockIterator) PeekNext() []byte
PeekNext returns the next key to be iterated or an empty string.
type BooleanDecoder ¶ added in v0.11.0
type BooleanDecoder struct {
// contains filtered or unexported fields
}
BooleanDecoder decodes a series of booleans from an in-memory buffer.
func (*BooleanDecoder) Error ¶ added in v0.11.0
func (e *BooleanDecoder) Error() error
Error returns the error encountered during decoding, if one occurred.
func (*BooleanDecoder) Next ¶ added in v0.11.0
func (e *BooleanDecoder) Next() bool
Next returns whether there are any bits remaining in the decoder. It returns false if there was an error decoding. The error is available on the Error method.
func (*BooleanDecoder) Read ¶ added in v0.11.0
func (e *BooleanDecoder) Read() bool
Read returns the next bit from the decoder.
func (*BooleanDecoder) SetBytes ¶ added in v0.13.0
func (e *BooleanDecoder) SetBytes(b []byte)
SetBytes initializes the decoder with a new set of bytes to read from. This must be called before calling any other methods.
type BooleanEncoder ¶ added in v0.11.0
type BooleanEncoder struct {
// contains filtered or unexported fields
}
BooleanEncoder encodes a series of booleans to an in-memory buffer.
func NewBooleanEncoder ¶ added in v0.11.0
func NewBooleanEncoder(sz int) BooleanEncoder
NewBooleanEncoder returns a new instance of BooleanEncoder.
func (*BooleanEncoder) Bytes ¶ added in v0.11.0
func (e *BooleanEncoder) Bytes() ([]byte, error)
Bytes returns a new byte slice containing the encoded booleans from previous calls to Write.
func (*BooleanEncoder) Reset ¶ added in v1.1.0
func (e *BooleanEncoder) Reset()
Reset sets the encoder to its initial state.
func (*BooleanEncoder) Write ¶ added in v0.11.0
func (e *BooleanEncoder) Write(b bool)
Write encodes b to the underlying buffer.
type BooleanValue ¶ added in v0.11.0
type BooleanValue struct {
// contains filtered or unexported fields
}
BooleanValue represents a boolean value.
func DecodeBooleanBlock ¶ added in v0.11.0
func DecodeBooleanBlock(block []byte, a *[]BooleanValue) ([]BooleanValue, error)
DecodeBooleanBlock decodes the boolean block from the byte slice and appends the boolean values to a.
func (BooleanValue) Size ¶ added in v0.11.0
func (v BooleanValue) Size() int
Size returns the number of bytes necessary to represent the value and its timestamp.
func (BooleanValue) String ¶ added in v0.11.0
func (v BooleanValue) String() string
String returns the string representation of the value and its timestamp.
func (BooleanValue) UnixNano ¶ added in v0.11.0
func (v BooleanValue) UnixNano() int64
UnixNano returns the timestamp of the value in nanoseconds since unix epoch.
func (BooleanValue) Value ¶ added in v0.11.0
func (v BooleanValue) Value() interface{}
Value returns the underlying boolean value.
type BooleanValues ¶ added in v0.11.0
type BooleanValues []BooleanValue
BooleanValues represents a slice of Boolean values.
func (BooleanValues) Deduplicate ¶ added in v0.11.0
func (a BooleanValues) Deduplicate() BooleanValues
Deduplicate returns a new slice with any values that have the same timestamp removed. The Value that appears last in the slice is the one that is kept. The returned Values are sorted if necessary.
func (BooleanValues) Encode ¶ added in v1.2.3
func (a BooleanValues) Encode(buf []byte) ([]byte, error)
func (BooleanValues) Exclude ¶ added in v1.0.0
func (a BooleanValues) Exclude(min, max int64) BooleanValues
Exclude returns the subset of values not in [min, max]. The values must be deduplicated and sorted before calling Exclude or the results are undefined.
func (BooleanValues) FindRange ¶ added in v1.4.0
func (a BooleanValues) FindRange(min, max int64) (int, int)
FindRange returns the positions where min and max would be inserted into the array. If a[0].UnixNano() > max or a[len-1].UnixNano() < min then FindRange returns (-1, -1) indicating the array is outside the [min, max]. The values must be deduplicated and sorted before calling Exclude or the results are undefined.
func (BooleanValues) Include ¶ added in v1.0.0
func (a BooleanValues) Include(min, max int64) BooleanValues
Include returns the subset values between min and max inclusive. The values must be deduplicated and sorted before calling Exclude or the results are undefined.
func (BooleanValues) Less ¶ added in v0.11.0
func (a BooleanValues) Less(i, j int) bool
func (BooleanValues) MaxTime ¶ added in v1.0.0
func (a BooleanValues) MaxTime() int64
func (BooleanValues) Merge ¶ added in v1.0.0
func (a BooleanValues) Merge(b BooleanValues) BooleanValues
Merge overlays b to top of a. If two values conflict with the same timestamp, b is used. Both a and b must be sorted in ascending order.
func (BooleanValues) MinTime ¶ added in v1.0.0
func (a BooleanValues) MinTime() int64
func (BooleanValues) Size ¶ added in v1.0.0
func (a BooleanValues) Size() int
func (BooleanValues) Swap ¶ added in v0.11.0
func (a BooleanValues) Swap(i, j int)
type Cache ¶ added in v0.9.6
type Cache struct {
// contains filtered or unexported fields
}
Cache maintains an in-memory store of Values for a set of keys.
func NewCache ¶ added in v0.9.6
NewCache returns an instance of a cache which will use a maximum of maxSize bytes of memory. Only used for engine caches, never for snapshots.
func (*Cache) ApplyEntryFn ¶ added in v1.2.0
ApplyEntryFn applies the function f to each entry in the Cache. ApplyEntryFn calls f on each entry in turn, within the same goroutine. It is safe for use by multiple goroutines.
func (*Cache) ClearSnapshot ¶ added in v0.9.6
ClearSnapshot removes the snapshot cache from the list of flushing caches and adjusts the size.
func (*Cache) Deduplicate ¶ added in v0.10.0
func (c *Cache) Deduplicate()
Deduplicate sorts the snapshot before returning it. The compactor and any queries coming in while it writes will need the values sorted.
func (*Cache) DeleteRange ¶ added in v0.13.0
DeleteRange removes the values for all keys containing points with timestamps between between min and max from the cache.
TODO(edd): Lock usage could possibly be optimised if necessary.
func (*Cache) Free ¶ added in v1.3.6
func (c *Cache) Free()
Free releases the underlying store and memory held by the Cache.
func (*Cache) Keys ¶ added in v0.9.6
Keys returns a sorted slice of all keys under management by the cache.
func (*Cache) MaxSize ¶ added in v0.9.6
MaxSize returns the maximum number of bytes the cache may consume.
func (*Cache) SetMaxSize ¶ added in v0.13.0
SetMaxSize updates the memory limit of the cache.
func (*Cache) Size ¶ added in v0.9.6
Size returns the number of point-calcuated bytes the cache currently uses.
func (*Cache) Snapshot ¶ added in v0.9.6
Snapshot takes a snapshot of the current cache, adds it to the slice of caches that are being flushed, and resets the current cache with new values.
func (*Cache) Statistics ¶ added in v1.0.0
Statistics returns statistics for periodic monitoring.
func (*Cache) UpdateAge ¶ added in v0.11.0
func (c *Cache) UpdateAge()
UpdateAge updates the age statistic based on the current time.
func (*Cache) UpdateCompactTime ¶ added in v0.11.0
UpdateCompactTime updates WAL compaction time statistic based on d.
func (*Cache) Values ¶ added in v0.9.6
Values returns a copy of all values, deduped and sorted, for the given key.
func (*Cache) Write ¶ added in v0.9.6
Write writes the set of values for the key to the cache. This function is goroutine-safe. It returns an error if the cache will exceed its max size by adding the new values.
func (*Cache) WriteMulti ¶ added in v0.9.6
WriteMulti writes the map of keys and associated values to the cache. This function is goroutine-safe. It returns an error if the cache will exceeded its max size by adding the new values. The write attempts to write as many values as possible. If one key fails, the others can still succeed and an error will be returned.
type CacheLoader ¶ added in v0.9.6
CacheLoader processes a set of WAL segment files, and loads a cache with the data contained within those files. Processing of the supplied files take place in the order they exist in the files slice.
func NewCacheLoader ¶ added in v0.9.6
func NewCacheLoader(files []string) *CacheLoader
NewCacheLoader returns a new instance of a CacheLoader.
func (*CacheLoader) Load ¶ added in v0.9.6
func (cl *CacheLoader) Load(cache *Cache) error
Load returns a cache loaded with the data contained within the segment files. If, during reading of a segment file, corruption is encountered, that segment file is truncated up to and including the last valid byte, and processing continues with the next segment file.
func (*CacheLoader) WithLogger ¶ added in v1.2.0
func (cl *CacheLoader) WithLogger(log *zap.Logger)
WithLogger sets the logger on the CacheLoader.
type CacheStatistics ¶ added in v1.0.0
type CacheStatistics struct {
MemSizeBytes int64
DiskSizeBytes int64
SnapshotCount int64
CacheAgeMs int64
CachedBytes int64
WALCompactionTimeMs int64
WriteOK int64
WriteErr int64
WriteDropped int64
}
CacheStatistics hold statistics related to the cache.
type CompactionGroup ¶ added in v0.10.0
type CompactionGroup []string
CompactionGroup represents a list of files eligible to be compacted together.
type CompactionPlanner ¶ added in v0.9.6
type CompactionPlanner interface {
Plan(lastWrite time.Time) []CompactionGroup
PlanLevel(level int) []CompactionGroup
PlanOptimize() []CompactionGroup
Release(group []CompactionGroup)
FullyCompacted() bool
// ForceFull causes the planner to return a full compaction plan the next
// time Plan() is called if there are files that could be compacted.
ForceFull()
}
CompactionPlanner determines what TSM files and WAL segments to include in a given compaction run.
type Compactor ¶ added in v0.9.6
type Compactor struct {
Dir string
Size int
FileStore interface {
NextGeneration() int
TSMReader(path string) *TSMReader
}
// RateLimit is the limit for disk writes for all concurrent compactions.
RateLimit limiter.Rate
// contains filtered or unexported fields
}
Compactor merges multiple TSM files into new files or writes a Cache into 1 or more TSM files.