Skip to content
This repository was archived by the owner on Aug 13, 2019. It is now read-only.

Commit 8c40bb9

Browse files
committed
Don't export MemTombstones.
Signed-off-by: Callum Styan <[email protected]>
1 parent 5264c56 commit 8c40bb9

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

compact_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -456,10 +456,12 @@ func metaRange(name string, mint, maxt int64, stats *BlockStats) dirMeta {
456456

457457
type erringBReader struct{}
458458

459-
func (erringBReader) Index() (IndexReader, error) { return nil, errors.New("index") }
460-
func (erringBReader) Chunks() (ChunkReader, error) { return nil, errors.New("chunks") }
461-
func (erringBReader) Tombstones() (TombstoneReader, error) { return nil, errors.New("tombstones") }
462-
func (erringBReader) Meta() BlockMeta { return BlockMeta{} }
459+
func (erringBReader) Index() (IndexReader, error) { return nil, errors.New("index") }
460+
func (erringBReader) Chunks() (ChunkReader, error) { return nil, errors.New("chunks") }
461+
func (erringBReader) Tombstones() (tombstones.TombstoneReader, error) {
462+
return nil, errors.New("tombstones")
463+
}
464+
func (erringBReader) Meta() BlockMeta { return BlockMeta{} }
463465

464466
type nopChunkWriter struct{}
465467

mocks_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ type mockBReader struct {
7373
maxt int64
7474
}
7575

76-
func (r *mockBReader) Index() (IndexReader, error) { return r.ir, nil }
77-
func (r *mockBReader) Chunks() (ChunkReader, error) { return r.cr, nil }
78-
func (r *mockBReader) Tombstones() (TombstoneReader, error) { return newMemTombstones(), nil }
79-
func (r *mockBReader) Meta() BlockMeta { return BlockMeta{MinTime: r.mint, MaxTime: r.maxt} }
76+
func (r *mockBReader) Index() (IndexReader, error) { return r.ir, nil }
77+
func (r *mockBReader) Chunks() (ChunkReader, error) { return r.cr, nil }
78+
func (r *mockBReader) Tombstones() (tombstones.TombstoneReader, error) {
79+
return tombstones.NewMemTombstones(), nil
80+
}
81+
func (r *mockBReader) Meta() BlockMeta { return BlockMeta{MinTime: r.mint, MaxTime: r.maxt} }

querier_test.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,11 @@ func TestBlockQuerierDelete(t *testing.T) {
413413
exp SeriesSet
414414
}
415415

416+
tstones := tombstones.NewMemTombstones()
417+
tstones.AddInterval(1, tombstones.Interval{1, 3})
418+
tstones.AddInterval(2, tombstones.Interval{1, 3}, tombstones.Interval{6, 10})
419+
tstones.AddInterval(3, tombstones.Interval{6, 10})
420+
416421
cases := struct {
417422
data []seriesSamples
418423

@@ -461,11 +466,7 @@ func TestBlockQuerierDelete(t *testing.T) {
461466
},
462467
},
463468
},
464-
tombstones: &tombstones.MemTombstones{IntvlGroups: map[uint64]tombstones.Intervals{
465-
1: tombstones.Intervals{{1, 3}},
466-
2: tombstones.Intervals{{1, 3}, {6, 10}},
467-
3: tombstones.Intervals{{6, 10}},
468-
}},
469+
tombstones: tstones,
469470
queries: []query{
470471
{
471472
mint: 2,

tombstones/tombstones.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,51 +199,51 @@ func ReadTombstones(dir string) (TombstoneReader, int64, error) {
199199
return stonesMap, int64(len(b)), nil
200200
}
201201

202-
type MemTombstones struct {
203-
IntvlGroups map[uint64]Intervals
202+
type memTombstones struct {
203+
intvlGroups map[uint64]Intervals
204204
mtx sync.RWMutex
205205
}
206206

207207
// NewMemTombstones creates new in memory TombstoneReader
208208
// that allows adding new intervals.
209-
func NewMemTombstones() *MemTombstones {
210-
return &MemTombstones{IntvlGroups: make(map[uint64]Intervals)}
209+
func NewMemTombstones() *memTombstones {
210+
return &memTombstones{intvlGroups: make(map[uint64]Intervals)}
211211
}
212212

213-
func (t *MemTombstones) Get(ref uint64) (Intervals, error) {
213+
func (t *memTombstones) Get(ref uint64) (Intervals, error) {
214214
t.mtx.RLock()
215215
defer t.mtx.RUnlock()
216-
return t.IntvlGroups[ref], nil
216+
return t.intvlGroups[ref], nil
217217
}
218218

219-
func (t *MemTombstones) Iter(f func(uint64, Intervals) error) error {
219+
func (t *memTombstones) Iter(f func(uint64, Intervals) error) error {
220220
t.mtx.RLock()
221221
defer t.mtx.RUnlock()
222-
for ref, ivs := range t.IntvlGroups {
222+
for ref, ivs := range t.intvlGroups {
223223
if err := f(ref, ivs); err != nil {
224224
return err
225225
}
226226
}
227227
return nil
228228
}
229229

230-
func (t *MemTombstones) Total() uint64 {
230+
func (t *memTombstones) Total() uint64 {
231231
t.mtx.RLock()
232232
defer t.mtx.RUnlock()
233233

234234
total := uint64(0)
235-
for _, ivs := range t.IntvlGroups {
235+
for _, ivs := range t.intvlGroups {
236236
total += uint64(len(ivs))
237237
}
238238
return total
239239
}
240240

241241
// AddInterval to an existing MemTombstones
242-
func (t *MemTombstones) AddInterval(ref uint64, itvs ...Interval) {
242+
func (t *memTombstones) AddInterval(ref uint64, itvs ...Interval) {
243243
t.mtx.Lock()
244244
defer t.mtx.Unlock()
245245
for _, itv := range itvs {
246-
t.IntvlGroups[ref] = t.IntvlGroups[ref].Add(itv)
246+
t.intvlGroups[ref] = t.intvlGroups[ref].Add(itv)
247247
}
248248
}
249249

0 commit comments

Comments
 (0)