diff --git a/lib/logstorage/block_search.go b/lib/logstorage/block_search.go index fe5cc56aa..34e7d6329 100644 --- a/lib/logstorage/block_search.go +++ b/lib/logstorage/block_search.go @@ -146,7 +146,7 @@ func (bs *blockSearch) partPath() string { return bs.bsw.p.path } -func (bs *blockSearch) search(bsw *blockSearchWork) { +func (bs *blockSearch) search(bsw *blockSearchWork, bm *bitmap) { bs.reset() bs.bsw = bsw @@ -154,18 +154,17 @@ func (bs *blockSearch) search(bsw *blockSearchWork) { bs.csh.initFromBlockHeader(&bs.a, bsw.p, &bsw.bh) // search rows matching the given filter - bm := getBitmap(int(bsw.bh.rowsCount)) - defer putBitmap(bm) - + bm.init(int(bsw.bh.rowsCount)) bm.setBits() bs.bsw.so.filter.apply(bs, bm) - bs.br.mustInit(bs, bm) if bm.isZero() { // The filter doesn't match any logs in the current block. return } + bs.br.mustInit(bs, bm) + // fetch the requested columns to bs.br. if bs.bsw.so.needAllColumns { bs.br.initAllColumns() diff --git a/lib/logstorage/storage_search.go b/lib/logstorage/storage_search.go index 5ed9b80d0..310718f06 100644 --- a/lib/logstorage/storage_search.go +++ b/lib/logstorage/storage_search.go @@ -178,6 +178,7 @@ func (s *Storage) search(workersCount int, so *genericSearchOptions, stopCh <-ch for i := 0; i < workersCount; i++ { go func(workerID uint) { bs := getBlockSearch() + bm := getBitmap(0) for bswb := range workCh { bsws := bswb.bsws for i := range bsws { @@ -188,7 +189,7 @@ func (s *Storage) search(workersCount int, so *genericSearchOptions, stopCh <-ch continue } - bs.search(bsw) + bs.search(bsw, bm) if len(bs.br.timestamps) > 0 { processBlockResult(workerID, &bs.br) } @@ -198,6 +199,7 @@ func (s *Storage) search(workersCount int, so *genericSearchOptions, stopCh <-ch putBlockSearchWorkBatch(bswb) } putBlockSearch(bs) + putBitmap(bm) wgWorkers.Done() }(uint(i)) }