Documentation ¶
Index ¶
- Constants
- Variables
- func BlockCount(block []byte) int
- func BlockType(block []byte) (byte, error)
- func CountTimestamps(b []byte) int
- func NewEngine(path string, walPath string, opt tsdb.EngineOptions) tsdb.Engine
- func NewIndirectIndex() *indirectIndex
- func NewMultiFieldCursor(fields []string, cursors []tsdb.Cursor, ascending bool) tsdb.Cursor
- func ParseTSMFileName(name string) (int, int, error)
- func SeriesFieldKey(seriesKey, field string) string
- func ZigZagDecode(v uint64) int64
- func ZigZagEncode(x int64) uint64
- type BitReader
- type BlockIterator
- type BooleanDecoder
- type BooleanEncoder
- type BooleanValue
- type BooleanValues
- func (a BooleanValues) Deduplicate() BooleanValues
- func (a BooleanValues) Exclude(min, max int64) BooleanValues
- 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) ClearSnapshot(success bool)
- func (c *Cache) Deduplicate()
- func (c *Cache) Delete(keys []string)
- func (c *Cache) DeleteRange(keys []string, min, max int64)
- func (c *Cache) Keys() []string
- func (c *Cache) MaxSize() uint64
- func (c *Cache) RLock()
- func (c *Cache) RUnlock()
- func (c *Cache) SetMaxSize(size uint64)
- func (c *Cache) Size() uint64
- func (c *Cache) Snapshot() (*Cache, error)
- func (c *Cache) Store() map[string]*entry
- func (c *Cache) UpdateAge()
- func (c *Cache) UpdateCompactTime(d time.Duration)
- func (c *Cache) Values(key string) Values
- func (c *Cache) Write(key string, values []Value) error
- func (c *Cache) WriteMulti(values map[string][]Value) error
- type CacheLoader
- type CompactionGroup
- type CompactionPlanner
- type Compactor
- type DefaultPlanner
- type DeleteRangeWALEntry
- type DeleteWALEntry
- 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) ContainsSeries(keys []string) (map[string]bool, error)
- func (e *Engine) CreateIterator(opt influxql.IteratorOptions) (influxql.Iterator, error)
- func (e *Engine) CreateSnapshot() (string, error)
- func (e *Engine) DeleteMeasurement(name string, seriesKeys []string) error
- func (e *Engine) DeleteSeries(seriesKeys []string) error
- func (e *Engine) DeleteSeriesRange(seriesKeys []string, min, max int64) error
- func (e *Engine) Format() tsdb.EngineFormat
- func (e *Engine) Index() *tsdb.DatabaseIndex
- func (e *Engine) KeyCursor(key string, t int64, ascending bool) *KeyCursor
- func (e *Engine) LoadMetadataIndex(shardID uint64, index *tsdb.DatabaseIndex) error
- func (e *Engine) MeasurementFields(measurement string) *tsdb.MeasurementFields
- func (e *Engine) Open() error
- func (e *Engine) Path() string
- func (e *Engine) Restore(r io.Reader, basePath string) error
- func (e *Engine) SeriesCount() (n int, err error)
- func (e *Engine) SetCompactionsEnabled(enabled bool)
- func (e *Engine) SetEnabled(enabled bool)
- func (e *Engine) SetLogOutput(w io.Writer)
- func (e *Engine) ShouldCompactCache(lastWriteTime time.Time) bool
- 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 FileStat
- type FileStore
- func (f *FileStore) Add(files ...TSMFile)
- func (f *FileStore) BlockCount(path string, idx int) int
- func (f *FileStore) Close() error
- func (f *FileStore) Count() int
- func (f *FileStore) CreateSnapshot() (string, error)
- func (f *FileStore) CurrentGeneration() int
- func (f *FileStore) Delete(keys []string) error
- func (f *FileStore) DeleteRange(keys []string, min, max int64) error
- func (f *FileStore) Files() []TSMFile
- func (f *FileStore) KeyCursor(key string, 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 string, t int64) ([]Value, error)
- func (f *FileStore) Remove(paths ...string)
- func (f *FileStore) Replace(oldFiles, newFiles []string) error
- func (f *FileStore) SetLogOutput(w io.Writer)
- func (f *FileStore) Stats() []FileStat
- func (f *FileStore) Type(key string) (byte, error)
- func (f *FileStore) WalkKeys(fn func(key string, typ byte) error) error
- type FloatDecoder
- type FloatEncoder
- type FloatValue
- type FloatValues
- func (a FloatValues) Deduplicate() FloatValues
- func (a FloatValues) Exclude(min, max int64) FloatValues
- 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) Exclude(min, max int64) IntegerValues
- 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(tdec *TimeDecoder, vdec *BooleanDecoder, buf *[]BooleanValue) ([]BooleanValue, error)
- func (c *KeyCursor) ReadFloatBlock(tdec *TimeDecoder, vdec *FloatDecoder, buf *[]FloatValue) ([]FloatValue, error)
- func (c *KeyCursor) ReadIntegerBlock(tdec *TimeDecoder, vdec *IntegerDecoder, buf *[]IntegerValue) ([]IntegerValue, error)
- func (c *KeyCursor) ReadStringBlock(tdec *TimeDecoder, vdec *StringDecoder, buf *[]StringValue) ([]StringValue, error)
- type KeyIterator
- type SegmentInfo
- type StringDecoder
- type StringEncoder
- type StringValue
- type StringValues
- func (a StringValues) Deduplicate() StringValues
- func (a StringValues) Exclude(min, max int64) StringValues
- 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 (t *TSMReader) BlockIterator() *BlockIterator
- func (t *TSMReader) Close() error
- func (t *TSMReader) Contains(key string) bool
- func (t *TSMReader) ContainsValue(key string, ts int64) bool
- func (t *TSMReader) Delete(keys []string) error
- func (t *TSMReader) DeleteRange(keys []string, minTime, maxTime int64) error
- func (t *TSMReader) Entries(key string) []IndexEntry
- func (t *TSMReader) HasTombstones() bool
- func (t *TSMReader) IndexSize() uint32
- func (t *TSMReader) Key(index int) (string, []IndexEntry)
- func (t *TSMReader) KeyAt(idx int) (string, byte)
- func (t *TSMReader) KeyCount() int
- func (t *TSMReader) KeyRange() (string, string)
- func (t *TSMReader) LastModified() int64
- func (t *TSMReader) Path() string
- func (t *TSMReader) Read(key string, timestamp int64) ([]Value, error)
- func (t *TSMReader) ReadAll(key string) ([]Value, error)
- func (t *TSMReader) ReadAt(entry *IndexEntry, vals []Value) ([]Value, error)
- func (t *TSMReader) ReadBooleanBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, ...) ([]BooleanValue, error)
- func (t *TSMReader) ReadEntries(key string, entries *[]IndexEntry)
- func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, vals *[]FloatValue) ([]FloatValue, error)
- func (t *TSMReader) ReadIntegerBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, ...) ([]IntegerValue, error)
- func (t *TSMReader) ReadStringBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, vals *[]StringValue) ([]StringValue, error)
- func (t *TSMReader) Remove() error
- 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 string) []TimeRange
- func (t *TSMReader) Type(key string) (byte, error)
- type TSMWriter
- type TimeDecoder
- type TimeEncoder
- type TimeRange
- type Tombstone
- type Tombstoner
- type 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) 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 []string) (int, error)
- func (l *WAL) DeleteRange(keys []string, min, max int64) (int, error)
- 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) SetLogOutput(w io.Writer)
- func (l *WAL) WritePoints(values map[string][]Value) (int, error)
- type WALEntry
- type WALSegmentReader
- type WALSegmentWriter
- type WalEntryType
- type WriteWALEntry
Constants ¶
const ( CompactionTempExtension = "tmp" 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) )
const ( // DefaultSegmentSize of 10MB is the size at which segment files will be rolled over DefaultSegmentSize = 10 * 1024 * 1024 // FileExtension is the file extension we expect for wal segments WALFileExtension = "wal" 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 byte = 1 )
Variables ¶
var ( ErrCacheMemoryExceeded = fmt.Errorf("cache maximum memory size exceeded") ErrCacheInvalidCheckpoint = fmt.Errorf("invalid checkpoint") ErrSnapshotInProgress = fmt.Errorf("snapshot in progress") )
var ( ErrWALClosed = fmt.Errorf("WAL closed") ErrWALCorrupt = fmt.Errorf("corrupted WAL entry") )
Functions ¶
func BlockCount ¶
func BlockType ¶
BlockType returns the type of value encoded in a block or an error if the block type is unknown.
func CountTimestamps ¶
func NewIndirectIndex ¶
func NewIndirectIndex() *indirectIndex
func NewMultiFieldCursor ¶
NewMultiFieldCursor returns an instance of Cursor that joins the results of cursors.
func ParseTSMFileName ¶
ParseTSMFileName parses the generation and sequence from a TSM file name.
func SeriesFieldKey ¶
SeriesFieldKey combine a series key and field name for a unique string to be hashed to a numeric ID
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 BitReader ¶
type BitReader struct {
// contains filtered or unexported fields
}
BitReader reads bits from an io.Reader.
func NewBitReader ¶
NewBitReader returns a new instance of BitReader that reads from data.
func (*BitReader) CanReadBitFast ¶
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 ¶
ReadBitFast is an optimized bit read. IMPORTANT: Only allowed if CanReadFastBit() is true!
type BlockIterator ¶
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) Next ¶
func (b *BlockIterator) Next() bool
func (*BlockIterator) PeekNext ¶
func (b *BlockIterator) PeekNext() string
type BooleanDecoder ¶
type BooleanDecoder struct {
// contains filtered or unexported fields
}
BooleanDecoder decodes a series of booleans from an in-memory buffer.
func (*BooleanDecoder) Error ¶
func (e *BooleanDecoder) Error() error
func (*BooleanDecoder) Next ¶
func (e *BooleanDecoder) Next() bool
func (*BooleanDecoder) Read ¶
func (e *BooleanDecoder) Read() bool
func (*BooleanDecoder) SetBytes ¶
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 ¶
type BooleanEncoder struct {
// contains filtered or unexported fields
}
BooleanEncoder encodes a series of booleans to an in-memory buffer.
func NewBooleanEncoder ¶
func NewBooleanEncoder() BooleanEncoder
NewBooleanEncoder returns a new instance of BooleanEncoder.
func (*BooleanEncoder) Bytes ¶
func (e *BooleanEncoder) Bytes() ([]byte, error)
func (*BooleanEncoder) Write ¶
func (e *BooleanEncoder) Write(b bool)
type BooleanValue ¶
type BooleanValue struct {
// contains filtered or unexported fields
}
func DecodeBooleanBlock ¶
func DecodeBooleanBlock(block []byte, tdec *TimeDecoder, vdec *BooleanDecoder, a *[]BooleanValue) ([]BooleanValue, error)
func (*BooleanValue) Size ¶
func (b *BooleanValue) Size() int
func (*BooleanValue) String ¶
func (f *BooleanValue) String() string
func (*BooleanValue) UnixNano ¶
func (b *BooleanValue) UnixNano() int64
func (*BooleanValue) Value ¶
func (b *BooleanValue) Value() interface{}
type BooleanValues ¶
type BooleanValues []BooleanValue
BooleanValues represents a slice of Boolean values.
func (BooleanValues) Deduplicate ¶
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.
func (BooleanValues) Exclude ¶
func (a BooleanValues) Exclude(min, max int64) BooleanValues
Exclude returns the subset of values not in [min, max]
func (BooleanValues) Include ¶
func (a BooleanValues) Include(min, max int64) BooleanValues
Include returns the subset values between min and max inclusive.
func (BooleanValues) Less ¶
func (a BooleanValues) Less(i, j int) bool
func (BooleanValues) MaxTime ¶
func (a BooleanValues) MaxTime() int64
func (BooleanValues) Merge ¶
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 ¶
func (a BooleanValues) MinTime() int64
func (BooleanValues) Size ¶
func (a BooleanValues) Size() int
func (BooleanValues) Swap ¶
func (a BooleanValues) Swap(i, j int)
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache maintains an in-memory store of Values for a set of keys.
func NewCache ¶
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) ClearSnapshot ¶
ClearSnapshot will remove the snapshot cache from the list of flushing caches and adjust the size
func (*Cache) Deduplicate ¶
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 ¶
DeleteRange will remove the values for all keys containing points between min and max from the cache.
func (*Cache) SetMaxSize ¶
func (*Cache) Snapshot ¶
Snapshot will take a snapshot of the current cache, add it to the slice of caches that are being flushed, and reset the current cache with new values
func (*Cache) Store ¶
Store returns the underlying cache store. This is not goroutine safe! Protect access by using the Lock and Unlock functions on Cache.
func (*Cache) UpdateCompactTime ¶
Updates WAL compaction time statistic
type CacheLoader ¶
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 ¶
func NewCacheLoader(files []string) *CacheLoader
NewCacheLoader returns a new instance of a CacheLoader.
func (*CacheLoader) Load ¶
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) SetLogOutput ¶
func (cl *CacheLoader) SetLogOutput(w io.Writer)
SetLogOutput sets the logger used for all messages. It must not be called after the Open method has been called.
type CompactionGroup ¶
type CompactionGroup []string
type CompactionPlanner ¶
type CompactionPlanner interface { Plan(lastWrite time.Time) []CompactionGroup PlanLevel(level int) []CompactionGroup }
CompactionPlanner determines what TSM files and WAL segments to include in a given compaction run.
type Compactor ¶
type Compactor struct { Dir string Size int FileStore interface { NextGeneration() int } // contains filtered or unexported fields }
Compactor merges multiple TSM files into new files or writes a Cache into 1 or more TSM files
func (*Compactor) CompactFast ¶
Compact will write multiple smaller TSM files into 1 or more larger files
func (*Compactor) CompactFull ¶
Compact will write multiple smaller TSM files into 1 or more larger files
type DefaultPlanner ¶
type DefaultPlanner struct { FileStore interface { Stats() []FileStat LastModified() time.Time BlockCount(path string, idx int) int } // CompactFullWriteColdDuration specifies the length of time after // which if no writes have been committed to the WAL, the engine will // do a full compaction of the TSM files in this shard. This duration // should always be greater than the CacheFlushWriteColdDuraion CompactFullWriteColdDuration time.Duration // contains filtered or unexported fields }
DefaultPlanner implements CompactionPlanner using a strategy to roll up multiple generations of TSM files into larger files in stages. It attempts to minimize the number of TSM files on disk while rolling up a bounder number of files.
func (*DefaultPlanner) Plan ¶
func (c *DefaultPlanner) Plan(lastWrite time.Time) []CompactionGroup
Plan returns a set of TSM files to rewrite for level 4 or higher. The planning returns multiple groups if possible to allow compactions to run concurrently.
func (*DefaultPlanner) PlanLevel ¶
func (c *DefaultPlanner) PlanLevel(level int) []CompactionGroup
PlanLevel returns a set of TSM files to rewrite for a specific level
type DeleteRangeWALEntry ¶
DeleteRangeWALEntry represents the deletion of multiple series.
func (*DeleteRangeWALEntry) MarshalBinary ¶
func (w *DeleteRangeWALEntry) MarshalBinary() ([]byte, error)
func (*DeleteRangeWALEntry) Type ¶
func (w *DeleteRangeWALEntry) Type() WalEntryType
func (*DeleteRangeWALEntry) UnmarshalBinary ¶
func (w *DeleteRangeWALEntry) UnmarshalBinary(b []byte) error
type DeleteWALEntry ¶
type DeleteWALEntry struct {
Keys []string
}
DeleteWALEntry represents the deletion of multiple series.
func (*DeleteWALEntry) MarshalBinary ¶
func (w *DeleteWALEntry) MarshalBinary() ([]byte, error)
func (*DeleteWALEntry) Type ¶
func (w *DeleteWALEntry) Type() WalEntryType
func (*DeleteWALEntry) UnmarshalBinary ¶
func (w *DeleteWALEntry) UnmarshalBinary(b []byte) error
type EmptyValue ¶
type EmptyValue struct { }
func (*EmptyValue) Size ¶
func (e *EmptyValue) Size() int
func (*EmptyValue) String ¶
func (e *EmptyValue) String() string
func (*EmptyValue) UnixNano ¶
func (e *EmptyValue) UnixNano() int64
func (*EmptyValue) Value ¶
func (e *EmptyValue) Value() interface{}
type Engine ¶
type Engine struct { WAL *WAL Cache *Cache Compactor *Compactor CompactionPlan CompactionPlanner FileStore *FileStore MaxPointsPerBlock int // CacheFlushMemorySizeThreshold specifies the minimum size threshodl for // the cache when the engine should write a snapshot to a TSM file CacheFlushMemorySizeThreshold uint64 // CacheFlushWriteColdDuration specifies the length of time after which if // no writes have been committed to the WAL, the engine will write // a snapshot of the cache to a TSM file CacheFlushWriteColdDuration time.Duration // contains filtered or unexported fields }
Engine represents a storage engine with compressed blocks.
func (*Engine) Backup ¶
Backup will write a tar archive of any TSM files modified since the passed in time to the passed in writer. The basePath will be prepended to the names of the files in the archive. It will force a snapshot of the WAL first then perform the backup with a read lock against the file store. This means that new TSM files will not be able to be created in this shard while the backup is running. For shards that are still acively getting writes, this could cause the WAL to backup, increasing memory usage and evenutally rejecting writes.
func (*Engine) ContainsSeries ¶
ContainsSeries returns a map of keys indicating whether the key exists and has values or not.
func (*Engine) CreateIterator ¶
func (*Engine) CreateSnapshot ¶
CreateSnapshot will create a temp directory that holds temporary hardlinks to the underylyng shard files
func (*Engine) DeleteMeasurement ¶
DeleteMeasurement deletes a measurement and all related series.
func (*Engine) DeleteSeries ¶
DeleteSeries removes all series keys from the engine.
func (*Engine) DeleteSeriesRange ¶
DeleteSeriesRange removes the values between min and max (inclusive) from all series.
func (*Engine) Format ¶
func (e *Engine) Format() tsdb.EngineFormat
Format returns the format type of this engine
func (*Engine) Index ¶
func (e *Engine) Index() *tsdb.DatabaseIndex
Index returns the database index.
func (*Engine) LoadMetadataIndex ¶
func (e *Engine) LoadMetadataIndex(shardID uint64, index *tsdb.DatabaseIndex) error
LoadMetadataIndex loads the shard metadata into memory.
func (*Engine) MeasurementFields ¶
func (e *Engine) MeasurementFields(measurement string) *tsdb.MeasurementFields
MeasurementFields returns the measurement fields for a measurement.
func (*Engine) Restore ¶
Restore will read a tar archive generated by Backup(). Only files that match basePath will be copied into the directory. This obtains a write lock so no operations can be performed while restoring.
func (*Engine) SeriesCount ¶
SeriesCount returns the number of series buckets on the shard.
func (*Engine) SetCompactionsEnabled ¶
SetCompactionsEnabled enables compactions on the engine. When disabled all running compactions are aborted and new compactions stop running.
func (*Engine) SetEnabled ¶
func (*Engine) SetLogOutput ¶
SetLogOutput sets the logger used for all messages. It must not be called after the Open method has been called.
func (*Engine) ShouldCompactCache ¶
ShouldCompactCache returns true if the Cache is over its flush threshold or if the passed in lastWriteTime is older than the write cold threshold
func (*Engine) WritePoints ¶
WritePoints writes metadata and point data into the engine. Returns an error if new points are added to an existing key.
func (*Engine) WriteSnapshot ¶
WriteSnapshot will snapshot the cache and write a new TSM file with its contents, releasing the snapshot when done.
type FileStat ¶
type FileStat struct { Path string HasTombstone bool Size uint32 LastModified int64 MinTime, MaxTime int64 MinKey, MaxKey string }
func (FileStat) ContainsKey ¶
func (FileStat) OverlapsKeyRange ¶
func (FileStat) OverlapsTimeRange ¶
type FileStore ¶
func NewFileStore ¶
func (*FileStore) BlockCount ¶
BlockCount returns number of values stored in the block at location idx in the file at path. If path does not match any file in the store, 0 is returned. If idx is out of range for the number of blocks in the file, 0 is returned.
func (*FileStore) CreateSnapshot ¶
CreateSnapshot will create hardlinks for all tsm and tombstone files in the path provided
func (*FileStore) CurrentGeneration ¶
CurrentGeneration returns the current generation of the TSM files
func (*FileStore) DeleteRange ¶
DeleteRange removes the values for keys between min and max.
func (*FileStore) LastModified ¶
LastModified returns the last time the file store was updated with new TSM files or a delete
func (*FileStore) NextGeneration ¶
NextGeneration returns the max file ID + 1
func (*FileStore) Remove ¶
Remove removes the files with matching paths from the set of active files. It does not remove the paths from disk.
func (*FileStore) SetLogOutput ¶
SetLogOutput sets the logger used for all messages. It must not be called after the Open method has been called.
type FloatDecoder ¶
type FloatDecoder struct {
// contains filtered or unexported fields
}
FloatDecoder decodes a byte slice into multipe float64 values
func (*FloatDecoder) Error ¶
func (it *FloatDecoder) Error() error
func (*FloatDecoder) Next ¶
func (it *FloatDecoder) Next() bool
func (*FloatDecoder) SetBytes ¶
func (it *FloatDecoder) SetBytes(b []byte) error
SetBytes initializes the decoder with b. Must call before calling Next().
func (*FloatDecoder) Values ¶
func (it *FloatDecoder) Values() float64
type FloatEncoder ¶
type FloatEncoder struct {
// contains filtered or unexported fields
}
FloatEncoder encodes multiple float64s into a byte slice
func NewFloatEncoder ¶
func NewFloatEncoder() *FloatEncoder
func (*FloatEncoder) Bytes ¶
func (s *FloatEncoder) Bytes() ([]byte, error)
func (*FloatEncoder) Finish ¶
func (s *FloatEncoder) Finish()
func (*FloatEncoder) Push ¶
func (s *FloatEncoder) Push(v float64)
type FloatValue ¶
type FloatValue struct {
// contains filtered or unexported fields
}
func DecodeFloatBlock ¶
func DecodeFloatBlock(block []byte, tdec *TimeDecoder, vdec *FloatDecoder, a *[]FloatValue) ([]FloatValue, error)
func (*FloatValue) Size ¶
func (f *FloatValue) Size() int
func (*FloatValue) String ¶
func (f *FloatValue) String() string
func (*FloatValue) UnixNano ¶
func (f *FloatValue) UnixNano() int64
func (*FloatValue) Value ¶
func (f *FloatValue) Value() interface{}
type FloatValues ¶
type FloatValues []FloatValue
FloatValues represents a slice of Float values.
func (FloatValues) Deduplicate ¶
func (a FloatValues) Deduplicate() FloatValues
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.
func (FloatValues) Exclude ¶
func (a FloatValues) Exclude(min, max int64) FloatValues
Exclude returns the subset of values not in [min, max]
func (FloatValues) Include ¶
func (a FloatValues) Include(min, max int64) FloatValues
Include returns the subset values between min and max inclusive.
func (FloatValues) Less ¶
func (a FloatValues) Less(i, j int) bool
func (FloatValues) MaxTime ¶
func (a FloatValues) MaxTime() int64
func (FloatValues) Merge ¶
func (a FloatValues) Merge(b FloatValues) FloatValues
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 (FloatValues) MinTime ¶
func (a FloatValues) MinTime() int64
func (FloatValues) Size ¶
func (a FloatValues) Size() int
func (FloatValues) Swap ¶
func (a FloatValues) Swap(i, j int)
type IndexEntry ¶
type IndexEntry struct {
// The min and max time of all points stored in the block.
MinTime, MaxTime int64
// The absolute position in the file where this block is located.
Offset int64
// The size in bytes of the block in the file.
Size uint32
}
IndexEntry is the index information for a given block in a TSM file.
func (*IndexEntry) AppendTo ¶
func (e *IndexEntry) AppendTo(b []byte) []byte
AppendTo will write a binary-encoded version of IndexEntry to b, allocating and returning a new slice, if necessary
func (*IndexEntry) Contains ¶
func (e *IndexEntry) Contains(t int64) bool
Returns true if this IndexEntry may contain values for the given time. The min and max times are inclusive.
func (*IndexEntry) OverlapsTimeRange ¶
func (e *IndexEntry) OverlapsTimeRange(min, max int64) bool
func (*IndexEntry) String ¶
func (e *IndexEntry) String() string
func (*IndexEntry) UnmarshalBinary ¶
func (e *IndexEntry) UnmarshalBinary(b []byte) error
UnmarshalBinary decodes an IndexEntry from a byte slice
type IndexWriter ¶
type IndexWriter interface { // Add records a new block entry for a key in the index. Add(key string, blockType byte, minTime, maxTime int64, offset int64, size uint32) // Entries returns all index entries for a key. Entries(key string) []IndexEntry // Keys returns the unique set of keys in the index. Keys() []string // KeyCount returns the count of unique keys in the index. KeyCount() int // Size returns the size of a the current index in bytes Size() uint32 // MarshalBinary returns a byte slice encoded version of the index. MarshalBinary() ([]byte, error) // WriteTo writes the index contents to a writer WriteTo(w io.Writer) (int64, error) }
IndexWriter writes a TSMIndex
func NewIndexWriter ¶
func NewIndexWriter() IndexWriter
type IntegerDecoder ¶
type IntegerDecoder struct {
// contains filtered or unexported fields
}
IntegerDecoder decodes a byte slice into int64s.
func (*IntegerDecoder) Error ¶
func (d *IntegerDecoder) Error() error
func (*IntegerDecoder) Next ¶
func (d *IntegerDecoder) Next() bool
func (*IntegerDecoder) Read ¶
func (d *IntegerDecoder) Read() int64
func (*IntegerDecoder) SetBytes ¶
func (d *IntegerDecoder) SetBytes(b []byte)
type IntegerEncoder ¶
type IntegerEncoder struct {
// contains filtered or unexported fields
}
IntegerEncoder encoders int64 into byte slices
func NewIntegerEncoder ¶
func NewIntegerEncoder() IntegerEncoder
func (*IntegerEncoder) Bytes ¶
func (e *IntegerEncoder) Bytes() ([]byte, error)
func (*IntegerEncoder) Write ¶
func (e *IntegerEncoder) Write(v int64)
type IntegerValue ¶
type IntegerValue struct {
// contains filtered or unexported fields
}
func DecodeIntegerBlock ¶
func DecodeIntegerBlock(block []byte, tdec *TimeDecoder, vdec *IntegerDecoder, a *[]IntegerValue) ([]IntegerValue, error)
func (*IntegerValue) Size ¶
func (v *IntegerValue) Size() int
func (*IntegerValue) String ¶
func (f *IntegerValue) String() string
func (*IntegerValue) UnixNano ¶
func (v *IntegerValue) UnixNano() int64
func (*IntegerValue) Value ¶
func (v *IntegerValue) Value() interface{}
type IntegerValues ¶
type IntegerValues []IntegerValue
IntegerValues represents a slice of Integer values.
func (IntegerValues) Deduplicate ¶
func (a IntegerValues) Deduplicate() IntegerValues
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.
func (IntegerValues) Exclude ¶
func (a IntegerValues) Exclude(min, max int64) IntegerValues
Exclude returns the subset of values not in [min, max]
func (IntegerValues) Include ¶
func (a IntegerValues) Include(min, max int64) IntegerValues
Include returns the subset values between min and max inclusive.
func (IntegerValues) Less ¶
func (a IntegerValues) Less(i, j int) bool
func (IntegerValues) MaxTime ¶
func (a IntegerValues) MaxTime() int64
func (IntegerValues) Merge ¶
func (a IntegerValues) Merge(b IntegerValues) IntegerValues
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 (IntegerValues) MinTime ¶
func (a IntegerValues) MinTime() int64
func (IntegerValues) Size ¶
func (a IntegerValues) Size() int
func (IntegerValues) Swap ¶
func (a IntegerValues) Swap(i, j int)
type KeyCursor ¶
type KeyCursor struct {
// contains filtered or unexported fields
}
func (*KeyCursor) Next ¶
func (c *KeyCursor) Next()
Next moves the cursor to the next position. Data should be read by the ReadBlock functions.
func (*KeyCursor) ReadBooleanBlock ¶
func (c *KeyCursor) ReadBooleanBlock(tdec *TimeDecoder, vdec *BooleanDecoder, buf *[]BooleanValue) ([]BooleanValue, error)
ReadBooleanBlock reads the next block as a set of boolean values.
func (*KeyCursor) ReadFloatBlock ¶
func (c *KeyCursor) ReadFloatBlock(tdec *TimeDecoder, vdec *FloatDecoder, buf *[]FloatValue) ([]FloatValue, error)
ReadFloatBlock reads the next block as a set of float values.
func (*KeyCursor) ReadIntegerBlock ¶
func (c *KeyCursor) ReadIntegerBlock(tdec *TimeDecoder, vdec *IntegerDecoder, buf *[]IntegerValue) ([]IntegerValue, error)
ReadIntegerBlock reads the next block as a set of integer values.
func (*KeyCursor) ReadStringBlock ¶
func (c *KeyCursor) ReadStringBlock(tdec *TimeDecoder, vdec *StringDecoder, buf *[]StringValue) ([]StringValue, error)
ReadStringBlock reads the next block as a set of string values.
type KeyIterator ¶
type KeyIterator interface { Next() bool Read() (string, int64, int64, []byte, error) Close() error }
KeyIterator allows iteration over set of keys and values in sorted order.
func NewCacheKeyIterator ¶
func NewCacheKeyIterator(cache *Cache, size int) KeyIterator
func NewTSMKeyIterator ¶
func NewTSMKeyIterator(size int, fast bool, readers ...*TSMReader) (KeyIterator, error)
type SegmentInfo ¶
type SegmentInfo struct {
// contains filtered or unexported fields
}
SegmentInfo represents metadata about a segment.
type StringDecoder ¶
type StringDecoder struct {
// contains filtered or unexported fields
}
func (*StringDecoder) Error ¶
func (e *StringDecoder) Error() error
func (*StringDecoder) Next ¶
func (e *StringDecoder) Next() bool
func (*StringDecoder) Read ¶
func (e *StringDecoder) Read() string
func (*StringDecoder) SetBytes ¶
func (e *StringDecoder) SetBytes(b []byte) error
SetBytes initializes the decoder with bytes to read from. This must be called before calling any other method.
type StringEncoder ¶
type StringEncoder struct {
// contains filtered or unexported fields
}
func NewStringEncoder ¶
func NewStringEncoder() StringEncoder
func (*StringEncoder) Bytes ¶
func (e *StringEncoder) Bytes() ([]byte, error)
func (*StringEncoder) Write ¶
func (e *StringEncoder) Write(s string)
type StringValue ¶
type StringValue struct {
// contains filtered or unexported fields
}
func DecodeStringBlock ¶
func DecodeStringBlock(block []byte, tdec *TimeDecoder, vdec *StringDecoder, a *[]StringValue) ([]StringValue, error)
func (*StringValue) Size ¶
func (v *StringValue) Size() int
func (*StringValue) String ¶
func (f *StringValue) String() string
func (*StringValue) UnixNano ¶
func (v *StringValue) UnixNano() int64
func (*StringValue) Value ¶
func (v *StringValue) Value() interface{}
type StringValues ¶
type StringValues []StringValue
StringValues represents a slice of String values.
func (StringValues) Deduplicate ¶
func (a StringValues) Deduplicate() StringValues
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.
func (StringValues) Exclude ¶
func (a StringValues) Exclude(min, max int64) StringValues
Exclude returns the subset of values not in [min, max]
func (StringValues) Include ¶
func (a StringValues) Include(min, max int64) StringValues
Include returns the subset values between min and max inclusive.
func (StringValues) Less ¶
func (a StringValues) Less(i, j int) bool
func (StringValues) MaxTime ¶
func (a StringValues) MaxTime() int64
func (StringValues) Merge ¶
func (a StringValues) Merge(b StringValues) StringValues
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 (StringValues) MinTime ¶
func (a StringValues) MinTime() int64
func (StringValues) Size ¶
func (a StringValues) Size() int
func (StringValues) Swap ¶
func (a StringValues) Swap(i, j int)
type TSMFile ¶
type TSMFile interface { // Path returns the underlying file path for the TSMFile. If the file // has not be written or loaded from disk, the zero value is returned. Path() string // Read returns all the values in the block where time t resides Read(key string, t int64) ([]Value, error) // ReadAt returns all the values in the block identified by entry. ReadAt(entry *IndexEntry, values []Value) ([]Value, error) ReadFloatBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, values *[]FloatValue) ([]FloatValue, error) ReadIntegerBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, values *[]IntegerValue) ([]IntegerValue, error) ReadStringBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, values *[]StringValue) ([]StringValue, error) ReadBooleanBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, values *[]BooleanValue) ([]BooleanValue, error) // Entries returns the index entries for all blocks for the given key. Entries(key string) []IndexEntry ReadEntries(key string, entries *[]IndexEntry) // Returns true if the TSMFile may contain a value with the specified // key and time ContainsValue(key string, t int64) bool // Contains returns true if the file contains any values for the given // key. Contains(key string) bool // TimeRange returns the min and max time across all keys in the file. TimeRange() (int64, int64) // TombstoneRange returns ranges of time that are deleted for the given key. TombstoneRange(key string) []TimeRange // KeyRange returns the min and max keys in the file. KeyRange() (string, string) // KeyCount returns the number of distict keys in the file. KeyCount() int // KeyAt returns the key located at index position idx KeyAt(idx int) (string, byte) // Type returns the block type of the values stored for the key. Returns one of // BlockFloat64, BlockInt64, BlockBoolean, BlockString. If key does not exist, // an error is returned. Type(key string) (byte, error) // Delete removes the keys from the set of keys available in this file. Delete(keys []string) error // DeleteRange removes the values for keys between min and max. DeleteRange(keys []string, min, max int64) error // HasTombstones returns true if file contains values that have been deleted. HasTombstones() bool // TombstoneFiles returns the tombstone filestats if there are any tombstones // written for this file. TombstoneFiles() []FileStat // Close the underlying file resources Close() error // Size returns the size of the file on disk in bytes. Size() uint32 // Remove deletes the file from the filesystem Remove() error // Stats returns summary information about the TSM file. Stats() FileStat // BlockIterator returns an iterator pointing to the first block in the file and // allows sequential iteration to each every block. BlockIterator() *BlockIterator }
type TSMIndex ¶
type TSMIndex interface { // Delete removes the given keys from the index. Delete(keys []string) // DeleteRange removes the given keys with data between minTime and maxTime from the index. DeleteRange(keys []string, minTime, maxTime int64) // Contains return true if the given key exists in the index. Contains(key string) bool // ContainsValue returns true if key and time might exists in this file. This function could // return true even though the actual point does not exists. For example, the key may // exists in this file, but not have point exactly at time t. ContainsValue(key string, timestamp int64) bool // Entries returns all index entries for a key. Entries(key string) []IndexEntry // ReadEntries reads the index entries for key into entries. ReadEntries(key string, entries *[]IndexEntry) // Entry returns the index entry for the specified key and timestamp. If no entry // matches the key and timestamp, nil is returned. Entry(key string, timestamp int64) *IndexEntry // Key returns the key in the index at the given postion. Key(index int) (string, []IndexEntry) // KeyAt returns the key in the index at the given postion. KeyAt(index int) (string, byte) // KeyCount returns the count of unique keys in the index. KeyCount() int // Size returns the size of a the current index in bytes Size() uint32 // TimeRange returns the min and max time across all keys in the file. TimeRange() (int64, int64) // TombstoneRange returns ranges of time that are deleted for the given key. TombstoneRange(key string) []TimeRange // KeyRange returns the min and max keys in the file. KeyRange() (string, string) // Type returns the block type of the values stored for the key. Returns one of // BlockFloat64, BlockInt64, BlockBool, BlockString. If key does not exist, // an error is returned. Type(key string) (byte, error) // UnmarshalBinary populates an index from an encoded byte slice // representation of an index. UnmarshalBinary(b []byte) error }
TSMIndex represent the index section of a TSM file. The index records all blocks, their locations, sizes, min and max times.
type TSMReader ¶
type TSMReader struct {
// contains filtered or unexported fields
}
func (*TSMReader) BlockIterator ¶
func (t *TSMReader) BlockIterator() *BlockIterator
func (*TSMReader) ContainsValue ¶
ContainsValue returns true if key and time might exists in this file. This function could return true even though the actual point does not exists. For example, the key may exists in this file, but not have point exactly at time t.
func (*TSMReader) DeleteRange ¶
DeleteRange removes the given points for keys between minTime and maxTime
func (*TSMReader) Entries ¶
func (t *TSMReader) Entries(key string) []IndexEntry
func (*TSMReader) HasTombstones ¶
HasTombstones return true if there are any tombstone entries recorded.
func (*TSMReader) LastModified ¶
func (*TSMReader) ReadAt ¶
func (t *TSMReader) ReadAt(entry *IndexEntry, vals []Value) ([]Value, error)
func (*TSMReader) ReadBooleanBlockAt ¶
func (t *TSMReader) ReadBooleanBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *BooleanDecoder, vals *[]BooleanValue) ([]BooleanValue, error)
func (*TSMReader) ReadEntries ¶
func (t *TSMReader) ReadEntries(key string, entries *[]IndexEntry)
func (*TSMReader) ReadFloatBlockAt ¶
func (t *TSMReader) ReadFloatBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *FloatDecoder, vals *[]FloatValue) ([]FloatValue, error)
func (*TSMReader) ReadIntegerBlockAt ¶
func (t *TSMReader) ReadIntegerBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *IntegerDecoder, vals *[]IntegerValue) ([]IntegerValue, error)
func (*TSMReader) ReadStringBlockAt ¶
func (t *TSMReader) ReadStringBlockAt(entry *IndexEntry, tdec *TimeDecoder, vdec *StringDecoder, vals *[]StringValue) ([]StringValue, error)
func (*TSMReader) TombstoneFiles ¶
TombstoneFiles returns any tombstone files associated with this TSM file.
func (*TSMReader) TombstoneRange ¶
TombstoneRange returns ranges of time that are deleted for the given key.
type TSMWriter ¶
type TSMWriter interface { // Write writes a new block for key containing and values. Writes append // blocks in the order that the Write function is called. The caller is // responsible for ensuring keys and blocks or sorted appropriately. // Values are encoded as a full block. The caller is responsible for // ensuring a fixed number of values are encoded in each block as wells as // ensuring the Values are sorted. The first and last timestamp values are // used as the minimum and maximum values for the index entry. Write(key string, values Values) error // WriteBlock writes a new block for key containing the bytes in block. WriteBlock appends // blocks in the order that the WriteBlock function is called. The caller is // responsible for ensuring keys and blocks are sorted appropriately, and that the // block and index information is correct for the block. The minTime and maxTime // timestamp values are used as the minimum and maximum values for the index entry. WriteBlock(key string, minTime, maxTime int64, block []byte) error // WriteIndex finishes the TSM write streams and writes the index. WriteIndex() error // Closes any underlying file resources. Close() error // Size returns the current size in bytes of the file Size() uint32 }
TSMWriter writes TSM formatted key and values.
type TimeDecoder ¶
type TimeDecoder struct {
// contains filtered or unexported fields
}
func (*TimeDecoder) Error ¶
func (d *TimeDecoder) Error() error
func (*TimeDecoder) Init ¶
func (d *TimeDecoder) Init(b []byte)
func (*TimeDecoder) Next ¶
func (d *TimeDecoder) Next() bool
func (*TimeDecoder) Read ¶
func (d *TimeDecoder) Read() int64
type TimeEncoder ¶
TimeEncoder encodes time.Time to byte slices.
type Tombstoner ¶
type Tombstoner struct { // Path is the location of the file to record tombstone. This should be the // full path to a TSM file. Path string // contains filtered or unexported fields }
func (*Tombstoner) Add ¶
func (t *Tombstoner) Add(keys []string) error
Add add the all keys to the tombstone
func (*Tombstoner) AddRange ¶
func (t *Tombstoner) AddRange(keys []string, min, max int64) error
AddRange adds all keys to the tombstone specifying only the data between min and max to be removed.
func (*Tombstoner) Delete ¶
func (t *Tombstoner) Delete() error
func (*Tombstoner) HasTombstones ¶
func (t *Tombstoner) HasTombstones() bool
HasTombstones return true if there are any tombstone entries recorded.
func (*Tombstoner) ReadAll ¶
func (t *Tombstoner) ReadAll() ([]Tombstone, error)
func (*Tombstoner) TombstoneFiles ¶
func (t *Tombstoner) TombstoneFiles() []FileStat
TombstoneFiles returns any tombstone files associated with this TSM file.
type Value ¶
type Value interface { UnixNano() int64 Value() interface{} Size() int String() string // contains filtered or unexported methods }
func DecodeBlock ¶
DecodeBlock takes a byte array and will decode into values of the appropriate type based on the block.
type Values ¶
type Values []Value
Values represents a slice of values.
func (Values) Deduplicate ¶
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.
func (Values) Encode ¶
Encode converts the values to a byte slice. If there are no values, this function panics.
func (Values) InfluxQLType ¶
InfluxQLType returns the influxql.DataType the values map to.
type WAL ¶
type WAL struct { // WALOutput is the writer used by the logger. LogOutput io.Writer // SegmentSize is the file size at which a segment file will be rotated SegmentSize int // LoggingEnabled specifies if detailed logs should be output LoggingEnabled bool // contains filtered or unexported fields }
func (*WAL) CloseSegment ¶
CloseSegment closes the current segment if it is non-empty and opens a new one.
func (*WAL) ClosedSegments ¶
func (*WAL) DeleteRange ¶
Delete deletes the given keys, returning the segment ID for the operation.
func (*WAL) LastWriteTime ¶
LastWriteTime is the last time anything was written to the WAL
func (*WAL) Open ¶
Open opens and initializes the Log. Will recover from previous unclosed shutdowns
func (*WAL) SetLogOutput ¶
SetLogOutput sets the location that logs are written to. It must not be called after the Open method has been called.
type WALEntry ¶
type WALEntry interface { Type() WalEntryType Encode(dst []byte) ([]byte, error) MarshalBinary() ([]byte, error) UnmarshalBinary(b []byte) error }
WALEntry is record stored in each WAL segment. Each entry has a type and an opaque, type dependent byte slice data attribute.
type WALSegmentReader ¶
type WALSegmentReader struct {
// contains filtered or unexported fields
}
WALSegmentReader reads WAL segments.
func NewWALSegmentReader ¶
func NewWALSegmentReader(r io.ReadCloser) *WALSegmentReader
func (*WALSegmentReader) Close ¶
func (r *WALSegmentReader) Close() error
func (*WALSegmentReader) Count ¶
func (r *WALSegmentReader) Count() int64
Count returns the total number of bytes read successfully from the segment, as of the last call to Read(). The segment is guaranteed to be valid up to and including this number of bytes.
func (*WALSegmentReader) Error ¶
func (r *WALSegmentReader) Error() error
func (*WALSegmentReader) Next ¶
func (r *WALSegmentReader) Next() bool
Next indicates if there is a value to read
func (*WALSegmentReader) Read ¶
func (r *WALSegmentReader) Read() (WALEntry, error)
type WALSegmentWriter ¶
type WALSegmentWriter struct {
// contains filtered or unexported fields
}
WALSegmentWriter writes WAL segments.
func NewWALSegmentWriter ¶
func NewWALSegmentWriter(w io.WriteCloser) *WALSegmentWriter
func (*WALSegmentWriter) Write ¶
func (w *WALSegmentWriter) Write(entryType WalEntryType, compressed []byte) error
type WalEntryType ¶
type WalEntryType byte
WalEntryType is a byte written to a wal segment file that indicates what the following compressed block contains
const ( WriteWALEntryType WalEntryType = 0x01 DeleteWALEntryType WalEntryType = 0x02 DeleteRangeWALEntryType WalEntryType = 0x03 )
type WriteWALEntry ¶
WriteWALEntry represents a write of points.
func (*WriteWALEntry) Encode ¶
func (w *WriteWALEntry) Encode(dst []byte) ([]byte, error)
Encode converts the WriteWALEntry into a byte stream using dst if it is large enough. If dst is too small, the slice will be grown to fit the encoded entry.
func (*WriteWALEntry) MarshalBinary ¶
func (w *WriteWALEntry) MarshalBinary() ([]byte, error)
func (*WriteWALEntry) Type ¶
func (w *WriteWALEntry) Type() WalEntryType
func (*WriteWALEntry) UnmarshalBinary ¶
func (w *WriteWALEntry) UnmarshalBinary(b []byte) error