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: add SearchForInsert to vector index library #140763

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

andy-kimball
Copy link
Contributor

Add a SearchForInsert method to the VectorIndex class that searches for the best partition in which to insert a query vector. This will be used by the execution engine, which creates its own custom insertion batches rather than using VectorIndex.Insert. Add a GetPartitionMetadata method to the Store class that's used by SearchForInsert to efficiently get the centroid of the insert partition, as well as to check whether the partition is over-sized.

Epic: CRDB-42943

Release note: None

@cockroach-teamcity
Copy link
Member

This change is Reviewable

Add a SearchForInsert method to the VectorIndex class that searches for
the best partition in which to insert a query vector. This will be used
by the execution engine, which creates its own custom insertion batches
rather than using VectorIndex.Insert. Add a GetPartitionMetadata method
to the Store class that's used by SearchForInsert to efficiently get the
centroid of the insert partition, as well as to check whether the
partition is over-sized.

Epic: CRDB-42943

Release note: None
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: with nits.

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


pkg/sql/vecindex/vecstore/store.go line 112 at r1 (raw file):

	// ErrRestartOperation if the caller should retry the operation that triggered
	// this call.
	GetPartitionMetadata(

When would we call this with forUpdate=false? Can we simplify the method and have it always take a shared lock?


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

	// candidates for reranking and statistics (up to MaxExtraResults) that are
	// within the error threshold of being among the best results.
	// Note: When ForInsert mode is enabled, MaxResults must be set to 1.

nit: there's no ForInsert mode; this comment seems stale.


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

	// statistics. These results are within the error threshold of being among the
	// the best results.
	// NOTE: When

nit: incomplete comment.


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

// It always returns a single search result containing the key of that
// partition, as well as the centroid of the partition (in the Vector field).
func (vi *VectorIndex) SearchForInsert(

Would it be possible to call this method as part of Insert()? Also, could we do something similar for deletes?

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