From 4b7a4fb28c06d3b312341407c5c46440fff7f62d Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Mon, 29 Jul 2019 11:11:17 -0700 Subject: [PATCH] Don't export MemTombstones. Signed-off-by: Callum Styan --- querier_test.go | 11 ++++++----- tombstones/tombstones.go | 26 +++++++++++++------------- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/querier_test.go b/querier_test.go index 2794e0e6..cbbfcdab 100644 --- a/querier_test.go +++ b/querier_test.go @@ -413,6 +413,11 @@ func TestBlockQuerierDelete(t *testing.T) { exp SeriesSet } + tstones := tombstones.NewMemTombstones() + tstones.AddInterval(1, tombstones.Interval{1, 3}) + tstones.AddInterval(2, tombstones.Interval{1, 3}, tombstones.Interval{6, 10}) + tstones.AddInterval(3, tombstones.Interval{6, 10}) + cases := struct { data []seriesSamples @@ -461,11 +466,7 @@ func TestBlockQuerierDelete(t *testing.T) { }, }, }, - tombstones: &tombstones.MemTombstones{IntvlGroups: map[uint64]tombstones.Intervals{ - 1: tombstones.Intervals{{1, 3}}, - 2: tombstones.Intervals{{1, 3}, {6, 10}}, - 3: tombstones.Intervals{{6, 10}}, - }}, + tombstones: tstones, queries: []query{ { mint: 2, diff --git a/tombstones/tombstones.go b/tombstones/tombstones.go index ef2d261f..e82bccb0 100644 --- a/tombstones/tombstones.go +++ b/tombstones/tombstones.go @@ -199,27 +199,27 @@ func ReadTombstones(dir string) (TombstoneReader, int64, error) { return stonesMap, int64(len(b)), nil } -type MemTombstones struct { - IntvlGroups map[uint64]Intervals +type memTombstones struct { + intvlGroups map[uint64]Intervals mtx sync.RWMutex } // NewMemTombstones creates new in memory TombstoneReader // that allows adding new intervals. -func NewMemTombstones() *MemTombstones { - return &MemTombstones{IntvlGroups: make(map[uint64]Intervals)} +func NewMemTombstones() *memTombstones { + return &memTombstones{intvlGroups: make(map[uint64]Intervals)} } -func (t *MemTombstones) Get(ref uint64) (Intervals, error) { +func (t *memTombstones) Get(ref uint64) (Intervals, error) { t.mtx.RLock() defer t.mtx.RUnlock() - return t.IntvlGroups[ref], nil + return t.intvlGroups[ref], nil } -func (t *MemTombstones) Iter(f func(uint64, Intervals) error) error { +func (t *memTombstones) Iter(f func(uint64, Intervals) error) error { t.mtx.RLock() defer t.mtx.RUnlock() - for ref, ivs := range t.IntvlGroups { + for ref, ivs := range t.intvlGroups { if err := f(ref, ivs); err != nil { return err } @@ -227,27 +227,27 @@ func (t *MemTombstones) Iter(f func(uint64, Intervals) error) error { return nil } -func (t *MemTombstones) Total() uint64 { +func (t *memTombstones) Total() uint64 { t.mtx.RLock() defer t.mtx.RUnlock() total := uint64(0) - for _, ivs := range t.IntvlGroups { + for _, ivs := range t.intvlGroups { total += uint64(len(ivs)) } return total } // AddInterval to an existing MemTombstones -func (t *MemTombstones) AddInterval(ref uint64, itvs ...Interval) { +func (t *memTombstones) AddInterval(ref uint64, itvs ...Interval) { t.mtx.Lock() defer t.mtx.Unlock() for _, itv := range itvs { - t.IntvlGroups[ref] = t.IntvlGroups[ref].Add(itv) + t.intvlGroups[ref] = t.intvlGroups[ref].Add(itv) } } -func (*MemTombstones) Close() error { +func (*memTombstones) Close() error { return nil }