Skip to content

Commit 83164a1

Browse files
authored
fix top container reset (#21208) (#21335)
fix top container reset Approved by: @badboynt1, @sukki37
1 parent 1d2305a commit 83164a1

File tree

2 files changed

+59
-4
lines changed

2 files changed

+59
-4
lines changed

pkg/sql/colexec/top/types.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,14 @@ func (top *Top) Release() {
9595
}
9696

9797
func (top *Top) Reset(proc *process.Process, pipelineFailed bool, err error) {
98-
top.ctr.reset()
98+
top.ctr.reset(proc)
9999
}
100100

101101
func (top *Top) Free(proc *process.Process, pipelineFailed bool, err error) {
102102
top.ctr.free(proc)
103103
}
104104

105-
func (ctr *container) reset() {
106-
105+
func (ctr *container) reset(proc *process.Process) {
107106
ctr.n = 0
108107
ctr.state = 0
109108
ctr.sels = nil
@@ -123,9 +122,14 @@ func (ctr *container) reset() {
123122
ctr.desc = false
124123
ctr.topValueZM = nil
125124
if ctr.bat != nil {
126-
ctr.bat.CleanOnlyData()
125+
ctr.bat.Clean(proc.Mp())
126+
ctr.bat = nil
127127
}
128128

129+
if ctr.buildBat != nil {
130+
ctr.buildBat.Clean(proc.Mp())
131+
ctr.buildBat = nil
132+
}
129133
}
130134

131135
func (ctr *container) free(proc *process.Process) {

pkg/sql/colexec/top/types_test.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2021 Matrix Origin
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
package top
16+
17+
import (
18+
"testing"
19+
20+
"github.com/matrixorigin/matrixone/pkg/container/batch"
21+
"github.com/matrixorigin/matrixone/pkg/testutil"
22+
"github.com/matrixorigin/matrixone/pkg/vm/process"
23+
)
24+
25+
func Test_container_reset(t *testing.T) {
26+
bat := batch.New([]string{"id"})
27+
bat.Vecs[0] = testutil.MakeInt32Vector([]int32{1, 2, 3}, nil)
28+
buildBat := batch.New([]string{"id"})
29+
buildBat.Vecs[0] = testutil.MakeInt32Vector([]int32{1, 2, 3}, nil)
30+
31+
proc := &process.Process{
32+
Base: &process.BaseProcess{},
33+
}
34+
proc.SetMPool(testutil.TestUtilMp)
35+
36+
c := &container{
37+
n: 0,
38+
state: 0,
39+
sels: nil,
40+
poses: nil,
41+
cmps: nil,
42+
limit: 0,
43+
limitExecutor: nil,
44+
executorsForOrderColumn: nil,
45+
desc: false,
46+
topValueZM: nil,
47+
bat: bat,
48+
buildBat: buildBat,
49+
}
50+
c.reset(proc)
51+
}

0 commit comments

Comments
 (0)