This commit is contained in:
Aliaksandr Valialkin 2024-05-06 23:03:42 +02:00
parent ba20bb08d3
commit adcdb92b1e
No known key found for this signature in database
GPG key ID: 52C003EE2BCDB9EB
3 changed files with 14 additions and 12 deletions

View file

@ -1560,8 +1560,7 @@ type resultColumn struct {
values []string values []string
} }
func (rc *resultColumn) reset() { func (rc *resultColumn) resetKeepName() {
rc.name = ""
rc.buf = rc.buf[:0] rc.buf = rc.buf[:0]
clear(rc.values) clear(rc.values)

View file

@ -466,14 +466,14 @@ type pipeSortWriteContext struct {
func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx uint) { func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx uint) {
rr := shard.rowRefs[rowIdx] rr := shard.rowRefs[rowIdx]
block := &shard.blocks[rr.blockIdx] b := &shard.blocks[rr.blockIdx]
byFields := shard.ps.byFields byFields := shard.ps.byFields
rcs := wctx.rcs rcs := wctx.rcs
areEqualColumns := len(rcs) == len(byFields)+len(block.otherColumns) areEqualColumns := len(rcs) == len(byFields)+len(b.otherColumns)
if areEqualColumns { if areEqualColumns {
for i, c := range block.otherColumns { for i, c := range b.otherColumns {
if rcs[len(byFields)+i].name != c.name { if rcs[len(byFields)+i].name != c.name {
areEqualColumns = false areEqualColumns = false
break break
@ -490,7 +490,7 @@ func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx
name: bf.name, name: bf.name,
}) })
} }
for _, c := range block.otherColumns { for _, c := range b.otherColumns {
rcs = append(rcs, resultColumn{ rcs = append(rcs, resultColumn{
name: c.name, name: c.name,
}) })
@ -498,13 +498,16 @@ func (wctx *pipeSortWriteContext) writeRow(shard *pipeSortProcessorShard, rowIdx
wctx.rcs = rcs wctx.rcs = rcs
} }
for i, c := range block.byColumns { byColumns := b.byColumns
v := c.values[rr.rowIdx] for i := range byFields {
v := byColumns[i].values[rr.rowIdx]
rcs[i].addValue(v) rcs[i].addValue(v)
wctx.valuesLen += len(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) rcs[len(byFields)+i].addValue(v)
wctx.valuesLen += len(v) wctx.valuesLen += len(v)
} }
@ -529,7 +532,7 @@ func (wctx *pipeSortWriteContext) flush() {
wctx.psp.ppBase.writeBlock(0, br) wctx.psp.ppBase.writeBlock(0, br)
br.reset() br.reset()
for i := range rcs { for i := range rcs {
rcs[i].reset() rcs[i].resetKeepName()
} }
} }

View file

@ -411,7 +411,7 @@ func (psp *pipeStatsProcessor) flush() error {
psp.ppBase.writeBlock(0, &br) psp.ppBase.writeBlock(0, &br)
br.reset() br.reset()
for i := range rcs { for i := range rcs {
rcs[i].reset() rcs[i].resetKeepName()
} }
valuesLen = 0 valuesLen = 0
} }