mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-24 21:24:05 -08:00
Add methods to fetch page's buf data in tsdb WAL (#5967)
* move the WAL page buf reset in its own func Signed-off-by: Erfan Besharat <erbesharat@gmail.com>
This commit is contained in:
parent
21c9789083
commit
9336c01dfd
|
@ -64,6 +64,14 @@ func (p *page) full() bool {
|
||||||
return pageSize-p.alloc < recordHeaderSize
|
return pageSize-p.alloc < recordHeaderSize
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *page) reset() {
|
||||||
|
for i := range p.buf {
|
||||||
|
p.buf[i] = 0
|
||||||
|
}
|
||||||
|
p.alloc = 0
|
||||||
|
p.flushed = 0
|
||||||
|
}
|
||||||
|
|
||||||
// Segment represents a segment file.
|
// Segment represents a segment file.
|
||||||
type Segment struct {
|
type Segment struct {
|
||||||
*os.File
|
*os.File
|
||||||
|
@ -494,11 +502,7 @@ func (w *WAL) flushPage(clear bool) error {
|
||||||
|
|
||||||
// We flushed an entire page, prepare a new one.
|
// We flushed an entire page, prepare a new one.
|
||||||
if clear {
|
if clear {
|
||||||
for i := range p.buf {
|
p.reset()
|
||||||
p.buf[i] = 0
|
|
||||||
}
|
|
||||||
p.alloc = 0
|
|
||||||
p.flushed = 0
|
|
||||||
w.donePages++
|
w.donePages++
|
||||||
w.pageCompletions.Inc()
|
w.pageCompletions.Inc()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue