Simplify position mapper updating

This commit is contained in:
Fabian Reinartz 2017-01-09 19:24:05 +01:00
parent 142c89b8b0
commit 4c4e0c614e
2 changed files with 4 additions and 13 deletions

12
head.go
View file

@ -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)
}

View file

@ -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)