11package com .aliyun .tair .tairvector .params ;
22
3+ import redis .clients .jedis .Protocol ;
4+ import redis .clients .jedis .util .SafeEncoder ;
5+
36import java .nio .ByteBuffer ;
47import java .util .ArrayList ;
58import java .util .Collection ;
912import java .util .List ;
1013import java .util .Map ;
1114
12- import redis .clients .jedis .Protocol ;
13- import redis .clients .jedis .util .SafeEncoder ;
14-
15-
1615public class HscanParams {
1716 private final static String MATCH = "MATCH" ;
1817 private final static String COUNT = "COUNT" ;
19- private final static String NOVAL = "NOVAL" ;
18+ private final static String VECTOR = "VECTOR" ;
19+ private final static String MAX_DIST = "MAX_DIST" ;
20+ private final static String FILTER = "FILTER" ;
2021
2122 private final Map <String , ByteBuffer > params = new HashMap <>();
2223 public static final String SCAN_POINTER_START = String .valueOf (0 );
@@ -40,35 +41,49 @@ public HscanParams count(Integer count) {
4041 return this ;
4142 }
4243
43- public HscanParams noval ( ) {
44- this .params .put (NOVAL , null );
44+ public HscanParams vector (byte [] vector ) {
45+ this .params .put (VECTOR , ByteBuffer .wrap (vector ));
46+ return this ;
47+ }
48+
49+ public HscanParams vector (String vector ) {
50+ this .params .put (VECTOR , ByteBuffer .wrap (SafeEncoder .encode (vector )));
51+ return this ;
52+ }
53+
54+ public HscanParams max_dist (float max_dist ) {
55+ this .params .put (MAX_DIST , ByteBuffer .wrap (Protocol .toByteArray (max_dist )));
56+ return this ;
57+ }
58+
59+ public HscanParams filter (String filter ) {
60+ this .params .put (FILTER , ByteBuffer .wrap (SafeEncoder .encode (filter )));
4561 return this ;
4662 }
4763
4864 public Collection <byte []> getParams () {
4965 List <byte []> paramsList = new ArrayList (this .params .size ());
5066 Iterator var2 = this .params .entrySet ().iterator ();
5167
52- while (var2 .hasNext ()) {
53- Map .Entry <String , ByteBuffer > param = (Map .Entry )var2 .next ();
68+ while (var2 .hasNext ()) {
69+ Map .Entry <String , ByteBuffer > param = (Map .Entry ) var2 .next ();
5470 paramsList .add (SafeEncoder .encode (param .getKey ()));
55- if (param .getKey ().equals (NOVAL )) continue ;
5671 paramsList .add ((param .getValue ()).array ());
5772 }
5873
5974 return Collections .unmodifiableCollection (paramsList );
6075 }
6176
6277 byte [] binaryMatch () {
63- return this .params .containsKey (MATCH ) ? ((ByteBuffer )this .params .get (MATCH )).array () : null ;
78+ return this .params .containsKey (MATCH ) ? ((ByteBuffer ) this .params .get (MATCH )).array () : null ;
6479 }
6580
6681 String match () {
67- return this .params .containsKey (MATCH ) ? new String (((ByteBuffer )this .params .get (MATCH )).array ()) : null ;
82+ return this .params .containsKey (MATCH ) ? new String (((ByteBuffer ) this .params .get (MATCH )).array ()) : null ;
6883 }
6984
7085 Integer count () {
71- return this .params .containsKey (COUNT ) ? ((ByteBuffer )this .params .get (COUNT )).getInt () : null ;
86+ return this .params .containsKey (COUNT ) ? ((ByteBuffer ) this .params .get (COUNT )).getInt () : null ;
7287 }
7388
7489 static {
0 commit comments