2626#include "run_info.h"
2727#include "util/arr_rm_alloc.h"
2828#include "util/dict.h"
29+ #include "util/string_utils.h"
2930#include "util/queue.h"
3031#include "version.h"
3132
@@ -184,9 +185,9 @@ int RedisAI_ModelSet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
184185 return RedisModule_ReplyWithError (ctx , "ERR Invalid DEVICE" );
185186 }
186187
187- const char * tag = "" ;
188+ RedisModuleString * tag = NULL ;
188189 if (AC_AdvanceIfMatch (& ac , "TAG" )) {
189- AC_GetString (& ac , & tag , NULL , 0 );
190+ AC_GetRString (& ac , & tag , 0 );
190191 }
191192
192193 unsigned long long batchsize = 0 ;
@@ -470,7 +471,8 @@ int RedisAI_ModelGet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
470471 RedisModule_ReplyWithCString (ctx , mto -> devicestr );
471472
472473 RedisModule_ReplyWithCString (ctx , "tag" );
473- RedisModule_ReplyWithCString (ctx , mto -> tag ? mto -> tag : "" );
474+ RedisModuleString * empty_tag = RedisModule_CreateString (ctx , "" , 0 );
475+ RedisModule_ReplyWithString (ctx , mto -> tag ? mto -> tag : empty_tag );
474476
475477 RedisModule_ReplyWithCString (ctx , "batchsize" );
476478 RedisModule_ReplyWithLongLong (ctx , (long )mto -> opts .batchsize );
@@ -539,15 +541,15 @@ int RedisAI_ModelScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
539541
540542 long long nkeys ;
541543 RedisModuleString * * keys ;
542- const char * * tags ;
544+ RedisModuleString * * tags ;
543545 RAI_ListStatsEntries (RAI_MODEL , & nkeys , & keys , & tags );
544546
545547 RedisModule_ReplyWithArray (ctx , nkeys );
546548
547549 for (long long i = 0 ; i < nkeys ; i ++ ) {
548550 RedisModule_ReplyWithArray (ctx , 2 );
549551 RedisModule_ReplyWithString (ctx , keys [i ]);
550- RedisModule_ReplyWithCString (ctx , tags [i ]);
552+ RedisModule_ReplyWithString (ctx , tags [i ]);
551553 }
552554
553555 RedisModule_Free (keys );
@@ -633,7 +635,7 @@ int RedisAI_ScriptGet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
633635 RedisModule_ReplyWithCString (ctx , "device" );
634636 RedisModule_ReplyWithCString (ctx , sto -> devicestr );
635637 RedisModule_ReplyWithCString (ctx , "tag" );
636- RedisModule_ReplyWithCString (ctx , sto -> tag );
638+ RedisModule_ReplyWithString (ctx , sto -> tag );
637639 if (source ) {
638640 RedisModule_ReplyWithCString (ctx , "source" );
639641 RedisModule_ReplyWithCString (ctx , sto -> scriptdef );
@@ -682,9 +684,9 @@ int RedisAI_ScriptSet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
682684 const char * devicestr ;
683685 AC_GetString (& ac , & devicestr , NULL , 0 );
684686
685- const char * tag = "" ;
687+ RedisModuleString * tag = NULL ;
686688 if (AC_AdvanceIfMatch (& ac , "TAG" )) {
687- AC_GetString (& ac , & tag , NULL , 0 );
689+ AC_GetRString (& ac , & tag , 0 );
688690 }
689691
690692 if (AC_IsAtEnd (& ac )) {
@@ -780,15 +782,15 @@ int RedisAI_ScriptScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **arg
780782
781783 long long nkeys ;
782784 RedisModuleString * * keys ;
783- const char * * tags ;
785+ RedisModuleString * * tags ;
784786 RAI_ListStatsEntries (RAI_SCRIPT , & nkeys , & keys , & tags );
785787
786788 RedisModule_ReplyWithArray (ctx , nkeys );
787789
788790 for (long long i = 0 ; i < nkeys ; i ++ ) {
789791 RedisModule_ReplyWithArray (ctx , 2 );
790792 RedisModule_ReplyWithString (ctx , keys [i ]);
791- RedisModule_ReplyWithCString (ctx , tags [i ]);
793+ RedisModule_ReplyWithString (ctx , tags [i ]);
792794 }
793795
794796 RedisModule_Free (keys );
@@ -803,7 +805,7 @@ int RedisAI_ScriptScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **arg
803805int RedisAI_Info_RedisCommand (RedisModuleCtx * ctx , RedisModuleString * * argv , int argc ) {
804806 if (argc != 2 && argc != 3 )
805807 return RedisModule_WrongArity (ctx );
806- const char * runkey = RedisModule_StringPtrLen ( argv [1 ], NULL ) ;
808+ RedisModuleString * runkey = argv [1 ];
807809 struct RedisAI_RunStats * rstats = NULL ;
808810 if (RAI_GetRunStats (runkey , & rstats ) == REDISMODULE_ERR ) {
809811 return RedisModule_ReplyWithError (ctx , "ERR cannot find run info for key" );
@@ -833,7 +835,11 @@ int RedisAI_Info_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
833835 RedisModule_ReplyWithCString (ctx , "device" );
834836 RedisModule_ReplyWithCString (ctx , rstats -> devicestr );
835837 RedisModule_ReplyWithCString (ctx , "tag" );
836- RedisModule_ReplyWithCString (ctx , rstats -> tag );
838+ if (rstats -> tag ) {
839+ RedisModule_ReplyWithString (ctx , rstats -> tag );
840+ } else {
841+ RedisModule_ReplyWithCString (ctx , "" );
842+ }
837843 RedisModule_ReplyWithCString (ctx , "duration" );
838844 RedisModule_ReplyWithLongLong (ctx , rstats -> duration_us );
839845 RedisModule_ReplyWithCString (ctx , "samples" );
@@ -1209,9 +1215,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
12091215 return REDISMODULE_ERR ;
12101216 }
12111217
1212- run_stats = AI_dictCreate (& AI_dictTypeHeapStrings , NULL );
1218+ run_stats = AI_dictCreate (& AI_dictTypeHeapRStrings , NULL );
12131219
12141220 return REDISMODULE_OK ;
12151221}
1216-
1217- extern AI_dictType AI_dictTypeHeapStrings ;
0 commit comments