Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

colexecop: reset the internal batch in a test operator #78703

Merged
merged 1 commit into from
Mar 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/col/coldata/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ func (b *Bytes) copyElements(srcElementsToCopy []element, src *Bytes, destIdx in
// Optimize copying of the elements by copying all of them directly into the
// destination. This way all inlined values become correctly set, and we
// only need to set the non-inlined values separately.
//
// Note that this behavior results in losing the references to the old
// non-inlined values, even if they could be reused. If Bytes is not Reset,
// then that unused space in Bytes.buffer can accumulate. However, checking
// whether there are old non-inlined values with non-zero capacity leads to
// performance regressions, and in the production code we do reset the Bytes
// in all cases, so we accept this poor behavior in such a hypothetical /
// test-only scenario. See #78703 for more details.
copy(destElements, srcElementsToCopy)
// Early bounds checks.
_ = destElements[len(srcElementsToCopy)-1]
Expand Down
3 changes: 2 additions & 1 deletion pkg/sql/colexecop/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,9 @@ func (s *RepeatableBatchSource) Next() coldata.Batch {
if s.batchesToReturn != 0 && s.batchesReturned > s.batchesToReturn {
return coldata.ZeroBatch
}
s.output.SetSelection(s.sel != nil)
s.output.ResetInternalBatch()
if s.sel != nil {
s.output.SetSelection(true)
copy(s.output.Selection()[:s.batchLen], s.sel[:s.batchLen])
}
for i, colVec := range s.colVecs {
Expand Down