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:
Erfan Besharat 2019-08-30 13:08:36 +04:30 committed by Krasi Georgiev
parent 21c9789083
commit 9336c01dfd

View file

@ -64,6 +64,14 @@ func (p *page) full() bool {
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.
type Segment struct {
*os.File
@ -494,11 +502,7 @@ func (w *WAL) flushPage(clear bool) error {
// We flushed an entire page, prepare a new one.
if clear {
for i := range p.buf {
p.buf[i] = 0
}
p.alloc = 0
p.flushed = 0
p.reset()
w.donePages++
w.pageCompletions.Inc()
}