diff --git a/lib/logstorage/block_result.go b/lib/logstorage/block_result.go index d1396c6ca..ce6ac5d0d 100644 --- a/lib/logstorage/block_result.go +++ b/lib/logstorage/block_result.go @@ -1560,8 +1560,7 @@ type resultColumn struct { values []string } -func (rc *resultColumn) reset() { - rc.name = "" +func (rc *resultColumn) resetKeepName() { rc.buf = rc.buf[:0] clear(rc.values) diff --git a/lib/logstorage/pipe_sort.go b/lib/logstorage/pipe_sort.go index a0e3366f2..4437837f7 100644 --- a/lib/logstorage/pipe_sort.go +++ b/lib/logstorage/pipe_sort.go @@ -466,14 +466,14 @@ type pipeSortWriteContext struct { func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx uint) { rr := shard.rowRefs[rowIdx] - block := &shard.blocks[rr.blockIdx] + b := &shard.blocks[rr.blockIdx] byFields := shard.ps.byFields rcs := wctx.rcs - areEqualColumns := len(rcs) == len(byFields)+len(block.otherColumns) + areEqualColumns := len(rcs) == len(byFields)+len(b.otherColumns) if areEqualColumns { - for i, c := range block.otherColumns { + for i, c := range b.otherColumns { if rcs[len(byFields)+i].name != c.name { areEqualColumns = false break @@ -490,7 +490,7 @@ func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx name: bf.name, }) } - for _, c := range block.otherColumns { + for _, c := range b.otherColumns { rcs = append(rcs, resultColumn{ name: c.name, }) @@ -498,13 +498,16 @@ func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx wctx.rcs = rcs } - for i, c := range block.byColumns { - v := c.values[rr.rowIdx] + byColumns := b.byColumns + for i := range byFields { + v := byColumns[i].values[rr.rowIdx] rcs[i].addValue(v) wctx.valuesLen += len(v) } - for i, c := range block.otherColumns { - v := c.values[rr.rowIdx] + + otherColumns := b.otherColumns + for i := range otherColumns { + v := otherColumns[i].values[rr.rowIdx] rcs[len(byFields)+i].addValue(v) wctx.valuesLen += len(v) } @@ -529,7 +532,7 @@ func (wctx *pipeSortWriteContext) flush() { wctx.psp.ppBase.writeBlock(0, br) br.reset() for i := range rcs { - rcs[i].reset() + rcs[i].resetKeepName() } } diff --git a/lib/logstorage/pipe_stats.go b/lib/logstorage/pipe_stats.go index 4b8c78e34..28d1c4044 100644 --- a/lib/logstorage/pipe_stats.go +++ b/lib/logstorage/pipe_stats.go @@ -411,7 +411,7 @@ func (psp *pipeStatsProcessor) flush() error { psp.ppBase.writeBlock(0, &br) br.reset() for i := range rcs { - rcs[i].reset() + rcs[i].resetKeepName() } valuesLen = 0 }