Skip to content

Commit 0ac4ad8

Browse files
committed
mark vector-set api as Experimental
- Add integration test for Jedis client
1 parent 5262e8f commit 0ac4ad8

File tree

12 files changed

+1699
-45
lines changed

12 files changed

+1699
-45
lines changed

src/main/java/redis/clients/jedis/CommandObjects.java

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,12 +4732,8 @@ private CommandArguments addGeoCoordinateFlatMapArgs(CommandArguments args, Map<
47324732

47334733
// Vector Set commands
47344734
public final CommandObject<Boolean> vadd(String key, float[] vector, String element) {
4735-
CommandArguments args = commandArguments(Command.VADD).key(key).add(Keyword.VALUES).add(vector.length);
4736-
for (float value : vector) {
4737-
args.add(value);
4738-
}
4739-
args.add(element);
4740-
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
4735+
4736+
return vadd(key, vector, element, null);
47414737
}
47424738

47434739
public final CommandObject<Boolean> vadd(String key, float[] vector, String element, VAddParams params) {
@@ -4747,29 +4743,27 @@ public final CommandObject<Boolean> vadd(String key, float[] vector, String elem
47474743
args.add(value);
47484744
}
47494745
args.add(element);
4750-
args.addParams(params);
4746+
if (params != null) {
4747+
args.addParams(params);
4748+
}
47514749
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
47524750
}
47534751

47544752
public final CommandObject<Boolean> vaddFP32(String key, byte[] vectorBlob, String element) {
4755-
return new CommandObject<>(commandArguments(Command.VADD).key(key).add(Keyword.FP32).add(vectorBlob).add(element),
4756-
BuilderFactory.BOOLEAN);
4753+
return vaddFP32(key, vectorBlob, element, null);
47574754
}
47584755

47594756
public final CommandObject<Boolean> vaddFP32(String key, byte[] vectorBlob, String element, VAddParams params) {
47604757
CommandArguments args = commandArguments(Command.VADD).key(key);
47614758
args.add(Keyword.FP32).add(vectorBlob).add(element);
4762-
args.addParams(params);
4759+
if (params != null) {
4760+
args.addParams(params);
4761+
}
47634762
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
47644763
}
47654764

47664765
public final CommandObject<Boolean> vadd(byte[] key, float[] vector, byte[] element) {
4767-
CommandArguments args = commandArguments(Command.VADD).key(key).add(Keyword.VALUES).add(vector.length);
4768-
for (float value : vector) {
4769-
args.add(value);
4770-
}
4771-
args.add(element);
4772-
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
4766+
return vadd(key, vector, element, null);
47734767
}
47744768

47754769
public final CommandObject<Boolean> vadd(byte[] key, float[] vector, byte[] element, VAddParams params) {
@@ -4779,19 +4773,22 @@ public final CommandObject<Boolean> vadd(byte[] key, float[] vector, byte[] elem
47794773
args.add(value);
47804774
}
47814775
args.add(element);
4782-
args.addParams(params);
4776+
if (params != null) {
4777+
args.addParams(params);
4778+
}
47834779
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
47844780
}
47854781

47864782
public final CommandObject<Boolean> vaddFP32(byte[] key, byte[] vectorBlob, byte[] element) {
4787-
return new CommandObject<>(commandArguments(Command.VADD).key(key).add(Keyword.FP32).add(vectorBlob).add(element),
4788-
BuilderFactory.BOOLEAN);
4783+
return vaddFP32(key, vectorBlob, element, null);
47894784
}
47904785

47914786
public final CommandObject<Boolean> vaddFP32(byte[] key, byte[] vectorBlob, byte[] element, VAddParams params) {
47924787
CommandArguments args = commandArguments(Command.VADD).key(key);
47934788
args.add(Keyword.FP32).add(vectorBlob).add(element);
4794-
args.addParams(params);
4789+
if (params != null) {
4790+
args.addParams(params);
4791+
}
47954792
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
47964793
}
47974794

@@ -4803,7 +4800,9 @@ public final CommandObject<Boolean> vadd(String key, float[] vector, String elem
48034800
args.add(value);
48044801
}
48054802
args.add(element);
4806-
args.addParams(params);
4803+
if (params != null) {
4804+
args.addParams(params);
4805+
}
48074806
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
48084807
}
48094808

@@ -4823,15 +4822,19 @@ public final CommandObject<Boolean> vadd(byte[] key, float[] vector, byte[] elem
48234822
args.add(value);
48244823
}
48254824
args.add(element);
4826-
args.addParams(params);
4825+
if (params != null) {
4826+
args.addParams(params);
4827+
}
48274828
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
48284829
}
48294830

48304831
public final CommandObject<Boolean> vaddFP32(byte[] key, byte[] vectorBlob, byte[] element, int reduceDim, VAddParams params) {
48314832
CommandArguments args = commandArguments(Command.VADD).key(key);
48324833
args.add(Keyword.REDUCE).add(reduceDim);
48334834
args.add(Keyword.FP32).add(vectorBlob).add(element);
4834-
args.addParams(params);
4835+
if (params != null) {
4836+
args.addParams(params);
4837+
}
48354838
return new CommandObject<>(args, BuilderFactory.BOOLEAN);
48364839
}
48374840

src/main/java/redis/clients/jedis/commands/VectorSetBinaryCommands.java

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.util.List;
44
import java.util.Map;
55

6+
import redis.clients.jedis.annots.Experimental;
67
import redis.clients.jedis.params.VAddParams;
78
import redis.clients.jedis.params.VSimParams;
89
import redis.clients.jedis.resps.RawVector;
@@ -23,6 +24,7 @@ public interface VectorSetBinaryCommands {
2324
* @param element the name of the element that is being added to the vector set
2425
* @return 1 if key was added; 0 if key was not added
2526
*/
27+
@Experimental
2628
boolean vadd(byte[] key, float[] vector, byte[] element);
2729

2830
/**
@@ -36,6 +38,7 @@ public interface VectorSetBinaryCommands {
3638
* @param params additional parameters for the VADD command
3739
* @return 1 if key was added; 0 if key was not added
3840
*/
41+
@Experimental
3942
boolean vadd(byte[] key, float[] vector, byte[] element, VAddParams params);
4043

4144
/**
@@ -48,6 +51,7 @@ public interface VectorSetBinaryCommands {
4851
* @param element the name of the element that is being added to the vector set
4952
* @return 1 if key was added; 0 if key was not added
5053
*/
54+
@Experimental
5155
boolean vaddFP32(byte[] key, byte[] vectorBlob, byte[] element);
5256

5357
/**
@@ -61,6 +65,7 @@ public interface VectorSetBinaryCommands {
6165
* @param params additional parameters for the VADD command
6266
* @return 1 if key was added; 0 if key was not added
6367
*/
68+
@Experimental
6469
boolean vaddFP32(byte[] key, byte[] vectorBlob, byte[] element, VAddParams params);
6570

6671
/**
@@ -75,6 +80,7 @@ public interface VectorSetBinaryCommands {
7580
* @param params additional parameters for the VADD command
7681
* @return 1 if key was added; 0 if key was not added
7782
*/
83+
@Experimental
7884
boolean vadd(byte[] key, float[] vector, byte[] element, int reduceDim, VAddParams params);
7985

8086
/**
@@ -89,6 +95,7 @@ public interface VectorSetBinaryCommands {
8995
* @param params additional parameters for the VADD command
9096
* @return 1 if key was added; 0 if key was not added
9197
*/
98+
@Experimental
9299
boolean vaddFP32(byte[] key, byte[] vectorBlob, byte[] element, int reduceDim, VAddParams params);
93100

94101
/**
@@ -100,6 +107,7 @@ public interface VectorSetBinaryCommands {
100107
* @param vector the vector to use as similarity reference
101108
* @return list of similar elements
102109
*/
110+
@Experimental
103111
List<byte[]> vsim(byte[] key, float[] vector);
104112

105113
/**
@@ -112,6 +120,7 @@ public interface VectorSetBinaryCommands {
112120
* @param params additional parameters for the VSIM command
113121
* @return list of similar elements
114122
*/
123+
@Experimental
115124
List<byte[]> vsim(byte[] key, float[] vector, VSimParams params);
116125

117126
/**
@@ -124,6 +133,7 @@ public interface VectorSetBinaryCommands {
124133
* @param params additional parameters for the VSIM command (WITHSCORES will be automatically added)
125134
* @return map of element names to their similarity scores
126135
*/
136+
@Experimental
127137
Map<byte[], Double> vsimWithScores(byte[] key, float[] vector, VSimParams params);
128138

129139
/**
@@ -135,6 +145,7 @@ public interface VectorSetBinaryCommands {
135145
* @param element the name of the element to use as similarity reference
136146
* @return list of similar elements
137147
*/
148+
@Experimental
138149
List<byte[]> vsimByElement(byte[] key, byte[] element);
139150

140151
/**
@@ -147,6 +158,7 @@ public interface VectorSetBinaryCommands {
147158
* @param params additional parameters for the VSIM command
148159
* @return list of similar elements
149160
*/
161+
@Experimental
150162
List<byte[]> vsimByElement(byte[] key, byte[] element, VSimParams params);
151163

152164
/**
@@ -159,6 +171,7 @@ public interface VectorSetBinaryCommands {
159171
* @param params additional parameters for the VSIM command (WITHSCORES will be automatically added)
160172
* @return map of element names to their similarity scores
161173
*/
174+
@Experimental
162175
Map<byte[], Double> vsimByElementWithScores(byte[] key, byte[] element, VSimParams params);
163176

164177
/**
@@ -169,6 +182,7 @@ public interface VectorSetBinaryCommands {
169182
* @param key the name of the key that holds the vector set
170183
* @return the number of vector set elements
171184
*/
185+
@Experimental
172186
long vdim(byte[] key);
173187

174188
/**
@@ -179,6 +193,7 @@ public interface VectorSetBinaryCommands {
179193
* @param key the name of the key that holds the vector set
180194
* @return the number of elements in the vector set
181195
*/
196+
@Experimental
182197
long vcard(byte[] key);
183198

184199
/**
@@ -190,6 +205,7 @@ public interface VectorSetBinaryCommands {
190205
* @param element the name of the element whose vector you want to retrieve
191206
* @return list of real numbers representing the vector
192207
*/
208+
@Experimental
193209
List<Double> vemb(byte[] key, byte[] element);
194210

195211
/**
@@ -212,6 +228,7 @@ public interface VectorSetBinaryCommands {
212228
* @param element the name of the element to remove from the vector set
213229
* @return true if the element was removed, false if either element or key do not exist
214230
*/
231+
@Experimental
215232
boolean vrem(byte[] key, byte[] element);
216233

217234
/**
@@ -223,6 +240,7 @@ public interface VectorSetBinaryCommands {
223240
* @param element the name of the element whose HNSW neighbors you want to inspect
224241
* @return list of neighbor element names
225242
*/
243+
@Experimental
226244
List<List<byte[]>> vlinks(byte[] key, byte[] element);
227245

228246
/**
@@ -232,8 +250,9 @@ public interface VectorSetBinaryCommands {
232250
* Time complexity: O(1)
233251
* @param key the name of the key that holds the vector set
234252
* @param element the name of the element whose HNSW neighbors you want to inspect
235-
* @return map of neighbor element names to similarity scores
253+
* @return List of map of neighbor element names to similarity scores per layer
236254
*/
255+
@Experimental
237256
List<Map<byte[], Double>> vlinksWithScores(byte[] key, byte[] element);
238257

239258
/**
@@ -244,6 +263,7 @@ public interface VectorSetBinaryCommands {
244263
* @param key the name of the key that holds the vector set
245264
* @return a random element name, or null if the key does not exist
246265
*/
266+
@Experimental
247267
byte[] vrandmember(byte[] key);
248268

249269
/**
@@ -255,6 +275,7 @@ public interface VectorSetBinaryCommands {
255275
* @param count the number of elements to return. Positive values return distinct elements; negative values allow duplicates
256276
* @return list of random element names
257277
*/
278+
@Experimental
258279
List<byte[]> vrandmember(byte[] key, int count);
259280

260281
/**
@@ -266,6 +287,7 @@ public interface VectorSetBinaryCommands {
266287
* @param element the name of the element whose attributes to retrieve
267288
* @return the attributes of the element as a JSON string, or null if the element doesn't exist or has no attributes
268289
*/
290+
@Experimental
269291
byte[] vgetattr(byte[] key, byte[] element);
270292

271293
/**
@@ -278,5 +300,6 @@ public interface VectorSetBinaryCommands {
278300
* @param attributes the attributes to set as a JSON string
279301
* @return true if the attributes were set successfully
280302
*/
303+
@Experimental
281304
boolean vsetattr(byte[] key, byte[] element, byte[] attributes);
282305
}

0 commit comments

Comments
 (0)