diff --git a/vendor/github.com/prometheus/tsdb/index/index.go b/vendor/github.com/prometheus/tsdb/index/index.go index 146332d10..2689b5691 100644 --- a/vendor/github.com/prometheus/tsdb/index/index.go +++ b/vendor/github.com/prometheus/tsdb/index/index.go @@ -144,7 +144,11 @@ func NewWriter(fn string) (*Writer, error) { if err != nil { return nil, err } - defer df.Close() // close for flatform windows + defer df.Close() // Close for platform windows. + + if err := os.RemoveAll(fn); err != nil { + return nil, errors.Wrap(err, "remove any existing index at path") + } f, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY, 0666) if err != nil { @@ -535,8 +539,8 @@ type Reader struct { c io.Closer // Cached hashmaps of section offsets. - labels map[string]uint32 - postings map[labels.Label]uint32 + labels map[string]uint64 + postings map[labels.Label]uint64 // Cache of read symbols. Strings that are returned when reading from the // block are always backed by true strings held in here rather than // strings that are backed by byte slices from the mmap'd index file. This @@ -597,8 +601,8 @@ func newReader(b ByteSlice, c io.Closer) (*Reader, error) { b: b, c: c, symbols: map[uint32]string{}, - labels: map[string]uint32{}, - postings: map[labels.Label]uint32{}, + labels: map[string]uint64{}, + postings: map[labels.Label]uint64{}, crc32: newCRC32(), } @@ -623,7 +627,7 @@ func newReader(b ByteSlice, c io.Closer) (*Reader, error) { } var err error - err = r.readOffsetTable(r.toc.labelIndicesTable, func(key []string, off uint32) error { + err = r.readOffsetTable(r.toc.labelIndicesTable, func(key []string, off uint64) error { if len(key) != 1 { return errors.Errorf("unexpected key length %d", len(key)) } @@ -633,7 +637,7 @@ func newReader(b ByteSlice, c io.Closer) (*Reader, error) { if err != nil { return nil, errors.Wrap(err, "read label index table") } - err = r.readOffsetTable(r.toc.postingsTable, func(key []string, off uint32) error { + err = r.readOffsetTable(r.toc.postingsTable, func(key []string, off uint64) error { if len(key) != 2 { return errors.Errorf("unexpected key length %d", len(key)) } @@ -786,7 +790,7 @@ func (r *Reader) readSymbols(off int) error { // readOffsetTable reads an offset table at the given position calls f for each // found entry.f // If f returns an error it stops decoding and returns the received error, -func (r *Reader) readOffsetTable(off uint64, f func([]string, uint32) error) error { +func (r *Reader) readOffsetTable(off uint64, f func([]string, uint64) error) error { d := r.decbufAt(int(off)) cnt := d.be32() @@ -797,7 +801,7 @@ func (r *Reader) readOffsetTable(off uint64, f func([]string, uint32) error) err for i := 0; i < keyCount; i++ { keys = append(keys, d.uvarintStr()) } - o := uint32(d.uvarint()) + o := d.uvarint64() if d.err() != nil { break } diff --git a/vendor/github.com/prometheus/tsdb/index/postings.go b/vendor/github.com/prometheus/tsdb/index/postings.go index f942edaad..53449f341 100644 --- a/vendor/github.com/prometheus/tsdb/index/postings.go +++ b/vendor/github.com/prometheus/tsdb/index/postings.go @@ -445,32 +445,31 @@ func (rp *removedPostings) Next() bool { rp.rok = rp.remove.Next() rp.initialized = true } + for { + if !rp.fok { + return false + } - if !rp.fok { - return false + if !rp.rok { + rp.cur = rp.full.At() + rp.fok = rp.full.Next() + return true + } + + fcur, rcur := rp.full.At(), rp.remove.At() + if fcur < rcur { + rp.cur = fcur + rp.fok = rp.full.Next() + + return true + } else if rcur < fcur { + // Forward the remove postings to the right position. + rp.rok = rp.remove.Seek(fcur) + } else { + // Skip the current posting. + rp.fok = rp.full.Next() + } } - - if !rp.rok { - rp.cur = rp.full.At() - rp.fok = rp.full.Next() - return true - } - - fcur, rcur := rp.full.At(), rp.remove.At() - if fcur < rcur { - rp.cur = fcur - rp.fok = rp.full.Next() - - return true - } else if rcur < fcur { - // Forward the remove postings to the right position. - rp.rok = rp.remove.Seek(fcur) - } else { - // Skip the current posting. - rp.fok = rp.full.Next() - } - - return rp.Next() } func (rp *removedPostings) Seek(id uint64) bool { diff --git a/vendor/vendor.json b/vendor/vendor.json index cbddd6560..5a7d4afc3 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -802,38 +802,38 @@ { "checksumSHA1": "CeD8QwiLL5CBkWMOfbaJxs4AFuM=", "path": "github.com/prometheus/tsdb", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { - "checksumSHA1": "4X26TfLh8M4WuCFo/5a+Qk+ieSw=", + "checksumSHA1": "S7F4yWxVLhxQNHMdgoOo6plmOOs=", "path": "github.com/prometheus/tsdb/chunkenc", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { "checksumSHA1": "+zsn1i8cqwgZXL8Bg6jDy32xjAo=", "path": "github.com/prometheus/tsdb/chunks", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { "checksumSHA1": "h49AAcJ5+iRBwCgbfQf+2T1E1ZE=", "path": "github.com/prometheus/tsdb/fileutil", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { - "checksumSHA1": "Cpumd1FEx22Kz8I3HrhMPrSRPNA=", + "checksumSHA1": "UlvN+ZhTu52S8f9niySQpPC+dvQ=", "path": "github.com/prometheus/tsdb/index", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { "checksumSHA1": "Va8HWvOFTwFeewZFadMAOzNGDps=", "path": "github.com/prometheus/tsdb/labels", - "revision": "bc49a665d16326ad6ad078b97e0f903d894f80f8", - "revisionTime": "2018-02-12T10:58:46Z" + "revision": "494acd307058387ced7646f9996b0f7372eaa558", + "revisionTime": "2018-02-15T11:29:47Z" }, { "checksumSHA1": "5SYLEhADhdBVZAGPVHWggQl7H8k=",