From 6921c026eee45693e1a6f7d7dbfe30fa3a837da3 Mon Sep 17 00:00:00 2001 From: Kyle Kim Date: Thu, 27 Jun 2024 20:46:35 +0000 Subject: [PATCH] Minor revision - Updated the RESP3 response from array of maps to array of arrays. Signed-off-by: Kyle Kim --- src/cluster_slot_stats.c | 3 ++- src/commands/cluster-slot-stats.json | 14 +++++++++----- tests/unit/cluster/slot-stats.tcl | 7 +++---- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/cluster_slot_stats.c b/src/cluster_slot_stats.c index 90748510a1..c53ab659b5 100644 --- a/src/cluster_slot_stats.c +++ b/src/cluster_slot_stats.c @@ -75,7 +75,8 @@ static void collectAndSortSlotStats(slotStatForSort slot_stats[], int order_by, } static void addReplySlotStat(client *c, int slot) { - addReplyMapLen(c, 1); /* Map for (int) slot to (map) usage statistics. */ + addReplyArrayLen(c, 2); /* Array of size 2, where 0th index represents (int) slot, + * and 1st index represents (map) usage statistics. */ addReplyLongLong(c, slot); addReplyMapLen(c, 1); /* Nested map representing slot usage statistics. */ addReplyBulkCString(c, "key-count"); diff --git a/src/commands/cluster-slot-stats.json b/src/commands/cluster-slot-stats.json index 4fe6d70a76..ebbd5d1982 100644 --- a/src/commands/cluster-slot-stats.json +++ b/src/commands/cluster-slot-stats.json @@ -17,12 +17,16 @@ ], "reply_schema": { "type": "array", - "description": "Array of nested maps, where each map represents a slot and its respective usage statistics.", + "description": "Array of nested arrays, where the inner array element represents a slot and its respective usage statistics.", "items": { - "type": "object", - "description": "Map of a slot and its respective usage statistics.", - "additionalProperties": { - "type": "string" + "type": "array", + "description": "Array of size 2, where 0th index represents (int) slot, and 1st index represents (map) usage statistics.", + "items": { + "type": "object", + "description": "Map of slot usage statistics.", + "additionalProperties": { + "type": "string" + } } } }, diff --git a/tests/unit/cluster/slot-stats.tcl b/tests/unit/cluster/slot-stats.tcl index 97d8519cee..c2923dc8bb 100644 --- a/tests/unit/cluster/slot-stats.tcl +++ b/tests/unit/cluster/slot-stats.tcl @@ -9,10 +9,9 @@ proc convert_array_into_dict {slot_stats} { set res [dict create] foreach slot_stat $slot_stats { - # slot_stat is a map of (int) slot to (map) usage statistics. - dict for {slot stat} $slot_stat { - dict set res $slot $stat - } + # slot_stat is an array of size 2, where 0th index represents (int) slot, + # and 1st index represents (map) usage statistics. + dict set res [lindex $slot_stat 0] [lindex $slot_stat 1] } return $res }