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

vecindex: support deleting vectors from C-SPANN index #135230

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

andy-kimball
Copy link
Contributor

Add Delete method to the vector index, which attempts to remove a vector from the index, given its value and primary key. Delete may not be able to locate the vector in the index, leaving a "dangling vector" reference which other methods need to take care not to ignore.

Epic: CRDB-42943

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Collaborator

@DrewKimball DrewKimball left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 7 of 7 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @andy-kimball and @mw5h)


pkg/sql/vecindex/vector_index.go line 244 at r1 (raw file):

		defer searchCtx.Workspace.FreeVector(tempRandomized)
		vi.quantizer.RandomizeVector(ctx, vector, tempRandomized, false /* invert */)
		searchCtx.Randomized = tempRandomized

[nit] Is it possible to move some of this logic above the loop?


pkg/sql/vecindex/vector_index.go line 255 at r1 (raw file):

			// Retry search with significantly higher beam size.
			if baseBeamSize == vi.options.BaseBeamSize {
				baseBeamSize *= 8

If vi.options.BaseBeamSize was somehow zero, we'd have an infinite loop, right?


pkg/sql/vecindex/vecstore/search_set.go line 174 at r1 (raw file):

	// MatchKey, if non-nil, filters out all search candidates that do not have
	// a matching primary key.
	MatchKey PrimaryKey

Think we could make this more general down the line? For example, simple filters on the primary key columns or stored columns.

Copy link
Contributor Author

@andy-kimball andy-kimball 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! 1 of 0 LGTMs obtained (waiting on @DrewKimball and @mw5h)


pkg/sql/vecindex/vector_index.go line 244 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

[nit] Is it possible to move some of this logic above the loop?

Done.


pkg/sql/vecindex/vector_index.go line 255 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

If vi.options.BaseBeamSize was somehow zero, we'd have an infinite loop, right?

Done.


pkg/sql/vecindex/vecstore/search_set.go line 174 at r1 (raw file):

Previously, DrewKimball (Drew Kimball) wrote…

Think we could make this more general down the line? For example, simple filters on the primary key columns or stored columns.

In other prototypes, I've had other kinds of filters here. Never anything so general, but I have found it useful to have the flexibility.

Add Delete method to the vector index, which attempts to remove a vector
from the index, given its value and primary key. Delete may not be able
to locate the vector in the index, leaving a "dangling vector" reference
which other methods need to take care not to ignore.

Epic: CRDB-42943

Release note: None
@andy-kimball
Copy link
Contributor Author

bors r=drewkimball

craig bot pushed a commit that referenced this pull request Nov 15, 2024
135230: vecindex: support deleting vectors from C-SPANN index r=drewkimball a=andy-kimball

Add Delete method to the vector index, which attempts to remove a vector from the index, given its value and primary key. Delete may not be able to locate the vector in the index, leaving a "dangling vector" reference which other methods need to take care not to ignore.

Epic: CRDB-42943

Release note: None

Co-authored-by: Andrew Kimball <[email protected]>
@craig
Copy link
Contributor

craig bot commented Nov 15, 2024

Build failed:

@andy-kimball
Copy link
Contributor Author

bors r=drewkimball

@craig craig bot merged commit d2a21ee into cockroachdb:master Nov 15, 2024
23 checks passed
@andy-kimball andy-kimball deleted the delete branch November 15, 2024 19:28
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