From 76237d80f2cad17c1e1040202576af3761b65e35 Mon Sep 17 00:00:00 2001 From: Edd Robinson Date: Thu, 9 Aug 2018 23:07:02 +0100 Subject: [PATCH] Address PR feedback --- tsdb/index/tsi1/index.go | 11 +---------- tsdb/index/tsi1/log_file.go | 11 ++++++----- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/tsdb/index/tsi1/index.go b/tsdb/index/tsi1/index.go index 24e7df97cf..b63b55e25a 100644 --- a/tsdb/index/tsi1/index.go +++ b/tsdb/index/tsi1/index.go @@ -27,7 +27,7 @@ import ( const IndexName = tsdb.TSI1IndexName // DefaultSeriesIDSetCacheSize is the default number of series ID sets to cache. -const DefaultSeriesIDSetCacheSize = 10 +const DefaultSeriesIDSetCacheSize = 100 // ErrCompactionInterrupted is returned if compactions are disabled or // an index is closed while a compaction is occurring. @@ -1120,12 +1120,3 @@ func IsIndexDir(path string) (bool, error) { } return false, nil } - -// ssElement is is stored within the LRU. It makes it possible to do constant -// time access via a hashmap and also storage inside a linked list. -type ssElement struct { - name []byte - key []byte - value []byte - SeriesIDSet *tsdb.SeriesIDSet -} diff --git a/tsdb/index/tsi1/log_file.go b/tsdb/index/tsi1/log_file.go index 176345a1f4..8316032b0c 100644 --- a/tsdb/index/tsi1/log_file.go +++ b/tsdb/index/tsi1/log_file.go @@ -525,7 +525,7 @@ func (f *LogFile) AddSeriesList(seriesSet *tsdb.SeriesIDSet, names [][]byte, tag continue } writeRequired = true - entries = append(entries, LogEntry{SeriesID: seriesIDs[i], name: names[i], tags: tagsSlice[i], cached: true}) + entries = append(entries, LogEntry{SeriesID: seriesIDs[i], name: names[i], tags: tagsSlice[i], cached: true, batchidx: i}) } seriesSet.RUnlock() @@ -544,7 +544,7 @@ func (f *LogFile) AddSeriesList(seriesSet *tsdb.SeriesIDSet, names [][]byte, tag entry := &entries[i] if seriesSet.ContainsNoLock(entry.SeriesID) { // We don't need to allocate anything for this series. - seriesIDs[i] = 0 + seriesIDs[entry.batchidx] = 0 continue } if err := f.appendEntry(entry); err != nil { @@ -1064,9 +1064,10 @@ type LogEntry struct { Checksum uint32 // checksum of flag/name/tags. Size int // total size of record, in bytes. - cached bool // Hint to LogFile that series data is already parsed - name []byte // series naem, this is a cached copy of the parsed measurement name - tags models.Tags // series tags, this is a cached copied of the parsed tags + cached bool // Hint to LogFile that series data is already parsed + name []byte // series naem, this is a cached copy of the parsed measurement name + tags models.Tags // series tags, this is a cached copied of the parsed tags + batchidx int // position of entry in batch. } // UnmarshalBinary unmarshals data into e.