From 7e949bb0a3511e7f6d2ef08935fe76441f2ad22c Mon Sep 17 00:00:00 2001 From: umit Date: Wed, 2 Oct 2024 21:36:28 +0300 Subject: [PATCH] Remove set type Signed-off-by: umit --- go/api/base_client.go | 1 - go/api/response_handlers.go | 6 +++--- go/integTest/shared_commands_test.go | 1 - go/src/lib.rs | 26 +++----------------------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/go/api/base_client.go b/go/api/base_client.go index 12b315ded7..0b3c9dd13b 100644 --- a/go/api/base_client.go +++ b/go/api/base_client.go @@ -515,7 +515,6 @@ func (client *baseClient) RPush(key string, elements []string) (Result[int64], e return handleLongResponse(result) } - func (client *baseClient) SAdd(key string, members []string) (Result[int64], error) { result, err := client.executeCommand(C.SAdd, append([]string{key}, members...)) if err != nil { diff --git a/go/api/response_handlers.go b/go/api/response_handlers.go index 08714c8b22..088624a885 100644 --- a/go/api/response_handlers.go +++ b/go/api/response_handlers.go @@ -207,13 +207,13 @@ func handleStringToStringMapResponse(response *C.struct_CommandResponse) (map[Re func handleStringSetResponse(response *C.struct_CommandResponse) (map[Result[string]]struct{}, error) { defer C.free_command_response(response) - typeErr := checkResponseType(response, C.Sets, false) + typeErr := checkResponseType(response, C.Array, false) if typeErr != nil { return nil, typeErr } - slice := make(map[Result[string]]struct{}, response.sets_value_len) - for _, v := range unsafe.Slice(response.sets_value, response.sets_value_len) { + slice := make(map[Result[string]]struct{}, response.array_value_len) + for _, v := range unsafe.Slice(response.array_value, response.array_value_len) { res, err := convertCharArrayToString(&v, true) if err != nil { return nil, err diff --git a/go/integTest/shared_commands_test.go b/go/integTest/shared_commands_test.go index b069416059..a0e02a0a89 100644 --- a/go/integTest/shared_commands_test.go +++ b/go/integTest/shared_commands_test.go @@ -1230,7 +1230,6 @@ func (suite *GlideTestSuite) TestRPush() { }) } - func (suite *GlideTestSuite) TestSAdd() { suite.runWithDefaultClients(func(client api.BaseClient) { key := uuid.NewString() diff --git a/go/src/lib.rs b/go/src/lib.rs index 021561d708..d0037b39c2 100644 --- a/go/src/lib.rs +++ b/go/src/lib.rs @@ -57,13 +57,6 @@ pub struct CommandResponse { map_key: *mut CommandResponse, #[derivative(Default(value = "std::ptr::null_mut()"))] map_value: *mut CommandResponse, - - /// Below two values are related to each other. - /// `sets_value` represents the set of CommandResponse. - /// `sets_value_len` represents the length of the set. - #[derivative(Default(value = "std::ptr::null_mut()"))] - sets_value: *mut CommandResponse, - sets_value_len: c_long, } #[repr(C)] @@ -77,7 +70,6 @@ pub enum ResponseType { String = 4, Array = 5, Map = 6, - Sets = 7, } /// Success callback that is called when a command succeeds. @@ -252,7 +244,6 @@ pub extern "C" fn get_response_type_string(response_type: ResponseType) -> *mut ResponseType::String => "String", ResponseType::Array => "Array", ResponseType::Map => "Map", - ResponseType::Sets => "Sets", }; let c_str = CString::new(s).unwrap_or_default(); c_str.into_raw() @@ -300,8 +291,6 @@ pub unsafe extern "C" fn free_command_response(command_response_ptr: *mut Comman /// * The contained `map_key` must be valid until `free_command_response` is called and it must outlive the `CommandResponse` that contains it. /// * The contained `map_value` must be obtained from the `CommandResponse` returned in [`SuccessCallback`] from [`command`]. /// * The contained `map_value` must be valid until `free_command_response` is called and it must outlive the `CommandResponse` that contains it. -/// * The contained `sets_value` must be obtained from the `CommandResponse` returned in [`SuccessCallback`] from [`command`]. -/// * The contained `sets_value` must be valid until `free_command_response` is called and it must outlive the `CommandResponse` that contains it. fn free_command_response_elements(command_response: CommandResponse) { let string_value = command_response.string_value; let string_value_len = command_response.string_value_len; @@ -309,8 +298,6 @@ fn free_command_response_elements(command_response: CommandResponse) { let array_value_len = command_response.array_value_len; let map_key = command_response.map_key; let map_value = command_response.map_value; - let sets_value = command_response.sets_value; - let sets_value_len = command_response.sets_value_len; if !string_value.is_null() { let len = string_value_len as usize; unsafe { Vec::from_raw_parts(string_value, len, len) }; @@ -328,13 +315,6 @@ fn free_command_response_elements(command_response: CommandResponse) { if !map_value.is_null() { unsafe { free_command_response(map_value) }; } - if !sets_value.is_null() { - let len = sets_value_len as usize; - let vec = unsafe { Vec::from_raw_parts(sets_value, len, len) }; - for element in vec.into_iter() { - free_command_response_elements(element); - } - } } /// Frees the error_message received on a command failure. @@ -482,9 +462,9 @@ fn valkey_value_to_command_response(value: Value) -> RedisResult