From 4c4e0c614e258c00eeff9eb79d172ce98c06b7ae Mon Sep 17 00:00:00 2001 From: Fabian Reinartz Date: Mon, 9 Jan 2017 19:24:05 +0100 Subject: [PATCH] Simplify position mapper updating --- head.go | 12 +++--------- querier.go | 5 +---- 2 files changed, 4 insertions(+), 13 deletions(-) diff --git a/head.go b/head.go index 1b8af29f0..5eafb4f95 100644 --- a/head.go +++ b/head.go @@ -403,9 +403,6 @@ func (h *HeadBlock) fullness() float64 { } func (h *HeadBlock) updateMapping() { - h.mapper.mtx.Lock() - defer h.mapper.mtx.Unlock() - h.mtx.RLock() if h.mapper.sortable != nil && h.mapper.Len() == len(h.descs) { @@ -435,15 +432,12 @@ func (h *HeadBlock) remapPostings(p Postings) Postings { return errPostings{err: err} } - h.mapper.mtx.RLock() - defer h.mapper.mtx.RUnlock() + h.mapper.mtx.Lock() + defer h.mapper.mtx.Unlock() + h.updateMapping() h.mapper.Sort(list) - slice.Sort(list, func(i, j int) bool { - return h.mapper.fw[list[i]] < h.mapper.fw[list[j]] - }) - return newListPostings(list) } diff --git a/querier.go b/querier.go index 73158b6ec..bbbc7abf3 100644 --- a/querier.go +++ b/querier.go @@ -64,11 +64,8 @@ func (s *DB) Querier(mint, maxt int64) Querier { // TODO(fabxc): find nicer solution. if hb, ok := b.(*HeadBlock); ok { - hb.updateMapping() q.postingsMapper = hb.remapPostings - q.series = &headSeriesReader{ - h: hb, - } + q.series = &headSeriesReader{h: hb} } sq.blocks = append(sq.blocks, q)