mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-21 03:16:00 -08:00
Refactor: extract headChunkReader.chunkFromSeries()
For when you have a series locked already. Signed-off-by: Bryan Boreham <bjboreham@gmail.com>
This commit is contained in:
parent
a32aca0cd7
commit
7e24844d08
|
@ -362,9 +362,14 @@ func (h *headChunkReader) chunk(meta chunks.Meta, copyLastChunk bool) (chunkenc.
|
||||||
}
|
}
|
||||||
|
|
||||||
s.Lock()
|
s.Lock()
|
||||||
|
defer s.Unlock()
|
||||||
|
return h.chunkFromSeries(s, cid, copyLastChunk)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Call with s locked.
|
||||||
|
func (h *headChunkReader) chunkFromSeries(s *memSeries, cid chunks.HeadChunkID, copyLastChunk bool) (chunkenc.Chunk, int64, error) {
|
||||||
c, headChunk, isOpen, err := s.chunk(cid, h.head.chunkDiskMapper, &h.head.memChunkPool)
|
c, headChunk, isOpen, err := s.chunk(cid, h.head.chunkDiskMapper, &h.head.memChunkPool)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.Unlock()
|
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
defer func() {
|
defer func() {
|
||||||
|
@ -378,7 +383,6 @@ func (h *headChunkReader) chunk(meta chunks.Meta, copyLastChunk bool) (chunkenc.
|
||||||
|
|
||||||
// This means that the chunk is outside the specified range.
|
// This means that the chunk is outside the specified range.
|
||||||
if !c.OverlapsClosedInterval(h.mint, h.maxt) {
|
if !c.OverlapsClosedInterval(h.mint, h.maxt) {
|
||||||
s.Unlock()
|
|
||||||
return nil, 0, storage.ErrNotFound
|
return nil, 0, storage.ErrNotFound
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +399,6 @@ func (h *headChunkReader) chunk(meta chunks.Meta, copyLastChunk bool) (chunkenc.
|
||||||
return nil, 0, err
|
return nil, 0, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
s.Unlock()
|
|
||||||
|
|
||||||
return &safeHeadChunk{
|
return &safeHeadChunk{
|
||||||
Chunk: chk,
|
Chunk: chk,
|
||||||
|
|
Loading…
Reference in a new issue