Skip to content

sql: use IndexFetchSpec for inverted joiner#77875

Merged
craig[bot] merged 3 commits intocockroachdb:masterfrom
RaduBerinde:inv-joiner-fetch-spec
Mar 17, 2022
Merged

sql: use IndexFetchSpec for inverted joiner#77875
craig[bot] merged 3 commits intocockroachdb:masterfrom
RaduBerinde:inv-joiner-fetch-spec

Conversation

@RaduBerinde
Copy link
Copy Markdown
Member

rowexec: address TODO in inverted joiner

This commit addresses a TODO in the inverted joiner. We now reuse a
buffer for encoding the prefix key. In the general case we still need
to make a copy since we are storing multiple prefix keys; but now we
try to reuse the last copy if the prefix is the same.

We also remove the temporary use of indexRow which is confusing here
(it wasn't obvious at first but this code has nothing to do with index
rows and is just using indexRow as a temporary buffer).

Release note: None

geoindex: minor cleanup around Config

This change changes IsEmptyConfig, IsGeographyConfig,
IsGeometryConfig to methods on the geoindex.Config type.

We also switch to passing configs by value which is cleaner and avoids
some allocations.

Release note: None

sql: use IndexFetchSpec for inverted joiner

This commit reworks the InvertedJoiner to use an IndexFetchSpec
instead of table and index descriptors.

The "internal schema" now matches the fetched columns (leading to
simplifications in both planning and execution code).

Release note: None

@RaduBerinde RaduBerinde requested review from a team, mgartner and yuzefovich March 16, 2022 02:41
@RaduBerinde RaduBerinde requested a review from a team as a code owner March 16, 2022 02:41
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
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 cleanup! :lgtm:

Reviewed 2 of 2 files at r1, 17 of 17 files at r2, 18 of 18 files at r3, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @mgartner and @RaduBerinde)


-- commits, line 18 at r2:
nit: "change changes" sounds not good :)


pkg/sql/opt/cat/index.go, line 190 at r2 (raw file):

	ImplicitPartitioningColumnCount() int

	// GeoConfig returns a geospatial index configuration. If non-nil, it

nit: "not-nil" is no longer applicable.


pkg/sql/rowexec/inverted_joiner.go, line 459 at r1 (raw file):

			} else {
				keyCols := ij.desc.IndexFetchSpecKeyAndSuffixColumns(ij.index)
				// Encode the prefix key; we reuse a buffer to avoid extra allocations when appending values.

nit: seems like a long line.

This commit addresses a TODO in the inverted joiner. We now reuse a
buffer for encoding the prefix key. In the general case we still need
to make a copy since we are storing multiple prefix keys; but now we
try to reuse the last copy if the prefix is the same.

We also remove the temporary use of `indexRow` which is confusing here
(it wasn't obvious at first but this code has nothing to do with index
rows and is just using `indexRow` as a temporary buffer).

Release note: None
This commit replaces `IsEmptyConfig`, `IsGeographyConfig`,
`IsGeometryConfig` with methods on the `geoindex.Config` type.

We also switch to passing configs by value which is cleaner and avoids
some allocations.

Release note: None
This commit reworks the InvertedJoiner to use an IndexFetchSpec
instead of table and index descriptors.

The "internal schema" now matches the fetched columns (leading to
simplifications in both planning and execution code).

Release note: None
@RaduBerinde RaduBerinde force-pushed the inv-joiner-fetch-spec branch from 7ade8f3 to f43648a Compare March 17, 2022 16:22
Copy link
Copy Markdown
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

TFTR!

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @mgartner and @yuzefovich)

@RaduBerinde
Copy link
Copy Markdown
Member Author

bors r+

Copy link
Copy Markdown
Contributor

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

:lgtm: Nice cleanup! Sorry for the late drive-by.

Reviewed 1 of 2 files at r1, 34 of 34 files at r4, 17 of 17 files at r5, 18 of 18 files at r6, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (and 1 stale) (waiting on @RaduBerinde)


pkg/geo/geoindex/config.go, line 14 at r5 (raw file):

// IsEmpty returns whether the config contains a geospatial index
// configuration.

nit: I know you just copied the comments from before, but "returns whether ..." is less clear than "returns true if ...". Ditto for the other comments below.

@craig craig bot merged commit 1a35e55 into cockroachdb:master Mar 17, 2022
@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 17, 2022

Build succeeded:

@RaduBerinde RaduBerinde deleted the inv-joiner-fetch-spec branch March 19, 2022 01:33
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