diff --git a/tsdb/engine/tsm1/bool.go b/tsdb/engine/tsm1/bool.go index 3cac8a09ef..3ad1cbd961 100644 --- a/tsdb/engine/tsm1/bool.go +++ b/tsdb/engine/tsm1/bool.go @@ -10,14 +10,9 @@ import ( "fmt" ) -const ( - // booleanUncompressed is an uncompressed boolean format. - // Not yet implemented. - booleanUncompressed = 0 - - // booleanCompressedBitPacked is an bit packed format using 1 bit per boolean - booleanCompressedBitPacked = 1 -) +// Note: an uncompressed boolean format is not yet implemented. +// booleanCompressedBitPacked is a bit packed format using 1 bit per boolean +const booleanCompressedBitPacked = 1 // BooleanEncoder encodes a series of booleans to an in-memory buffer. type BooleanEncoder struct { diff --git a/tsdb/engine/tsm1/cache.go b/tsdb/engine/tsm1/cache.go index 6506796afa..c49406eca4 100644 --- a/tsdb/engine/tsm1/cache.go +++ b/tsdb/engine/tsm1/cache.go @@ -514,15 +514,6 @@ func (c *Cache) Split(n int) []*Cache { return caches } -// unsortedKeys returns a slice of all keys under management by the cache. The -// keys are not sorted. -func (c *Cache) unsortedKeys() [][]byte { - c.mu.RLock() - store := c.store - c.mu.RUnlock() - return store.keys(false) -} - // Values returns a copy of all values, deduped and sorted, for the given key. func (c *Cache) Values(key []byte) Values { var snapshotEntries *entry diff --git a/tsdb/engine/tsm1/cache_test.go b/tsdb/engine/tsm1/cache_test.go index 309b428972..33bf87249a 100644 --- a/tsdb/engine/tsm1/cache_test.go +++ b/tsdb/engine/tsm1/cache_test.go @@ -443,7 +443,7 @@ func TestCache_CacheSnapshot(t *testing.T) { } // Create another snapshot - snapshot, err = c.Snapshot() + _, err = c.Snapshot() if err != nil { t.Fatalf("failed to snapshot cache: %v", err) } @@ -454,7 +454,7 @@ func TestCache_CacheSnapshot(t *testing.T) { c.ClearSnapshot(true) - snapshot, err = c.Snapshot() + _, err = c.Snapshot() if err != nil { t.Fatalf("failed to snapshot cache: %v", err) } diff --git a/tsdb/engine/tsm1/digest.go b/tsdb/engine/tsm1/digest.go index 7b3d9142a7..3c98e8e023 100644 --- a/tsdb/engine/tsm1/digest.go +++ b/tsdb/engine/tsm1/digest.go @@ -122,15 +122,3 @@ func Digest(dir string, w io.WriteCloser) error { MaxTime: math.MaxInt64, }, w) } - -type rwPair struct { - r *TSMReader - w TSMWriter - outf *os.File -} - -func (rw *rwPair) close() { - rw.r.Close() - rw.w.Close() - rw.outf.Close() -} diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index 020dca3523..86835ee200 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -1233,7 +1233,6 @@ func (e *Engine) DeleteSeriesRange(itr tsdb.SeriesIterator, min, max int64) erro if err := e.deleteSeriesRange(batch, min, max); err != nil { return err } - batch = batch[:0] } e.index.Rebuild() @@ -2771,40 +2770,6 @@ func SeriesAndFieldFromCompositeKey(key []byte) ([]byte, []byte) { return key[:sep], key[sep+len(keyFieldSeparator):] } -// readDir recursively reads all files from a path. -func readDir(root, rel string) ([]string, error) { - // Open root. - f, err := os.Open(filepath.Join(root, rel)) - if err != nil { - return nil, err - } - defer f.Close() - - // Read all files. - fis, err := f.Readdir(-1) - if err != nil { - return nil, err - } - - // Read all subdirectories and append to the end. - var paths []string - for _, fi := range fis { - // Simply append if it's a file. - if !fi.IsDir() { - paths = append(paths, filepath.Join(rel, fi.Name())) - continue - } - - // Read and append nested file paths. - children, err := readDir(root, filepath.Join(rel, fi.Name())) - if err != nil { - return nil, err - } - paths = append(paths, children...) - } - return paths, nil -} - func varRefSliceContains(a []influxql.VarRef, v string) bool { for _, ref := range a { if ref.Val == v { diff --git a/tsdb/engine/tsm1/file_store.go b/tsdb/engine/tsm1/file_store.go index 4db738c295..52795fcd4d 100644 --- a/tsdb/engine/tsm1/file_store.go +++ b/tsdb/engine/tsm1/file_store.go @@ -815,37 +815,6 @@ func (f *FileStore) BlockCount(path string, idx int) int { return 0 } -// walkFiles calls fn for each file in filestore in parallel. -func (f *FileStore) walkFiles(fn func(f TSMFile) error) error { - // Copy the current TSM files to prevent a slow walker from - // blocking other operations. - f.mu.RLock() - files := make([]TSMFile, len(f.files)) - copy(files, f.files) - f.mu.RUnlock() - - // struct to hold the result of opening each reader in a goroutine - errC := make(chan error, len(files)) - for _, f := range files { - go func(tsm TSMFile) { - if err := fn(tsm); err != nil { - errC <- fmt.Errorf("file %s: %s", tsm.Path(), err) - return - } - - errC <- nil - }(f) - } - - for i := 0; i < cap(errC); i++ { - res := <-errC - if res != nil { - return res - } - } - return nil -} - // We need to determine the possible files that may be accessed by this query given // the time range. func (f *FileStore) cost(key []byte, min, max int64) query.IteratorCost { @@ -1125,23 +1094,6 @@ func (c *KeyCursor) Close() { c.current = nil } -// hasOverlappingBlocks returns true if blocks have overlapping time ranges. -// This result is computed once and stored as the "duplicates" field. -func (c *KeyCursor) hasOverlappingBlocks() bool { - if len(c.seeks) == 0 { - return false - } - - for i := 1; i < len(c.seeks); i++ { - prev := c.seeks[i-1] - cur := c.seeks[i] - if prev.entry.MaxTime >= cur.entry.MinTime { - return true - } - } - return false -} - // seek positions the cursor at the given time. func (c *KeyCursor) seek(t int64) { if len(c.seeks) == 0 { @@ -1353,11 +1305,6 @@ func (a tsmReaders) Len() int { return len(a) } func (a tsmReaders) Less(i, j int) bool { return a[i].Path() < a[j].Path() } func (a tsmReaders) Swap(i, j int) { a[i], a[j] = a[j], a[i] } -type stream struct { - c chan seriesKey - v seriesKey -} - type seriesKey struct { key []byte typ byte diff --git a/tsdb/engine/tsm1/float.go b/tsdb/engine/tsm1/float.go index b088e1653a..0abf24e7dc 100644 --- a/tsdb/engine/tsm1/float.go +++ b/tsdb/engine/tsm1/float.go @@ -18,14 +18,9 @@ import ( "github.com/influxdata/influxdb/pkg/bits" ) -const ( - // floatUncompressed is an uncompressed format using 8 bytes per value. - // Not yet implemented. - floatUncompressed = 0 - - // floatCompressedGorilla is a compressed format using the gorilla paper encoding - floatCompressedGorilla = 1 -) +// Note: an uncompressed format is not yet implemented. +// floatCompressedGorilla is a compressed format using the gorilla paper encoding +const floatCompressedGorilla = 1 // uvnan is the constant returned from math.NaN(). const uvnan = 0x7FF8000000000001 diff --git a/tsdb/engine/tsm1/string.go b/tsdb/engine/tsm1/string.go index ccc4f407cb..fe6b5e9b20 100644 --- a/tsdb/engine/tsm1/string.go +++ b/tsdb/engine/tsm1/string.go @@ -12,14 +12,10 @@ import ( "github.com/golang/snappy" ) -const ( - // stringUncompressed is a an uncompressed format encoding strings as raw bytes. - // Not yet implemented. - stringUncompressed = 0 +// Note: an uncompressed format is not yet implemented. - // stringCompressedSnappy is a compressed encoding using Snappy compression - stringCompressedSnappy = 1 -) +// stringCompressedSnappy is a compressed encoding using Snappy compression +const stringCompressedSnappy = 1 // StringEncoder encodes multiple strings into a byte slice. type StringEncoder struct { diff --git a/tsdb/engine/tsm1/tombstone.go b/tsdb/engine/tsm1/tombstone.go index 3fee1709f4..a8b99444a6 100644 --- a/tsdb/engine/tsm1/tombstone.go +++ b/tsdb/engine/tsm1/tombstone.go @@ -341,24 +341,6 @@ func (t *Tombstoner) prepareV4() error { return nil } -// writeTombstoneV4 writes v3 files that are concatenated together. A v4 header is -// written to indicated this is a v4 file. -func (t *Tombstoner) writeTombstoneV4(tombstones []Tombstone) error { - if err := t.prepareV4(); err == errIncompatibleVersion { - return t.writeTombstoneV3(tombstones) - } else if err != nil { - return err - } - - for _, ts := range tombstones { - if err := t.writeTombstone(t.gz, ts); err != nil { - return err - } - } - - return t.commit() -} - func (t *Tombstoner) commit() error { // No pending writes if t.pendingFile == nil { diff --git a/tsdb/engine/tsm1/writer.go b/tsdb/engine/tsm1/writer.go index a82f22079e..00c4d8c249 100644 --- a/tsdb/engine/tsm1/writer.go +++ b/tsdb/engine/tsm1/writer.go @@ -246,12 +246,6 @@ func NewDiskIndexWriter(f *os.File) IndexWriter { return &directIndex{fd: f, w: bufio.NewWriterSize(f, 1024*1024)} } -// indexBlock represent an index information for a series within a TSM file. -type indexBlock struct { - key []byte - entries *indexEntries -} - type syncer interface { Name() string Sync() error