From 2e5eba640e4ba339f03707fc4ae57ef4416a10e2 Mon Sep 17 00:00:00 2001 From: Edward Liang Date: Sat, 25 Jan 2025 10:27:04 -0800 Subject: [PATCH] Remove the need to sort Signed-off-by: Edward Liang --- go/api/base_client.go | 8 ++++---- go/api/response_handlers.go | 6 ------ go/integTest/shared_commands_test.go | 18 +++++++----------- 3 files changed, 11 insertions(+), 21 deletions(-) diff --git a/go/api/base_client.go b/go/api/base_client.go index cca71429ed..1a63420774 100644 --- a/go/api/base_client.go +++ b/go/api/base_client.go @@ -4543,8 +4543,8 @@ func (client *baseClient) BZPopMin(keys []string, timeoutSecs float64) (Result[K // Return value: // // An object containing the following elements: -// - The key name of the set from which the element was popped -// - An array of member scores of the popped elements in ascending order. +// - The key name of the set from which the element was popped. +// - An array of member scores of the popped elements. // Returns `nil` if no member could be popped and the timeout expired. // // For example: @@ -4609,8 +4609,8 @@ func (client *baseClient) BZMPop( // Return value: // // An object containing the following elements: -// - The key name of the set from which the element was popped -// - An array of member scores of the popped elements in ascending order. +// - The key name of the set from which the element was popped. +// - An array of member scores of the popped elements. // Returns `nil` if no member could be popped and the timeout expired. // // For example: diff --git a/go/api/response_handlers.go b/go/api/response_handlers.go index f0d03ef677..75f013af03 100644 --- a/go/api/response_handlers.go +++ b/go/api/response_handlers.go @@ -9,7 +9,6 @@ import "C" import ( "fmt" "reflect" - "sort" "strconv" "unsafe" @@ -578,11 +577,6 @@ func handleKeyWithArrayOfMembersAndScoresResponse( memberAndScoreArray = append(memberAndScoreArray, MemberAndScore{k, v}) } - // Ensure consistent output - sort.Slice(memberAndScoreArray, func(i, j int) bool { - return memberAndScoreArray[i].Score < memberAndScoreArray[j].Score - }) - return CreateKeyWithArrayOfMembersAndScoresResult(KeyWithArrayOfMembersAndScores{key, memberAndScoreArray}), nil } diff --git a/go/integTest/shared_commands_test.go b/go/integTest/shared_commands_test.go index b2a193c4ab..4d28d1121e 100644 --- a/go/integTest/shared_commands_test.go +++ b/go/integTest/shared_commands_test.go @@ -2915,18 +2915,14 @@ func (suite *GlideTestSuite) TestBZMPopAndBZMPopWithOptions() { // Try to pop the top 2 elements from key1 res5, err := client.BZMPopWithOptions([]string{key1}, api.MAX, float64(0.1), options.NewZMPopOptions().SetCount(2)) assert.Nil(suite.T(), err) - assert.Equal( + assert.Equal(suite.T(), key1, res5.Value().Key) + assert.ElementsMatch( suite.T(), - api.CreateKeyWithArrayOfMembersAndScoresResult( - api.KeyWithArrayOfMembersAndScores{ - Key: key1, - MembersAndScores: []api.MemberAndScore{ - {Member: "two", Score: 2.0}, - {Member: "three", Score: 3.0}, - }, - }, - ), - res5, + []api.MemberAndScore{ + {Member: "three", Score: 3.0}, + {Member: "two", Score: 2.0}, + }, + res5.Value().MembersAndScores, ) // Try to pop the minimum value from key2