@@ -514,15 +514,14 @@ public Map<byte[], Double> build(Object data) {
514
514
final List <Object > list = (List <Object >) data ;
515
515
if (list .isEmpty ()) return Collections .emptyMap ();
516
516
517
+ final JedisByteMap <Double > map = new JedisByteMap <>();
517
518
if (list .get (0 ) instanceof KeyValue ) {
518
- final Map <byte [], Double > map = new LinkedHashMap <>(list .size (), 1f );
519
519
for (Object o : list ) {
520
520
KeyValue <?, ?> kv = (KeyValue <?, ?>) o ;
521
521
map .put (BINARY .build (kv .getKey ()), DOUBLE .build (kv .getValue ()));
522
522
}
523
523
return map ;
524
524
} else {
525
- final Map <byte [], Double > map = new LinkedHashMap <>(list .size () / 2 , 1f );
526
525
final Iterator iterator = list .iterator ();
527
526
while (iterator .hasNext ()) {
528
527
map .put (BINARY .build (iterator .next ()), DOUBLE .build (iterator .next ()));
@@ -2249,7 +2248,73 @@ public String toString() {
2249
2248
};
2250
2249
2251
2250
// Vector Set builders
2251
+ public static final Builder <Map <String , VSimScoreAttribs >> VSIM_SCORE_ATTRIBS_MAP = new Builder <Map <String , VSimScoreAttribs >>() {
2252
2252
2253
+ @ Override
2254
+ @ SuppressWarnings ("unchecked" )
2255
+ public Map <String , VSimScoreAttribs > build (Object data ) {
2256
+ if (data == null ) return null ;
2257
+ List <Object > list = (List <Object >) data ;
2258
+ if (list .isEmpty ()) return Collections .emptyMap ();
2259
+
2260
+ if (list .get (0 ) instanceof KeyValue ) {
2261
+ final Map <String , VSimScoreAttribs > result = new LinkedHashMap <>(list .size (), 1f );
2262
+ for (Object o : list ) {
2263
+ KeyValue <?, ?> kv = (KeyValue <?, ?>) o ;
2264
+ List <Object > scoreAndAttribs = (List <Object >) kv .getValue ();
2265
+ result .put (STRING .build (kv .getKey ()),
2266
+ new VSimScoreAttribs (DOUBLE .build (scoreAndAttribs .get (0 )),
2267
+ STRING .build (scoreAndAttribs .get (1 ))));
2268
+ }
2269
+ return result ;
2270
+ } else {
2271
+ final Map <String , VSimScoreAttribs > result = new LinkedHashMap <>(list .size () / 3 , 1f );
2272
+ for (int i = 0 ; i < list .size (); i += 3 ) {
2273
+ result .put (STRING .build (list .get (i )),
2274
+ new VSimScoreAttribs (DOUBLE .build (list .get (i + 1 )), STRING .build (list .get (i + 2 ))));
2275
+ }
2276
+ return result ;
2277
+ }
2278
+ }
2279
+
2280
+ @ Override
2281
+ public String toString () {
2282
+ return "Map<String, VSimScoreAttribs>" ;
2283
+ }
2284
+ };
2285
+
2286
+ public static final Builder <Map <byte [], VSimScoreAttribs >> VSIM_SCORE_ATTRIBS_BINARY_MAP = new Builder <Map <byte [], VSimScoreAttribs >>() {
2287
+
2288
+ @ Override
2289
+ @ SuppressWarnings ("unchecked" )
2290
+ public Map <byte [], VSimScoreAttribs > build (Object data ) {
2291
+ if (data == null ) return null ;
2292
+ List <Object > list = (List <Object >) data ;
2293
+ if (list .isEmpty ()) return Collections .emptyMap ();
2294
+
2295
+ JedisByteMap <VSimScoreAttribs > result = new JedisByteMap <>();
2296
+ if (list .get (0 ) instanceof KeyValue ) {
2297
+ for (Object o : list ) {
2298
+ KeyValue <?, ?> kv = (KeyValue <?, ?>) o ;
2299
+ List <Object > scoreAndAttribs = (List <Object >) kv .getValue ();
2300
+ result .put (BINARY .build (kv .getKey ()),
2301
+ new VSimScoreAttribs (DOUBLE .build (scoreAndAttribs .get (0 )),
2302
+ STRING .build (scoreAndAttribs .get (1 ))));
2303
+ }
2304
+ } else {
2305
+ for (int i = 0 ; i < list .size (); i += 3 ) {
2306
+ result .put (BINARY .build (list .get (i )),
2307
+ new VSimScoreAttribs (DOUBLE .build (list .get (i + 1 )), STRING .build (list .get (i + 2 ))));
2308
+ }
2309
+ }
2310
+ return result ;
2311
+ }
2312
+
2313
+ @ Override
2314
+ public String toString () {
2315
+ return "Map<byte[], VSimScoreAttribs>" ;
2316
+ }
2317
+ };
2253
2318
2254
2319
public static final Builder <RawVector > VEMB_RAW_RESULT = new Builder <RawVector >() {
2255
2320
@ Override
0 commit comments