@@ -18,15 +18,14 @@ use hnsw::{Index, Node};
1818use redis_module:: {
1919 Context , RedisError , RedisResult , RedisValue ,
2020} ;
21- use redismodule_cmd:: Command ;
21+ use redismodule_cmd:: { Command , ArgType , Collection } ;
2222use std:: collections:: { HashMap , HashSet } ;
2323use std:: collections:: hash_map:: Entry ;
2424use std:: sync:: { Arc , RwLock , RwLockWriteGuard } ;
2525use types:: * ;
2626
2727static PREFIX : & str = "hnsw" ;
2828
29- // type IndexArc = Arc<RwLock<Index<f32, f32>>>;
3029type IndexT = Index < f32 , f32 > ;
3130
3231lazy_static ! {
@@ -38,58 +37,58 @@ thread_local! {
3837 static NEW_INDEX_CMD : Command = command!{
3938 name: "hnsw.new" ,
4039 args: [
41- [ "name" , String , false , None , false ] ,
42- [ "dim" , u64 , false , None , true ] ,
43- [ "m" , u64 , false , Some ( Box :: new( 5_u64 ) ) , true ] ,
44- [ "efcon" , u64 , false , Some ( Box :: new( 200_u64 ) ) , true ] ,
40+ [ "name" , ArgType :: Arg , String , Collection :: Unit , None ] ,
41+ [ "dim" , ArgType :: Kwarg , u64 , Collection :: Unit , None ] ,
42+ [ "m" , ArgType :: Kwarg , u64 , Collection :: Unit , Some ( Box :: new( 5_u64 ) ) ] ,
43+ [ "efcon" , ArgType :: Kwarg , u64 , Collection :: Unit , Some ( Box :: new( 200_u64 ) ) ] ,
4544 ] ,
4645 } ;
4746
4847 static GET_INDEX_CMD : Command = command!{
4948 name: "hnsw.get" ,
5049 args: [
51- [ "name" , String , false , None , false ] ,
50+ [ "name" , ArgType :: Arg , String , Collection :: Unit , None ] ,
5251 ] ,
5352 } ;
5453
5554 static DEL_INDEX_CMD : Command = command!{
5655 name: "hnsw.del" ,
5756 args: [
58- [ "name" , String , false , None , false ] ,
57+ [ "name" , ArgType :: Arg , String , Collection :: Unit , None ] ,
5958 ] ,
6059 } ;
6160
6261 static ADD_NODE_CMD : Command = command!{
6362 name: "hnsw.node.add" ,
6463 args: [
65- [ "index" , String , false , None , false ] ,
66- [ "node" , String , false , None , false ] ,
67- [ "data" , f64 , true , None , true ] ,
64+ [ "index" , ArgType :: Arg , String , Collection :: Unit , None ] ,
65+ [ "node" , ArgType :: Arg , String , Collection :: Unit , None ] ,
66+ [ "data" , ArgType :: Kwarg , f64 , Collection :: Vec , None ] ,
6867 ] ,
6968 } ;
7069
7170 static GET_NODE_CMD : Command = command!{
7271 name: "hnsw.node.get" ,
7372 args: [
74- [ "index" , String , false , None , false ] ,
75- [ "node" , String , false , None , false ] ,
73+ [ "index" , ArgType :: Arg , String , Collection :: Unit , None ] ,
74+ [ "node" , ArgType :: Arg , String , Collection :: Unit , None ] ,
7675 ] ,
7776 } ;
7877
7978 static DEL_NODE_CMD : Command = command!{
8079 name: "hnsw.node.del" ,
8180 args: [
82- [ "index" , String , false , None , false ] ,
83- [ "node" , String , false , None , false ] ,
81+ [ "index" , ArgType :: Arg , String , Collection :: Unit , None ] ,
82+ [ "node" , ArgType :: Arg , String , Collection :: Unit , None ] ,
8483 ] ,
8584 } ;
8685
8786 static SEARCH_CMD : Command = command!{
8887 name: "hnsw.search" ,
8988 args: [
90- [ "index" , String , false , None , false ] ,
91- [ "k" , u64 , false , Some ( Box :: new( 5_u64 ) ) , true ] ,
92- [ "query" , f64 , true , None , true ] ,
89+ [ "index" , ArgType :: Arg , String , Collection :: Unit , None ] ,
90+ [ "k" , ArgType :: Kwarg , u64 , Collection :: Unit , Some ( Box :: new( 5_u64 ) ) ] ,
91+ [ "query" , ArgType :: Kwarg , f64 , Collection :: Vec , None ] ,
9392 ] ,
9493 } ;
9594}
0 commit comments