@@ -189,8 +189,9 @@ func (ctr *container) pickAndSend(proc *process.Process, result *vm.CallResult)
189
189
hasSame := false
190
190
var row int64
191
191
var cols []* vector.Vector
192
+ fromRemoveBatch := false
192
193
for {
193
- if wholeLength == 0 {
194
+ if wholeLength == 0 || fromRemoveBatch {
194
195
choice = ctr .pickFirstRow ()
195
196
} else {
196
197
if choice , hasSame = ctr .pickSameRow (row , cols ); ! hasSame {
@@ -211,14 +212,22 @@ func (ctr *container) pickAndSend(proc *process.Process, result *vm.CallResult)
211
212
wholeLength ++
212
213
213
214
ctr .indexList [choice ]++
215
+ removeHasSame := true
214
216
if ctr .indexList [choice ] == int64 (ctr .batchList [choice ].RowCount ()) {
217
+ removeHasSame = ctr .hasSameRow (row , cols , choice )
215
218
ctr .removeBatch (proc , choice )
219
+ fromRemoveBatch = true
220
+ } else {
221
+ fromRemoveBatch = false
216
222
}
217
223
218
224
if len (ctr .indexList ) == 0 {
219
225
sendOver = true
220
226
break
221
227
}
228
+ if ! removeHasSame {
229
+ break
230
+ }
222
231
}
223
232
ctr .buf .SetRowCount (wholeLength )
224
233
result .Batch = ctr .buf
@@ -270,6 +279,30 @@ func (ctr *container) pickSameRow(row int64, cols []*vector.Vector) (batIndex in
270
279
return j , hasSame
271
280
}
272
281
282
+ func (ctr * container ) hasSameRow (row int64 , cols []* vector.Vector , choice int ) (hasSame bool ) {
283
+ l := len (ctr .indexList )
284
+
285
+ for j := 0 ; j < l ; j ++ {
286
+ if j == choice {
287
+ continue
288
+ }
289
+ hasSame = true
290
+ for k := 0 ; k < len (ctr .compares ); k ++ {
291
+ ctr .compares [k ].Set (0 , cols [k ])
292
+ ctr .compares [k ].Set (1 , ctr.orderCols [j ][k ])
293
+ result := ctr .compares [k ].Compare (0 , 1 , row , ctr .indexList [j ])
294
+ if result != 0 {
295
+ hasSame = false
296
+ break
297
+ }
298
+ }
299
+ if hasSame {
300
+ break
301
+ }
302
+ }
303
+ return hasSame
304
+ }
305
+
273
306
func (ctr * container ) removeBatch (proc * process.Process , index int ) {
274
307
if ctr .batchList [index ] != nil {
275
308
ctr .batchList [index ].Clean (proc .Mp ())
0 commit comments