Skip to content

exec: distinct manages its own scratch column#31881

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:distinct-own-col
Oct 26, 2018
Merged

exec: distinct manages its own scratch column#31881
craig[bot] merged 1 commit intocockroachdb:masterfrom
jordanlewis:distinct-own-col

Conversation

@jordanlewis
Copy link
Copy Markdown
Member

Previously, distinct relied on its input batch to have a scratch boolean
column for working. It's unnecessary - instead, manage the scratch
boolean directly during construction.

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@jordanlewis jordanlewis force-pushed the distinct-own-col branch 2 times, most recently from cf5d204 to 22b236e Compare October 25, 2018 17:28
Copy link
Copy Markdown
Contributor

@asubiotto asubiotto left a comment

Choose a reason for hiding this comment

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

Mind running the benchmarks? Don't expect anything to change but I think it's good to get into the habit of doing this when modifying operators.

Reviewed 3 of 3 files at r1.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/exec/distinct.go, line 31 at r1 (raw file):

	sortedDistinctCol int

	// outputColIdx is the boolean output column.

s/outputColIdx/outputCol


pkg/sql/exec/distinct.go, line 50 at r1 (raw file):

// input columns with the given types.
func NewOrderedDistinct(input Operator, distinctCols []uint32, typs []types.T) (Operator, error) {
	distinctCol := make([]bool, ColBatchSize)

Maybe add a comment about how distinctCol is shared between many operators?


pkg/sql/exec/distinct.go, line 138 at r1 (raw file):

	input Operator

	// outputColIdx is the boolean output column from previous

s/outputColIdx/outputCol


pkg/sql/exec/distinct_test.go, line 56 at r1 (raw file):

	for _, tc := range tcs {
		runTests(t, tc.tuples, []types.T{}, func(t *testing.T, input Operator) {
			distinct, err := NewOrderedDistinct(input, tc.distinctCols, tc.colTypes)

Do you need to call Init on this?

Copy link
Copy Markdown
Member Author

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

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

BenchmarkSortedDistinct-8 500000 2834 ns/op 8671.00 MB/s

they're the same.

TFTRs!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained


pkg/sql/exec/distinct.go, line 31 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

s/outputColIdx/outputCol

Done.


pkg/sql/exec/distinct.go, line 50 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

Maybe add a comment about how distinctCol is shared between many operators?

Done.


pkg/sql/exec/distinct.go, line 138 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

s/outputColIdx/outputCol

Done.


pkg/sql/exec/distinct_test.go, line 56 at r1 (raw file):

Previously, asubiotto (Alfonso Subiotto Marqués) wrote…

Do you need to call Init on this?

No, the test framework automatically inits the bottom op in the chain, which will propagate everywhere.

Previously, distinct relied on its input batch to have a scratch boolean
column for working. It's unnecessary - instead, manage the scratch
boolean directly during construction.

Release note: None
@jordanlewis
Copy link
Copy Markdown
Member Author

bors r+

craig bot pushed a commit that referenced this pull request Oct 26, 2018
31881: exec: distinct manages its own scratch column r=jordanlewis a=jordanlewis

Previously, distinct relied on its input batch to have a scratch boolean
column for working. It's unnecessary - instead, manage the scratch
boolean directly during construction.

Release note: None

31926: storage: adjust raft log size correctly when replacing sideloaded entries r=nvanbenschoten a=tschottdorf

This follows up on a comment of @nvanbenschoten in #31914 which highlighted yet
another potential (though hopefully rare) source of raft log size not being
reduced correctly.

Release note: None

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
Co-authored-by: Tobias Schottdorf <tobias.schottdorf@gmail.com>
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 26, 2018

Build succeeded

@craig craig bot merged commit 758d1c7 into cockroachdb:master Oct 26, 2018
@jordanlewis jordanlewis deleted the distinct-own-col branch October 28, 2018 16:44
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.

3 participants