From 4de4232a68fa39fbcbf2de1061ec8884cba0d0da Mon Sep 17 00:00:00 2001 From: dylan Date: Tue, 15 Oct 2024 15:46:34 -0700 Subject: [PATCH] accomodate new optional values --- client.go | 4 ++-- utils.go | 12 ++++++++---- utils_test.go | 12 ++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/client.go b/client.go index 7ab2af2..2c474e5 100644 --- a/client.go +++ b/client.go @@ -163,7 +163,7 @@ func (c *Client) put( putReq := &protos.PutRequest{ Key: protoKey, - WriteType: writeType, + WriteType: &writeType, Fields: fields, IgnoreMemQueueFull: ignoreMemQueueFull, } @@ -786,7 +786,7 @@ func (c *Client) IndexCreate( Name: indexName, }, Dimensions: dimensions, - VectorDistanceMetric: vectorDistanceMetric, + VectorDistanceMetric: &vectorDistanceMetric, Field: vectorField, SetFilter: set, Params: params, diff --git a/utils.go b/utils.go index c895790..92f40f0 100644 --- a/utils.go +++ b/utils.go @@ -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, @@ -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, } } diff --git a/utils_test.go b/utils_test.go index 532ad1f..307a3ce 100644 --- a/utils_test.go +++ b/utils_test.go @@ -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), }, }, }, @@ -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"}, }, }, @@ -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), }, }, },