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

coldata: operate on Nulls value, not reference #74592

Merged
merged 1 commit into from
Jan 10, 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
4 changes: 2 additions & 2 deletions pkg/col/coldata/nulls.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,12 +340,12 @@ func (n *Nulls) SetNullBitmap(bm []byte, size int) {

// Or returns a new Nulls vector where NullAt(i) iff n1.NullAt(i) or
// n2.NullAt(i).
func (n *Nulls) Or(n2 *Nulls) *Nulls {
func (n Nulls) Or(n2 Nulls) Nulls {
// For simplicity, enforce that len(n.nulls) <= len(n2.nulls).
if len(n.nulls) > len(n2.nulls) {
n, n2 = n2, n
}
res := &Nulls{
res := Nulls{
maybeHasNulls: n.maybeHasNulls || n2.maybeHasNulls,
nulls: make([]byte, len(n2.nulls)),
}
Expand Down
8 changes: 4 additions & 4 deletions pkg/col/coldata/nulls_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,18 +161,18 @@ func TestNullsSet(t *testing.T) {
}
for _, withSel := range []bool{false, true} {
t.Run(fmt.Sprintf("WithSel=%t", withSel), func(t *testing.T) {
var srcNulls *Nulls
var srcNulls Nulls
if withSel {
args.Sel = make([]int, BatchSize())
// Make a selection vector with every even index. (This turns nulls10 into
// nulls5.)
for i := range args.Sel {
args.Sel[i] = i * 2
}
srcNulls = &nulls10
srcNulls = nulls10
} else {
args.Sel = nil
srcNulls = &nulls5
srcNulls = nulls5
}
for _, destStartIdx := range pos {
for _, srcStartIdx := range pos {
Expand Down Expand Up @@ -241,7 +241,7 @@ func TestNullsOr(t *testing.T) {
n1Choice, n2Choice := rng.Intn(len(nullsToChooseFrom)), rng.Intn(len(nullsToChooseFrom))
n1 := nullsToChooseFrom[n1Choice].Slice(0, length1)
n2 := nullsToChooseFrom[n2Choice].Slice(0, length2)
or := n1.Or(&n2)
or := n1.Or(n2)
require.Equal(t, or.maybeHasNulls, n1.maybeHasNulls || n2.maybeHasNulls)
maxLength := length1
if length2 > length1 {
Expand Down
6 changes: 3 additions & 3 deletions pkg/col/coldata/vec.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ type Vec interface {
Nulls() *Nulls

// SetNulls sets the nulls vector for this column.
SetNulls(*Nulls)
SetNulls(Nulls)

// Length returns the length of the slice that is underlying this Vec.
Length() int
Expand Down Expand Up @@ -294,8 +294,8 @@ func (m *memColumn) Nulls() *Nulls {
return &m.nulls
}

func (m *memColumn) SetNulls(n *Nulls) {
m.nulls = *n
func (m *memColumn) SetNulls(n Nulls) {
m.nulls = n
}

func (m *memColumn) Length() int {
Expand Down
452 changes: 226 additions & 226 deletions pkg/sql/colexec/colexecproj/proj_const_left_ops.eg.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pkg/sql/colexec/colexecproj/proj_const_ops_tmpl.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func _SET_PROJECTION(_HAS_NULLS bool) {
// If _HAS_NULLS is false, then there are no input Nulls. _outNulls is
// projVec.Nulls() so there is no need to call projVec.SetNulls().
// {{if _HAS_NULLS}}
projVec.SetNulls(_outNulls.Or(colNulls))
projVec.SetNulls(_outNulls.Or(*colNulls))
// {{end}}
// {{end}}
// {{end}}
Expand Down
824 changes: 412 additions & 412 deletions pkg/sql/colexec/colexecproj/proj_const_right_ops.eg.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions pkg/sql/colexec/colexecproj/proj_like_ops.eg.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading