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

exec: Update NULL handling in Vec Copy #38669

Merged
merged 1 commit into from
Jul 8, 2019
Merged

Conversation

rohany
Copy link
Contributor

@rohany rohany commented Jul 3, 2019

The copy method in Vec previously unset ALL NULL values in the
destination vector, and then proceeded to set the appropriate
NULL values from the source vector, which is incorrect. To address
this problem, this commit adds a UnsetNullRange operation to
the Nulls object. The operation unsets all null values within an
input range, but is unable to smartly/efficiently identify when
the vector no longer contains any null values. The best way
to address this problem can be left to future PR's and discussion.

Depends on #38654. Until that is landed, look at the latest commit to review.

@rohany rohany requested review from solongordon, yuzefovich, asubiotto and a team July 3, 2019 19:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! I didn't have any comments about the first commit when I looked earlier but left a few about the second. Overall, it looks good to me.

Reviewed 4 of 4 files at r2.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @rohany, @solongordon, and @yuzefovich)


pkg/sql/exec/coldata/nulls.go, line 117 at r2 (raw file):

}

// UnsetNullRange unsets all the nulls in the range [start, end).

nit: I'd mention the limitation about not maintaining hasNulls field up to date at the moment (unless you're planning on tackling that next in which case ignore this).


pkg/sql/exec/coldata/nulls.go, line 137 at r2 (raw file):

	// Case where mask spans at least two bytes.
	if sIdx < eIdx {

This if seems unnecessary (the condition is always true since we know that start < end and sIdx != eIdx. (Ditto for SetNullRange.)


pkg/sql/exec/coldata/nulls_test.go, line 82 at r2 (raw file):

			n.UnsetNullRange(start, end)
			for i := uint64(0); i < BatchSize; i++ {
				expected := i >= start && i < end

nit: it is a little unusual to have "expected" and then do "not equal to unexpected." I'd negate either negate the condition or the variable name.


pkg/sql/exec/coldata/vec_test.go, line 337 at r2 (raw file):

	dst.Copy(copyArgs)

	// Verify that original nulls arent deleted, and that

pkg/sql/exec/coldata/vec_test.go, line 350 at r2 (raw file):

	// Verify that the remaining elements in dst have not been touched.
	for i := 10; i < BatchSize; i++ {
		require.True(t, dstInts[i] == 1, "data in dst outside copy range has been changed")

I'd also add a check for not having nulls in this loop.

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @rohany, @solongordon, and @yuzefovich)


pkg/sql/exec/coldata/nulls_test.go, line 82 at r2 (raw file):

Previously, yuzefovich wrote…

[nit]: it is a little unusual to have "expected" and then do "not equal to unexpected." I'd negate either negate the condition or the variable name.

*I'd either negate ...


pkg/sql/exec/coldata/vec_test.go, line 339 at r2 (raw file):

	// Verify that original nulls arent deleted, and that
	// the nulls in the source have been copied over.
	for i := 0; i < 8; i++ {

The empty comment above was: "[nit]: s/arent/aren't/."

Copy link
Contributor Author

@rohany rohany left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @solongordon, and @yuzefovich)


pkg/sql/exec/coldata/nulls.go, line 117 at r2 (raw file):

Previously, yuzefovich wrote…

nit: I'd mention the limitation about not maintaining hasNulls field up to date at the moment (unless you're planning on tackling that next in which case ignore this).

Done.


pkg/sql/exec/coldata/nulls.go, line 137 at r2 (raw file):

Previously, yuzefovich wrote…

This if seems unnecessary (the condition is always true since we know that start < end and sIdx != eIdx. (Ditto for SetNullRange.)

Done.


pkg/sql/exec/coldata/nulls_test.go, line 82 at r2 (raw file):

Previously, yuzefovich wrote…

*I'd either negate ...

Done.


pkg/sql/exec/coldata/vec_test.go, line 337 at r2 (raw file):

Previously, yuzefovich wrote…

Done.


pkg/sql/exec/coldata/vec_test.go, line 339 at r2 (raw file):

Previously, yuzefovich wrote…

The empty comment above was: "nit: s/arent/aren't/."

Done.


pkg/sql/exec/coldata/vec_test.go, line 350 at r2 (raw file):

Previously, yuzefovich wrote…

I'd also add a check for not having nulls in this loop.

Done.

Copy link
Contributor

@solongordon solongordon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @asubiotto, @solongordon, and @yuzefovich)

The copy method in Vec previously unset ALL NULL values in the
destination vector, and then proceeded to set the appropriate
NULL values from the source vector, which is incorrect. To address
this problem, this commit adds a UnsetNullRange operation to
the Nulls object. The operation unsets all null values within an
input range, but is unable to smartly/efficiently identify when
the vector no longer contains any null values. The best way
to address this problem can be left to future PR's and discussion.

Release note: None
@rohany
Copy link
Contributor Author

rohany commented Jul 8, 2019

bors r+

craig bot pushed a commit that referenced this pull request Jul 8, 2019
38669: exec: Update NULL handling in Vec Copy r=rohany a=rohany

The copy method in Vec previously unset ALL NULL values in the
destination vector, and then proceeded to set the appropriate
NULL values from the source vector, which is incorrect. To address
this problem, this commit adds a UnsetNullRange operation to
the Nulls object. The operation unsets all null values within an
input range, but is unable to smartly/efficiently identify when
the vector no longer contains any null values. The best way
to address this problem can be left to future PR's and discussion.

Depends on #38654. Until that is landed, look at the latest commit to review.


Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
@craig
Copy link
Contributor

craig bot commented Jul 8, 2019

Build succeeded

@craig craig bot merged commit dd2c287 into cockroachdb:master Jul 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants