Skip to content

Commit

Permalink
accomodate new optional values
Browse files Browse the repository at this point in the history
  • Loading branch information
dwelch-spike committed Oct 15, 2024
1 parent be3410a commit 4de4232
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 12 deletions.
4 changes: 2 additions & 2 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ func (c *Client) put(

putReq := &protos.PutRequest{
Key: protoKey,
WriteType: writeType,
WriteType: &writeType,
Fields: fields,
IgnoreMemQueueFull: ignoreMemQueueFull,
}
Expand Down Expand Up @@ -786,7 +786,7 @@ func (c *Client) IndexCreate(
Name: indexName,
},
Dimensions: dimensions,
VectorDistanceMetric: vectorDistanceMetric,
VectorDistanceMetric: &vectorDistanceMetric,
Field: vectorField,
SetFilter: set,
Params: params,
Expand Down
12 changes: 8 additions & 4 deletions utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"github.com/aerospike/avs-client-go/protos"
)

func projectionTypePtr(t protos.ProjectionType) *protos.ProjectionType {
return &t
}

func createUserPassCredential(username, password string) *protos.Credentials {
return &protos.Credentials{
Username: username,
Expand Down Expand Up @@ -44,23 +48,23 @@ func createVectorSearchRequest(
func createProjectionSpec(includeFields, excludeFields []string) *protos.ProjectionSpec {
spec := &protos.ProjectionSpec{
Include: &protos.ProjectionFilter{
Type: protos.ProjectionType_ALL,
Type: projectionTypePtr(protos.ProjectionType_ALL),
},
Exclude: &protos.ProjectionFilter{
Type: protos.ProjectionType_NONE,
Type: projectionTypePtr(protos.ProjectionType_NONE),
},
}

if includeFields != nil {
spec.Include = &protos.ProjectionFilter{
Type: protos.ProjectionType_SPECIFIED,
Type: projectionTypePtr(protos.ProjectionType_SPECIFIED),
Fields: includeFields,
}
}

if excludeFields != nil {
spec.Exclude = &protos.ProjectionFilter{
Type: protos.ProjectionType_SPECIFIED,
Type: projectionTypePtr(protos.ProjectionType_SPECIFIED),
Fields: excludeFields,
}
}
Expand Down
12 changes: 6 additions & 6 deletions utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ func TestCreateProjectionSpec(t *testing.T) {
excludeFields: nil,
expectedProjectionSpec: &protos.ProjectionSpec{
Include: &protos.ProjectionFilter{
Type: protos.ProjectionType_SPECIFIED,
Type: projectionTypePtr(protos.ProjectionType_SPECIFIED),
Fields: []string{"field1", "field2"},
},
Exclude: &protos.ProjectionFilter{
Type: protos.ProjectionType_NONE,
Type: projectionTypePtr(protos.ProjectionType_NONE),
},
},
},
Expand All @@ -34,10 +34,10 @@ func TestCreateProjectionSpec(t *testing.T) {
excludeFields: []string{"field3", "field4"},
expectedProjectionSpec: &protos.ProjectionSpec{
Include: &protos.ProjectionFilter{
Type: protos.ProjectionType_ALL,
Type: projectionTypePtr(protos.ProjectionType_ALL),
},
Exclude: &protos.ProjectionFilter{
Type: protos.ProjectionType_SPECIFIED,
Type: projectionTypePtr(protos.ProjectionType_SPECIFIED),
Fields: []string{"field3", "field4"},
},
},
Expand All @@ -48,10 +48,10 @@ func TestCreateProjectionSpec(t *testing.T) {
excludeFields: nil,
expectedProjectionSpec: &protos.ProjectionSpec{
Include: &protos.ProjectionFilter{
Type: protos.ProjectionType_ALL,
Type: projectionTypePtr(protos.ProjectionType_ALL),
},
Exclude: &protos.ProjectionFilter{
Type: protos.ProjectionType_NONE,
Type: projectionTypePtr(protos.ProjectionType_NONE),
},
},
},
Expand Down

0 comments on commit 4de4232

Please sign in to comment.