@@ -169,6 +169,147 @@ void commandlogPushCurrentCommand(client *c, struct serverCommand *cmd) {
169169 commandlogPushEntryIfNeeded (c , argv , argc , net_output_bytes_curr_cmd , COMMANDLOG_TYPE_LARGE_REPLY );
170170}
171171
172+ // bigKeyInfo [string | set | hash | list | zset | xstream | all]
173+ void bigkeyInfoCommand (client * c ) {
174+ bool isDisplayAll = 0 ;
175+ bool isDisplayString = 0 ;
176+ bool isDisplaySet = 0 ;
177+ bool isDisplayHash = 0 ;
178+ bool isDisplayList = 0 ;
179+ bool isDisplayZset = 0 ;
180+ long totalLine = 0 ;
181+
182+ long count_string = listLength (server .string_bigkey_info );
183+ long count_list = listLength (server .list_bigkey_info );
184+ long count_hash = listLength (server .hash_bigkey_info );
185+ long count_set = listLength (server .set_bigkey_info );
186+ long count_zset = listLength (server .zset_bigkey_info );
187+
188+ if (c -> argc == 1 ) {
189+ isDisplayAll = 1 ;
190+ } else {
191+ int j = 1 ;
192+ while (j < c -> argc ) {
193+ char * opt = c -> argv [j ]-> ptr ;
194+ if (!strcasecmp (opt , "string" )) {
195+ isDisplayString = 1 ;
196+ } else if (!strcasecmp (opt , "set" )) {
197+ isDisplaySet = 1 ;
198+ } else if (!strcasecmp (opt , "hash" )) {
199+ isDisplayHash = 1 ;
200+ } else if (!strcasecmp (opt , "list" )) {
201+ isDisplayList = 1 ;
202+ } else if (!strcasecmp (opt , "zset" )) {
203+ isDisplayZset = 1 ;
204+ } else if (!strcasecmp (opt , "all" )) {
205+ isDisplayAll = 1 ;
206+ break ;
207+ } else {
208+ addReplyErrorFormat (c , "Unsupported option %s" , opt );
209+ return ;
210+ }
211+ j ++ ;
212+ }
213+ }
214+
215+ if (server .big_key_output < count_string ) {
216+ count_string = server .big_key_output ;
217+ }
218+ if (server .big_key_output < count_list ) {
219+ count_list = server .big_key_output ;
220+ }
221+ if (server .big_key_output < count_hash ) {
222+ count_hash = server .big_key_output ;
223+ }
224+ if (server .big_key_output < count_set ) {
225+ count_set = server .big_key_output ;
226+ }
227+ if (server .big_key_output < count_zset ) {
228+ count_zset = server .big_key_output ;
229+ }
230+
231+ if (isDisplayAll | isDisplayString ) {
232+ totalLine += count_string ;
233+ }
234+ if (isDisplayAll | isDisplaySet ) {
235+ totalLine += count_set ;
236+ }
237+ if (isDisplayAll | isDisplayHash ) {
238+ totalLine += count_hash ;
239+ }
240+ if (isDisplayAll | isDisplayList ) {
241+ totalLine += count_list ;
242+ }
243+ if (isDisplayAll | isDisplayZset ) {
244+ totalLine += count_zset ;
245+ }
246+
247+ addReplyArrayLen (c , totalLine );
248+
249+ listIter li ;
250+ listNode * ln ;
251+
252+ if (isDisplayAll | isDisplayString ) {
253+ listRewindTail (server .string_bigkey_info , & li );
254+ while (count_string -- ) {
255+ ln = listNext (& li );
256+ bigkeyEntry * bke = ln -> value ;
257+ addReplyArrayLen (c , 3 );
258+ addReplyLongLong (c , bke -> value );
259+ addReplyBulkCBuffer (c , bke -> key -> ptr , sdslen (bke -> key -> ptr ));
260+ addReplyBulkCString (c , "string" );
261+ }
262+ }
263+
264+ if (isDisplayAll | isDisplayList ) {
265+ listRewindTail (server .list_bigkey_info , & li );
266+ while (count_list -- ) {
267+ ln = listNext (& li );
268+ bigkeyEntry * bke = ln -> value ;
269+ addReplyArrayLen (c , 3 );
270+ addReplyLongLong (c , bke -> value );
271+ addReplyBulkCBuffer (c , bke -> key -> ptr , sdslen (bke -> key -> ptr ));
272+ addReplyBulkCString (c , "list" );
273+ }
274+ }
275+
276+ if (isDisplayAll | isDisplayHash ) {
277+ listRewindTail (server .hash_bigkey_info , & li );
278+ while (count_hash -- ) {
279+ ln = listNext (& li );
280+ bigkeyEntry * bke = ln -> value ;
281+ addReplyArrayLen (c , 3 );
282+ addReplyLongLong (c , bke -> value );
283+ addReplyBulkCBuffer (c , bke -> key -> ptr , sdslen (bke -> key -> ptr ));
284+ addReplyBulkCString (c , "hash" );
285+ }
286+ }
287+
288+ if (isDisplayAll | isDisplaySet ) {
289+ listRewindTail (server .set_bigkey_info , & li );
290+ while (count_set -- ) {
291+ ln = listNext (& li );
292+ bigkeyEntry * bke = ln -> value ;
293+ addReplyArrayLen (c , 3 );
294+ addReplyLongLong (c , bke -> value );
295+ addReplyBulkCBuffer (c , bke -> key -> ptr , sdslen (bke -> key -> ptr ));
296+ addReplyBulkCString (c , "set" );
297+ }
298+ }
299+
300+ if (isDisplayAll | isDisplayZset ) {
301+ listRewindTail (server .list_bigkey_info , & li );
302+ while (count_zset -- ) {
303+ ln = listNext (& li );
304+ bigkeyEntry * bke = ln -> value ;
305+ addReplyArrayLen (c , 3 );
306+ addReplyLongLong (c , bke -> value );
307+ addReplyBulkCBuffer (c , bke -> key -> ptr , sdslen (bke -> key -> ptr ));
308+ addReplyBulkCString (c , "Sorted Set" );
309+ }
310+ }
311+ }
312+
172313/* The SLOWLOG command. Implements all the subcommands needed to handle the
173314 * slow log. */
174315void slowlogCommand (client * c ) {
0 commit comments