mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
fix lint errors (#439)
unexported NewMemTombstones as this returns unexported memTombstones type which will not be shows in godoc. Added missing comments for exported methods. Removed unused RecordLogger,RecordReader interfaces. Signed-off-by: Krasi Georgiev <kgeorgie@redhat.com>
This commit is contained in:
parent
910f3021b0
commit
5a9ddeecef
4
block.go
4
block.go
|
@ -457,7 +457,7 @@ func (pb *Block) Delete(mint, maxt int64, ms ...labels.Matcher) error {
|
||||||
ir := pb.indexr
|
ir := pb.indexr
|
||||||
|
|
||||||
// Choose only valid postings which have chunks in the time-range.
|
// Choose only valid postings which have chunks in the time-range.
|
||||||
stones := NewMemTombstones()
|
stones := newMemTombstones()
|
||||||
|
|
||||||
var lset labels.Labels
|
var lset labels.Labels
|
||||||
var chks []chunks.Meta
|
var chks []chunks.Meta
|
||||||
|
@ -565,7 +565,7 @@ func (pb *Block) Snapshot(dir string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns true if the block overlaps [mint, maxt].
|
// OverlapsClosedInterval returns true if the block overlaps [mint, maxt].
|
||||||
func (pb *Block) OverlapsClosedInterval(mint, maxt int64) bool {
|
func (pb *Block) OverlapsClosedInterval(mint, maxt int64) bool {
|
||||||
// The block itself is a half-open interval
|
// The block itself is a half-open interval
|
||||||
// [pb.meta.MinTime, pb.meta.MaxTime).
|
// [pb.meta.MinTime, pb.meta.MaxTime).
|
||||||
|
|
|
@ -70,7 +70,7 @@ func createEmptyBlock(t *testing.T, dir string, meta *BlockMeta) *Block {
|
||||||
|
|
||||||
testutil.Ok(t, os.MkdirAll(chunkDir(dir), 0777))
|
testutil.Ok(t, os.MkdirAll(chunkDir(dir), 0777))
|
||||||
|
|
||||||
testutil.Ok(t, writeTombstoneFile(dir, NewMemTombstones()))
|
testutil.Ok(t, writeTombstoneFile(dir, newMemTombstones()))
|
||||||
|
|
||||||
b, err := OpenBlock(dir, nil)
|
b, err := OpenBlock(dir, nil)
|
||||||
testutil.Ok(t, err)
|
testutil.Ok(t, err)
|
||||||
|
|
|
@ -489,7 +489,7 @@ func (c *LeveledCompactor) write(dest string, meta *BlockMeta, blocks ...BlockRe
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create an empty tombstones file.
|
// Create an empty tombstones file.
|
||||||
if err := writeTombstoneFile(tmp, NewMemTombstones()); err != nil {
|
if err := writeTombstoneFile(tmp, newMemTombstones()); err != nil {
|
||||||
return errors.Wrap(err, "write new tombstones file")
|
return errors.Wrap(err, "write new tombstones file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -782,7 +782,7 @@ func TestTombstoneClean(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, b := range db.Blocks() {
|
for _, b := range db.Blocks() {
|
||||||
testutil.Equals(t, NewMemTombstones(), b.tombstones)
|
testutil.Equals(t, newMemTombstones(), b.tombstones)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -811,7 +811,7 @@ func TestTombstoneCleanFail(t *testing.T) {
|
||||||
block := createEmptyBlock(t, blockDir, meta)
|
block := createEmptyBlock(t, blockDir, meta)
|
||||||
|
|
||||||
// Add some some fake tombstones to trigger the compaction.
|
// Add some some fake tombstones to trigger the compaction.
|
||||||
tomb := NewMemTombstones()
|
tomb := newMemTombstones()
|
||||||
tomb.addInterval(0, Interval{0, 1})
|
tomb.addInterval(0, Interval{0, 1})
|
||||||
block.tombstones = tomb
|
block.tombstones = tomb
|
||||||
|
|
||||||
|
|
2
head.go
2
head.go
|
@ -225,7 +225,7 @@ func NewHead(r prometheus.Registerer, l log.Logger, wal *wal.WAL, chunkRange int
|
||||||
values: map[string]stringset{},
|
values: map[string]stringset{},
|
||||||
symbols: map[string]struct{}{},
|
symbols: map[string]struct{}{},
|
||||||
postings: index.NewUnorderedMemPostings(),
|
postings: index.NewUnorderedMemPostings(),
|
||||||
tombstones: NewMemTombstones(),
|
tombstones: newMemTombstones(),
|
||||||
}
|
}
|
||||||
h.metrics = newHeadMetrics(h, r)
|
h.metrics = newHeadMetrics(h, r)
|
||||||
|
|
||||||
|
|
|
@ -338,7 +338,7 @@ func TestHeadDeleteSimple(t *testing.T) {
|
||||||
Outer:
|
Outer:
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
// Reset the tombstones.
|
// Reset the tombstones.
|
||||||
head.tombstones = NewMemTombstones()
|
head.tombstones = newMemTombstones()
|
||||||
|
|
||||||
// Delete the ranges.
|
// Delete the ranges.
|
||||||
for _, r := range c.intervals {
|
for _, r := range c.intervals {
|
||||||
|
@ -521,7 +521,7 @@ func TestDelete_e2e(t *testing.T) {
|
||||||
}
|
}
|
||||||
for _, del := range dels {
|
for _, del := range dels {
|
||||||
// Reset the deletes everytime.
|
// Reset the deletes everytime.
|
||||||
hb.tombstones = NewMemTombstones()
|
hb.tombstones = newMemTombstones()
|
||||||
for _, r := range del.drange {
|
for _, r := range del.drange {
|
||||||
testutil.Ok(t, hb.Delete(r.Mint, r.Maxt, del.ms...))
|
testutil.Ok(t, hb.Delete(r.Mint, r.Maxt, del.ms...))
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,4 +70,4 @@ type mockBReader struct {
|
||||||
|
|
||||||
func (r *mockBReader) Index() (IndexReader, error) { return r.ir, nil }
|
func (r *mockBReader) Index() (IndexReader, error) { return r.ir, nil }
|
||||||
func (r *mockBReader) Chunks() (ChunkReader, error) { return r.cr, nil }
|
func (r *mockBReader) Chunks() (ChunkReader, error) { return r.cr, nil }
|
||||||
func (r *mockBReader) Tombstones() (TombstoneReader, error) { return NewMemTombstones(), nil }
|
func (r *mockBReader) Tombstones() (TombstoneReader, error) { return newMemTombstones(), nil }
|
||||||
|
|
|
@ -478,7 +478,7 @@ type baseChunkSeries struct {
|
||||||
// over them. It drops chunks based on tombstones in the given reader.
|
// over them. It drops chunks based on tombstones in the given reader.
|
||||||
func LookupChunkSeries(ir IndexReader, tr TombstoneReader, ms ...labels.Matcher) (ChunkSeriesSet, error) {
|
func LookupChunkSeries(ir IndexReader, tr TombstoneReader, ms ...labels.Matcher) (ChunkSeriesSet, error) {
|
||||||
if tr == nil {
|
if tr == nil {
|
||||||
tr = NewMemTombstones()
|
tr = newMemTombstones()
|
||||||
}
|
}
|
||||||
p, err := PostingsForMatchers(ir, ms...)
|
p, err := PostingsForMatchers(ir, ms...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -483,7 +483,7 @@ Outer:
|
||||||
querier := &blockQuerier{
|
querier := &blockQuerier{
|
||||||
index: ir,
|
index: ir,
|
||||||
chunks: cr,
|
chunks: cr,
|
||||||
tombstones: NewMemTombstones(),
|
tombstones: newMemTombstones(),
|
||||||
|
|
||||||
mint: c.mint,
|
mint: c.mint,
|
||||||
maxt: c.maxt,
|
maxt: c.maxt,
|
||||||
|
@ -756,7 +756,7 @@ func TestBaseChunkSeries(t *testing.T) {
|
||||||
bcs := &baseChunkSeries{
|
bcs := &baseChunkSeries{
|
||||||
p: index.NewListPostings(tc.postings),
|
p: index.NewListPostings(tc.postings),
|
||||||
index: mi,
|
index: mi,
|
||||||
tombstones: NewMemTombstones(),
|
tombstones: newMemTombstones(),
|
||||||
}
|
}
|
||||||
|
|
||||||
i := 0
|
i := 0
|
||||||
|
|
20
record.go
20
record.go
|
@ -26,22 +26,16 @@ import (
|
||||||
type RecordType uint8
|
type RecordType uint8
|
||||||
|
|
||||||
const (
|
const (
|
||||||
RecordInvalid RecordType = 255
|
// RecordInvalid is returned for unrecognised WAL record types.
|
||||||
RecordSeries RecordType = 1
|
RecordInvalid RecordType = 255
|
||||||
RecordSamples RecordType = 2
|
// RecordSeries is used to match WAL records of type Series.
|
||||||
|
RecordSeries RecordType = 1
|
||||||
|
// RecordSamples is used to match WAL records of type Samples.
|
||||||
|
RecordSamples RecordType = 2
|
||||||
|
// RecordTombstones is used to match WAL records of type Tombstones.
|
||||||
RecordTombstones RecordType = 3
|
RecordTombstones RecordType = 3
|
||||||
)
|
)
|
||||||
|
|
||||||
type RecordLogger interface {
|
|
||||||
Log(recs ...[]byte) error
|
|
||||||
}
|
|
||||||
|
|
||||||
type RecordReader interface {
|
|
||||||
Next() bool
|
|
||||||
Err() error
|
|
||||||
Record() []byte
|
|
||||||
}
|
|
||||||
|
|
||||||
// RecordDecoder decodes series, sample, and tombstone records.
|
// RecordDecoder decodes series, sample, and tombstone records.
|
||||||
// The zero value is ready to use.
|
// The zero value is ready to use.
|
||||||
type RecordDecoder struct {
|
type RecordDecoder struct {
|
||||||
|
|
|
@ -113,10 +113,10 @@ type Stone struct {
|
||||||
intervals Intervals
|
intervals Intervals
|
||||||
}
|
}
|
||||||
|
|
||||||
func readTombstones(dir string) (*memTombstones, error) {
|
func readTombstones(dir string) (TombstoneReader, error) {
|
||||||
b, err := ioutil.ReadFile(filepath.Join(dir, tombstoneFilename))
|
b, err := ioutil.ReadFile(filepath.Join(dir, tombstoneFilename))
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return NewMemTombstones(), nil
|
return newMemTombstones(), nil
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ func readTombstones(dir string) (*memTombstones, error) {
|
||||||
return nil, errors.New("checksum did not match")
|
return nil, errors.New("checksum did not match")
|
||||||
}
|
}
|
||||||
|
|
||||||
stonesMap := NewMemTombstones()
|
stonesMap := newMemTombstones()
|
||||||
|
|
||||||
for d.len() > 0 {
|
for d.len() > 0 {
|
||||||
k := d.uvarint64()
|
k := d.uvarint64()
|
||||||
|
@ -167,7 +167,9 @@ type memTombstones struct {
|
||||||
mtx sync.RWMutex
|
mtx sync.RWMutex
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewMemTombstones() *memTombstones {
|
// newMemTombstones creates new in memory TombstoneReader
|
||||||
|
// that allows adding new intervals.
|
||||||
|
func newMemTombstones() *memTombstones {
|
||||||
return &memTombstones{intvlGroups: make(map[uint64]Intervals)}
|
return &memTombstones{intvlGroups: make(map[uint64]Intervals)}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +210,7 @@ func (t *memTombstones) addInterval(ref uint64, itvs ...Interval) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (memTombstones) Close() error {
|
func (*memTombstones) Close() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ func TestWriteAndReadbackTombStones(t *testing.T) {
|
||||||
|
|
||||||
ref := uint64(0)
|
ref := uint64(0)
|
||||||
|
|
||||||
stones := NewMemTombstones()
|
stones := newMemTombstones()
|
||||||
// Generate the tombstones.
|
// Generate the tombstones.
|
||||||
for i := 0; i < 100; i++ {
|
for i := 0; i < 100; i++ {
|
||||||
ref += uint64(rand.Int31n(10)) + 1
|
ref += uint64(rand.Int31n(10)) + 1
|
||||||
|
@ -125,7 +125,7 @@ func TestAddingNewIntervals(t *testing.T) {
|
||||||
|
|
||||||
// TestMemTombstonesConcurrency to make sure they are safe to access from different goroutines.
|
// TestMemTombstonesConcurrency to make sure they are safe to access from different goroutines.
|
||||||
func TestMemTombstonesConcurrency(t *testing.T) {
|
func TestMemTombstonesConcurrency(t *testing.T) {
|
||||||
tomb := NewMemTombstones()
|
tomb := newMemTombstones()
|
||||||
totalRuns := 100
|
totalRuns := 100
|
||||||
var wg sync.WaitGroup
|
var wg sync.WaitGroup
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
|
|
Loading…
Reference in a new issue