From 38646a0491e9eaddc864d37652dc23312c2b0d16 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Sat, 25 May 2024 19:42:11 +0200 Subject: [PATCH] wip --- lib/logstorage/block_result.go | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/logstorage/block_result.go b/lib/logstorage/block_result.go index d6d35825f..aa2ac5168 100644 --- a/lib/logstorage/block_result.go +++ b/lib/logstorage/block_result.go @@ -295,6 +295,8 @@ func (br *blockResult) initAllColumns(bs *blockSearch, bm *bitmap) { br.addColumn(bs, bm, ch) } } + + br.csInitFast() } // initRequestedColumns initialized only requested columns in br according to bs and bm. @@ -322,6 +324,8 @@ func (br *blockResult) initRequestedColumns(bs *blockSearch, bm *bitmap) { } } } + + br.csInitFast() } func (br *blockResult) mustInit(bs *blockSearch, bm *bitmap) { @@ -1351,10 +1355,13 @@ func (br *blockResult) getColumnByName(columnName string) *blockResultColumn { } func (br *blockResult) getColumns() []*blockResultColumn { - if br.csInitialized { - return br.cs + if !br.csInitialized { + br.csInit() } + return br.cs +} +func (br *blockResult) csInit() { csBuf := br.csBuf clear(br.cs) cs := br.cs[:0] @@ -1369,8 +1376,17 @@ func (br *blockResult) getColumns() []*blockResultColumn { } br.cs = cs br.csInitialized = true +} - return br.cs +func (br *blockResult) csInitFast() { + csBuf := br.csBuf + clear(br.cs) + cs := slicesutil.SetLength(br.cs, len(csBuf)) + for i := range csBuf { + cs[i] = &csBuf[i] + } + br.cs = cs + br.csInitialized = true } func getBlockResultColumnIdxByName(cs []*blockResultColumn, name string) int {