-
Notifications
You must be signed in to change notification settings - Fork 9
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
Implement sparse index support #95
Conversation
…nt for new deserialization
… and associated methods, add some additional error validation for the different scenarios, update unit / integration tests
@@ -540,7 +540,7 @@ func (req CreatePodIndexRequest) TotalCount() int { | |||
// fmt.Printf("Successfully created pod index: %s", idx.Name) | |||
// } | |||
func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest) (*Index, error) { | |||
if in.Name == "" || in.Dimension == 0 || in.Metric == "" || in.Environment == "" || in.PodType == "" { | |||
if in.Name == "" || in.Dimension <= 0 || in.Metric == "" || in.Environment == "" || in.PodType == "" { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refining the check on Dimension
here - if it's negative we don't really need to make a request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Will Dimension <= 0 throw an error message "fields Name, Dimension, Metric, Environment, and Podtype must be included in CreatePodIndexRequest" even though the Dimension is included as a part of the request?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I can update to mention "positive Dimension" to make it a bit more clear.
@@ -549,6 +549,7 @@ func (c *Client) CreatePodIndex(ctx context.Context, in *CreatePodIndexRequest) | |||
pods := in.TotalCount() | |||
replicas := in.ReplicaCount() | |||
shards := in.ShardCount() | |||
vectorType := "dense" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sparse
cannot be selected for pod indexes so we default for the pod creation path.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
require.ErrorContainsf(t, err, "fields Name, Metric, Cloud, and Region must be included in CreateServerlessIndexRequest", err.Error()) | ||
} | ||
|
||
func TestCreateServerlessIndexInvalidSparseDimensionUnit(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The following are all unit tests to check the validation in the serverless creation path.
@@ -7,7 +7,7 @@ import ( | |||
"google.golang.org/protobuf/types/known/structpb" | |||
) | |||
|
|||
func TestMarshalIndexStatus(t *testing.T) { | |||
func TestMarshalIndexStatusUnit(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Noticed all these tests were missing the "Unit" suffix, which is needed for them to be included when running just test-unit
.
README.md
Outdated
} | ||
|
||
indexName := "my-serverless-index" | ||
vectorType := "dense" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
did you mean to show an example for vectorType = sparse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, left a few comments!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good
if in.Dimension != nil { | ||
return nil, fmt.Errorf("dimension should not be specified when VectorType is 'sparse'") | ||
} else if in.Metric != Dotproduct { | ||
return nil, fmt.Errorf("metric should be 'dotproduct' when VectorType is 'sparse'") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
metric should be optional for sparse.
Problem
2025-01
includes changes to support sparse indexes. We need to adjust several types and functions to support working with these kinds of indexes.Solution
CreateServerlessIndexRequest
to allow creatingsparse
ordense
serverless indexes.Index
struct to supportVectorType
andIndexEmbed
. Add newIndexEmbed
type.Type of Change
Test Plan
CI / CD (unit / integration tests)