26
26
#include "run_info.h"
27
27
#include "util/arr_rm_alloc.h"
28
28
#include "util/dict.h"
29
+ #include "util/string_utils.h"
29
30
#include "util/queue.h"
30
31
#include "version.h"
31
32
@@ -184,9 +185,9 @@ int RedisAI_ModelSet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
184
185
return RedisModule_ReplyWithError (ctx , "ERR Invalid DEVICE" );
185
186
}
186
187
187
- const char * tag = "" ;
188
+ RedisModuleString * tag = NULL ;
188
189
if (AC_AdvanceIfMatch (& ac , "TAG" )) {
189
- AC_GetString (& ac , & tag , NULL , 0 );
190
+ AC_GetRString (& ac , & tag , 0 );
190
191
}
191
192
192
193
unsigned long long batchsize = 0 ;
@@ -470,7 +471,8 @@ int RedisAI_ModelGet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv,
470
471
RedisModule_ReplyWithCString (ctx , mto -> devicestr );
471
472
472
473
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 );
474
476
475
477
RedisModule_ReplyWithCString (ctx , "batchsize" );
476
478
RedisModule_ReplyWithLongLong (ctx , (long )mto -> opts .batchsize );
@@ -539,15 +541,15 @@ int RedisAI_ModelScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
539
541
540
542
long long nkeys ;
541
543
RedisModuleString * * keys ;
542
- const char * * tags ;
544
+ RedisModuleString * * tags ;
543
545
RAI_ListStatsEntries (RAI_MODEL , & nkeys , & keys , & tags );
544
546
545
547
RedisModule_ReplyWithArray (ctx , nkeys );
546
548
547
549
for (long long i = 0 ; i < nkeys ; i ++ ) {
548
550
RedisModule_ReplyWithArray (ctx , 2 );
549
551
RedisModule_ReplyWithString (ctx , keys [i ]);
550
- RedisModule_ReplyWithCString (ctx , tags [i ]);
552
+ RedisModule_ReplyWithString (ctx , tags [i ]);
551
553
}
552
554
553
555
RedisModule_Free (keys );
@@ -633,7 +635,7 @@ int RedisAI_ScriptGet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
633
635
RedisModule_ReplyWithCString (ctx , "device" );
634
636
RedisModule_ReplyWithCString (ctx , sto -> devicestr );
635
637
RedisModule_ReplyWithCString (ctx , "tag" );
636
- RedisModule_ReplyWithCString (ctx , sto -> tag );
638
+ RedisModule_ReplyWithString (ctx , sto -> tag );
637
639
if (source ) {
638
640
RedisModule_ReplyWithCString (ctx , "source" );
639
641
RedisModule_ReplyWithCString (ctx , sto -> scriptdef );
@@ -682,9 +684,9 @@ int RedisAI_ScriptSet_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv
682
684
const char * devicestr ;
683
685
AC_GetString (& ac , & devicestr , NULL , 0 );
684
686
685
- const char * tag = "" ;
687
+ RedisModuleString * tag = NULL ;
686
688
if (AC_AdvanceIfMatch (& ac , "TAG" )) {
687
- AC_GetString (& ac , & tag , NULL , 0 );
689
+ AC_GetRString (& ac , & tag , 0 );
688
690
}
689
691
690
692
if (AC_IsAtEnd (& ac )) {
@@ -780,15 +782,15 @@ int RedisAI_ScriptScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **arg
780
782
781
783
long long nkeys ;
782
784
RedisModuleString * * keys ;
783
- const char * * tags ;
785
+ RedisModuleString * * tags ;
784
786
RAI_ListStatsEntries (RAI_SCRIPT , & nkeys , & keys , & tags );
785
787
786
788
RedisModule_ReplyWithArray (ctx , nkeys );
787
789
788
790
for (long long i = 0 ; i < nkeys ; i ++ ) {
789
791
RedisModule_ReplyWithArray (ctx , 2 );
790
792
RedisModule_ReplyWithString (ctx , keys [i ]);
791
- RedisModule_ReplyWithCString (ctx , tags [i ]);
793
+ RedisModule_ReplyWithString (ctx , tags [i ]);
792
794
}
793
795
794
796
RedisModule_Free (keys );
@@ -803,7 +805,7 @@ int RedisAI_ScriptScan_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **arg
803
805
int RedisAI_Info_RedisCommand (RedisModuleCtx * ctx , RedisModuleString * * argv , int argc ) {
804
806
if (argc != 2 && argc != 3 )
805
807
return RedisModule_WrongArity (ctx );
806
- const char * runkey = RedisModule_StringPtrLen ( argv [1 ], NULL ) ;
808
+ RedisModuleString * runkey = argv [1 ];
807
809
struct RedisAI_RunStats * rstats = NULL ;
808
810
if (RAI_GetRunStats (runkey , & rstats ) == REDISMODULE_ERR ) {
809
811
return RedisModule_ReplyWithError (ctx , "ERR cannot find run info for key" );
@@ -833,7 +835,11 @@ int RedisAI_Info_RedisCommand(RedisModuleCtx *ctx, RedisModuleString **argv, int
833
835
RedisModule_ReplyWithCString (ctx , "device" );
834
836
RedisModule_ReplyWithCString (ctx , rstats -> devicestr );
835
837
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
+ }
837
843
RedisModule_ReplyWithCString (ctx , "duration" );
838
844
RedisModule_ReplyWithLongLong (ctx , rstats -> duration_us );
839
845
RedisModule_ReplyWithCString (ctx , "samples" );
@@ -1209,9 +1215,7 @@ int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc)
1209
1215
return REDISMODULE_ERR ;
1210
1216
}
1211
1217
1212
- run_stats = AI_dictCreate (& AI_dictTypeHeapStrings , NULL );
1218
+ run_stats = AI_dictCreate (& AI_dictTypeHeapRStrings , NULL );
1213
1219
1214
1220
return REDISMODULE_OK ;
1215
1221
}
1216
-
1217
- extern AI_dictType AI_dictTypeHeapStrings ;
0 commit comments