@@ -200,22 +200,18 @@ public Flux<CommandResponse<ZRangeCommand, Flux<Tuple>>> zRange(Publisher<ZRange
200
200
if (ObjectUtils .nullSafeEquals (command .getDirection (), Direction .ASC )) {
201
201
if (command .isWithScores ()) {
202
202
203
- result = cmd .zrangeWithScores (command .getKey (), start , stop )
204
- .map (this ::toTuple );
203
+ result = cmd .zrangeWithScores (command .getKey (), start , stop ).map (this ::toTuple );
205
204
} else {
206
205
207
- result = cmd .zrange (command .getKey (), start , stop )
208
- .map (value -> toTuple (value , Double .NaN ));
206
+ result = cmd .zrange (command .getKey (), start , stop ).map (value -> toTuple (value , Double .NaN ));
209
207
}
210
208
} else {
211
209
if (command .isWithScores ()) {
212
210
213
- result = cmd .zrevrangeWithScores (command .getKey (), start , stop )
214
- .map (this ::toTuple );
211
+ result = cmd .zrevrangeWithScores (command .getKey (), start , stop ).map (this ::toTuple );
215
212
} else {
216
213
217
- result = cmd .zrevrange (command .getKey (), start , stop )
218
- .map (value -> toTuple (value , Double .NaN ));
214
+ result = cmd .zrevrange (command .getKey (), start , stop ).map (value -> toTuple (value , Double .NaN ));
219
215
}
220
216
}
221
217
@@ -247,8 +243,7 @@ public Flux<CommandResponse<ZRangeByScoreCommand, Flux<Tuple>>> zRangeByScore(
247
243
if (command .isWithScores ()) {
248
244
249
245
if (!isLimited ) {
250
- result = cmd .zrangebyscoreWithScores (command .getKey (), range )
251
- .map (this ::toTuple );
246
+ result = cmd .zrangebyscoreWithScores (command .getKey (), range ).map (this ::toTuple );
252
247
} else {
253
248
result = cmd
254
249
.zrangebyscoreWithScores (command .getKey (), range , LettuceConverters .toLimit (command .getLimit ().get ()))
@@ -257,8 +252,7 @@ public Flux<CommandResponse<ZRangeByScoreCommand, Flux<Tuple>>> zRangeByScore(
257
252
} else {
258
253
259
254
if (!isLimited ) {
260
- result = cmd .zrangebyscore (command .getKey (), range )
261
- .map (value -> toTuple (value , Double .NaN ));
255
+ result = cmd .zrangebyscore (command .getKey (), range ).map (value -> toTuple (value , Double .NaN ));
262
256
} else {
263
257
264
258
result = cmd .zrangebyscore (command .getKey (), range , LettuceConverters .toLimit (command .getLimit ().get ()))
@@ -272,20 +266,16 @@ public Flux<CommandResponse<ZRangeByScoreCommand, Flux<Tuple>>> zRangeByScore(
272
266
if (command .isWithScores ()) {
273
267
274
268
if (!isLimited ) {
275
- result = cmd .zrevrangebyscoreWithScores (command .getKey (), range )
276
- .map (this ::toTuple );
269
+ result = cmd .zrevrangebyscoreWithScores (command .getKey (), range ).map (this ::toTuple );
277
270
} else {
278
271
279
- result = cmd
280
- .zrevrangebyscoreWithScores (command .getKey (), range ,
281
- LettuceConverters .toLimit (command .getLimit ().get ()))
282
- .map (this ::toTuple );
272
+ result = cmd .zrevrangebyscoreWithScores (command .getKey (), range ,
273
+ LettuceConverters .toLimit (command .getLimit ().get ())).map (this ::toTuple );
283
274
}
284
275
} else {
285
276
286
277
if (!isLimited ) {
287
- result = cmd .zrevrangebyscore (command .getKey (), range )
288
- .map (value -> toTuple (value , Double .NaN ));
278
+ result = cmd .zrevrangebyscore (command .getKey (), range ).map (value -> toTuple (value , Double .NaN ));
289
279
} else {
290
280
291
281
result = cmd .zrevrangebyscore (command .getKey (), range , LettuceConverters .toLimit (command .getLimit ().get ()))
@@ -520,26 +510,99 @@ public Flux<NumericResponse<ZRemRangeByLexCommand, Long>> zRemRangeByLex(Publish
520
510
521
511
/*
522
512
* (non-Javadoc)
523
- * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zUnionStore(org.reactivestreams.Publisher)
513
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zDiff(Publisher)
514
+ */
515
+ @ Override
516
+ public Flux <CommandResponse <ZDiffCommand , Flux <ByteBuffer >>> zDiff (Publisher <? extends ZDiffCommand > commands ) {
517
+
518
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
519
+
520
+ Assert .notEmpty (command .getKeys (), "Keys must not be null or empty!" );
521
+
522
+ ByteBuffer [] sourceKeys = command .getKeys ().toArray (new ByteBuffer [0 ]);
523
+ return new CommandResponse <>(command , cmd .zdiff (sourceKeys ));
524
+ }));
525
+ }
526
+
527
+ /*
528
+ * (non-Javadoc)
529
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zDiffWithScores(Publisher)
530
+ */
531
+ @ Override
532
+ public Flux <CommandResponse <ZDiffCommand , Flux <Tuple >>> zDiffWithScores (Publisher <? extends ZDiffCommand > commands ) {
533
+
534
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
535
+
536
+ Assert .notEmpty (command .getKeys (), "Keys must not be null or empty!" );
537
+
538
+ ByteBuffer [] sourceKeys = command .getKeys ().toArray (new ByteBuffer [0 ]);
539
+ return new CommandResponse <>(command , cmd .zdiffWithScores (sourceKeys ).map (this ::toTuple ));
540
+ }));
541
+ }
542
+
543
+ /*
544
+ * (non-Javadoc)
545
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zDiffStore(Publisher)
524
546
*/
525
547
@ Override
526
- public Flux <NumericResponse <ZUnionStoreCommand , Long >> zUnionStore (Publisher <ZUnionStoreCommand > commands ) {
548
+ public Flux <NumericResponse <ZDiffStoreCommand , Long >> zDiffStore (Publisher <ZDiffStoreCommand > commands ) {
527
549
528
550
return connection .execute (cmd -> Flux .from (commands ).concatMap (command -> {
529
551
530
552
Assert .notNull (command .getKey (), "Destination key must not be null!" );
531
553
Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
532
554
555
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().toArray (new ByteBuffer [0 ]);
556
+ return cmd .zdiffstore (command .getKey (), sourceKeys ).map (value -> new NumericResponse <>(command , value ));
557
+ }));
558
+ }
559
+
560
+ /*
561
+ * (non-Javadoc)
562
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zInter(Publisher)
563
+ */
564
+ @ Override
565
+ public Flux <CommandResponse <ZAggregateCommand , Flux <ByteBuffer >>> zInter (
566
+ Publisher <? extends ZAggregateCommand > commands ) {
567
+
568
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
569
+
570
+ Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
571
+
533
572
ZStoreArgs args = null ;
534
573
if (command .getAggregateFunction ().isPresent () || !command .getWeights ().isEmpty ()) {
535
574
args = zStoreArgs (command .getAggregateFunction ().isPresent () ? command .getAggregateFunction ().get () : null ,
536
575
command .getWeights ());
537
576
}
538
577
539
- ByteBuffer [] sourceKeys = command .getSourceKeys ().stream ().toArray (ByteBuffer []::new );
540
- Mono <Long > result = args != null ? cmd .zunionstore (command .getKey (), args , sourceKeys )
541
- : cmd .zunionstore (command .getKey (), sourceKeys );
542
- return result .map (value -> new NumericResponse <>(command , value ));
578
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().toArray (new ByteBuffer [0 ]);
579
+ Flux <ByteBuffer > result = args != null ? cmd .zinter (args , sourceKeys ) : cmd .zinter (sourceKeys );
580
+ return new CommandResponse <>(command , result );
581
+ }));
582
+ }
583
+
584
+ /*
585
+ * (non-Javadoc)
586
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zInterWithScores(Publisher)
587
+ */
588
+ @ Override
589
+ public Flux <CommandResponse <ZAggregateCommand , Flux <Tuple >>> zInterWithScores (
590
+ Publisher <? extends ZAggregateCommand > commands ) {
591
+
592
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
593
+
594
+ Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
595
+
596
+ ZStoreArgs args = null ;
597
+ if (command .getAggregateFunction ().isPresent () || !command .getWeights ().isEmpty ()) {
598
+ args = zStoreArgs (command .getAggregateFunction ().isPresent () ? command .getAggregateFunction ().get () : null ,
599
+ command .getWeights ());
600
+ }
601
+
602
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().toArray (new ByteBuffer [0 ]);
603
+ Flux <ScoredValue <ByteBuffer >> result = args != null ? cmd .zinterWithScores (args , sourceKeys )
604
+ : cmd .zinterWithScores (sourceKeys );
605
+ return new CommandResponse <>(command , result .map (this ::toTuple ));
543
606
}));
544
607
}
545
608
@@ -548,7 +611,8 @@ public Flux<NumericResponse<ZUnionStoreCommand, Long>> zUnionStore(Publisher<ZUn
548
611
* @see org.springframework.data.redis.connection.ReactiveZSetCommands#zInterStore(org.reactivestreams.Publisher)
549
612
*/
550
613
@ Override
551
- public Flux <NumericResponse <ZInterStoreCommand , Long >> zInterStore (Publisher <ZInterStoreCommand > commands ) {
614
+ public Flux <NumericResponse <ZAggregateStoreCommand , Long >> zInterStore (
615
+ Publisher <? extends ZAggregateStoreCommand > commands ) {
552
616
553
617
return connection .execute (cmd -> Flux .from (commands ).concatMap (command -> {
554
618
@@ -561,13 +625,88 @@ public Flux<NumericResponse<ZInterStoreCommand, Long>> zInterStore(Publisher<ZIn
561
625
command .getWeights ());
562
626
}
563
627
564
- ByteBuffer [] sourceKeys = command .getSourceKeys ().stream (). toArray (ByteBuffer []:: new );
628
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().toArray (new ByteBuffer [0 ] );
565
629
Mono <Long > result = args != null ? cmd .zinterstore (command .getKey (), args , sourceKeys )
566
630
: cmd .zinterstore (command .getKey (), sourceKeys );
567
631
return result .map (value -> new NumericResponse <>(command , value ));
568
632
}));
569
633
}
570
634
635
+ /*
636
+ * (non-Javadoc)
637
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zUnion(org.reactivestreams.Publisher)
638
+ */
639
+ @ Override
640
+ public Flux <CommandResponse <ZAggregateCommand , Flux <ByteBuffer >>> zUnion (
641
+ Publisher <? extends ZAggregateCommand > commands ) {
642
+
643
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
644
+
645
+ Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
646
+
647
+ ZStoreArgs args = null ;
648
+ if (command .getAggregateFunction ().isPresent () || !command .getWeights ().isEmpty ()) {
649
+ args = zStoreArgs (command .getAggregateFunction ().isPresent () ? command .getAggregateFunction ().get () : null ,
650
+ command .getWeights ());
651
+ }
652
+
653
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().stream ().toArray (ByteBuffer []::new );
654
+ Flux <ByteBuffer > result = args != null ? cmd .zunion (args , sourceKeys ) : cmd .zunion (sourceKeys );
655
+ return new CommandResponse <>(command , result );
656
+ }));
657
+ }
658
+
659
+ /*
660
+ * (non-Javadoc)
661
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zUnion(org.reactivestreams.Publisher)
662
+ */
663
+ @ Override
664
+ public Flux <CommandResponse <ZAggregateCommand , Flux <Tuple >>> zUnionWithScores (
665
+ Publisher <? extends ZAggregateCommand > commands ) {
666
+
667
+ return connection .execute (cmd -> Flux .from (commands ).map (command -> {
668
+
669
+ Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
670
+
671
+ ZStoreArgs args = null ;
672
+ if (command .getAggregateFunction ().isPresent () || !command .getWeights ().isEmpty ()) {
673
+ args = zStoreArgs (command .getAggregateFunction ().isPresent () ? command .getAggregateFunction ().get () : null ,
674
+ command .getWeights ());
675
+ }
676
+
677
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().stream ().toArray (ByteBuffer []::new );
678
+ Flux <ScoredValue <ByteBuffer >> result = args != null ? cmd .zunionWithScores (args , sourceKeys )
679
+ : cmd .zunionWithScores (sourceKeys );
680
+ return new CommandResponse <>(command , result .map (this ::toTuple ));
681
+ }));
682
+ }
683
+
684
+ /*
685
+ * (non-Javadoc)
686
+ * @see org.springframework.data.redis.connection.ReactiveZSetCommands#zUnionStore(org.reactivestreams.Publisher)
687
+ */
688
+ @ Override
689
+ public Flux <NumericResponse <ZAggregateStoreCommand , Long >> zUnionStore (
690
+ Publisher <? extends ZAggregateStoreCommand > commands ) {
691
+
692
+ return connection .execute (cmd -> Flux .from (commands ).concatMap (command -> {
693
+
694
+ Assert .notNull (command .getKey (), "Destination key must not be null!" );
695
+ Assert .notEmpty (command .getSourceKeys (), "Source keys must not be null or empty!" );
696
+
697
+ ZStoreArgs args = null ;
698
+ if (command .getAggregateFunction ().isPresent () || !command .getWeights ().isEmpty ()) {
699
+ args = zStoreArgs (command .getAggregateFunction ().isPresent () ? command .getAggregateFunction ().get () : null ,
700
+ command .getWeights ());
701
+ }
702
+
703
+ ByteBuffer [] sourceKeys = command .getSourceKeys ().stream ().toArray (ByteBuffer []::new );
704
+ Mono <Long > result = args != null ? cmd .zunionstore (command .getKey (), args , sourceKeys )
705
+ : cmd .zunionstore (command .getKey (), sourceKeys );
706
+ return result .map (value -> new NumericResponse <>(command , value ));
707
+ }));
708
+ }
709
+
571
710
/*
572
711
* (non-Javadoc)
573
712
* @see org.springframework.data.redis.connection.ReactiveZSetCommands#zRangeByLex(org.reactivestreams.Publisher)
0 commit comments