Feature - countIntersection() method added to RScoredSortedSet object. #3942

pull/3951/head
Nikita Koksharov 3 years ago
parent 32d3f2ba81
commit 80ba3f2952

@ -943,6 +943,34 @@ public class RedissonScoredSortedSet<V> extends RedissonExpirable implements RSc
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZINTER, args.toArray()); return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZINTER, args.toArray());
} }
@Override
public Integer countIntersection(String... names) {
return get(countIntersectionAsync(names));
}
@Override
public Integer countIntersection(int limit, String... names) {
return get(countIntersectionAsync(limit, names));
}
@Override
public RFuture<Integer> countIntersectionAsync(String... names) {
return countIntersectionAsync(0, names);
}
@Override
public RFuture<Integer> countIntersectionAsync(int limit, String... names) {
List<Object> args = new ArrayList<>(names.length + 1);
args.add(getRawName());
args.add(names.length);
args.addAll(Arrays.asList(names));
if (limit > 0) {
args.add("LIMIT");
args.add(limit);
}
return commandExecutor.writeAsync(getRawName(), codec, RedisCommands.ZINTERCARD_INT, args.toArray());
}
@Override @Override
public int union(String... names) { public int union(String... names) {
return get(unionAsync(names)); return get(unionAsync(names));

@ -930,6 +930,27 @@ public interface RScoredSortedSet<V> extends RScoredSortedSetAsync<V>, Iterable<
*/ */
Collection<V> readIntersection(Map<String, Double> nameWithWeight); Collection<V> readIntersection(Map<String, Double> nameWithWeight);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @return amount of elements
*/
Integer countIntersection(String... names);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @param limit - sets intersection limit
* @return amount of elements
*/
Integer countIntersection(int limit, String... names);
/** /**
* Intersect provided ScoredSortedSets mapped to weight multiplier * Intersect provided ScoredSortedSets mapped to weight multiplier
* with current ScoredSortedSet using defined aggregation method * with current ScoredSortedSet using defined aggregation method

@ -808,6 +808,27 @@ public interface RScoredSortedSetAsync<V> extends RExpirableAsync, RSortableAsyn
*/ */
RFuture<Collection<V>> readIntersectionAsync(Aggregate aggregate, Map<String, Double> nameWithWeight); RFuture<Collection<V>> readIntersectionAsync(Aggregate aggregate, Map<String, Double> nameWithWeight);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @return amount of elements
*/
RFuture<Integer> countIntersectionAsync(String... names);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @param limit - sets intersection limit
* @return amount of elements
*/
RFuture<Integer> countIntersectionAsync(int limit, String... names);
/** /**
* Union provided ScoredSortedSets * Union provided ScoredSortedSets
* and store result to current ScoredSortedSet * and store result to current ScoredSortedSet

@ -833,6 +833,27 @@ public interface RScoredSortedSetReactive<V> extends RExpirableReactive, RSortab
*/ */
Mono<Collection<V>> readIntersection(Aggregate aggregate, Map<String, Double> nameWithWeight); Mono<Collection<V>> readIntersection(Aggregate aggregate, Map<String, Double> nameWithWeight);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @return amount of elements
*/
Mono<Integer> countIntersection(String... names);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @param limit - sets intersection limit
* @return amount of elements
*/
Mono<Integer> countIntersection(int limit, String... names);
/** /**
* Union provided ScoredSortedSets * Union provided ScoredSortedSets
* and store result to current ScoredSortedSet * and store result to current ScoredSortedSet

@ -835,6 +835,27 @@ public interface RScoredSortedSetRx<V> extends RExpirableRx, RSortableRx<Set<V>>
*/ */
Single<Collection<V>> readIntersection(Aggregate aggregate, Map<String, Double> nameWithWeight); Single<Collection<V>> readIntersection(Aggregate aggregate, Map<String, Double> nameWithWeight);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @return amount of elements
*/
Single<Integer> countIntersection(String... names);
/**
* Counts elements of set as a result of sets intersection with current set.
* <p>
* Requires <b>Redis 7.0.0 and higher.</b>
*
* @param names - name of sets
* @param limit - sets intersection limit
* @return amount of elements
*/
Single<Integer> countIntersection(int limit, String... names);
/** /**
* Union provided ScoredSortedSets * Union provided ScoredSortedSets
* and store result to current ScoredSortedSet * and store result to current ScoredSortedSet

@ -84,6 +84,7 @@ public interface RedisCommands {
RedisStrictCommand<List<Object>> ZDIFF = new RedisStrictCommand<>("ZDIFF", new ObjectListReplayDecoder<>()); RedisStrictCommand<List<Object>> ZDIFF = new RedisStrictCommand<>("ZDIFF", new ObjectListReplayDecoder<>());
RedisCommand<List<Object>> ZUNION = new RedisCommand<>("ZUNION", new ObjectListReplayDecoder<>()); RedisCommand<List<Object>> ZUNION = new RedisCommand<>("ZUNION", new ObjectListReplayDecoder<>());
RedisCommand<List<Object>> ZINTER = new RedisCommand<>("ZINTER", new ObjectListReplayDecoder<>()); RedisCommand<List<Object>> ZINTER = new RedisCommand<>("ZINTER", new ObjectListReplayDecoder<>());
RedisStrictCommand<Integer> ZINTERCARD_INT = new RedisStrictCommand<>("ZINTERCARD", new IntegerReplayConvertor());
RedisStrictCommand<Integer> ZDIFFSTORE_INT = new RedisStrictCommand<Integer>("ZDIFFSTORE", new IntegerReplayConvertor()); RedisStrictCommand<Integer> ZDIFFSTORE_INT = new RedisStrictCommand<Integer>("ZDIFFSTORE", new IntegerReplayConvertor());
RedisStrictCommand<Integer> ZUNIONSTORE_INT = new RedisStrictCommand<Integer>("ZUNIONSTORE", new IntegerReplayConvertor()); RedisStrictCommand<Integer> ZUNIONSTORE_INT = new RedisStrictCommand<Integer>("ZUNIONSTORE", new IntegerReplayConvertor());
RedisStrictCommand<Integer> ZINTERSTORE_INT = new RedisStrictCommand<Integer>("ZINTERSTORE", new IntegerReplayConvertor()); RedisStrictCommand<Integer> ZINTERSTORE_INT = new RedisStrictCommand<Integer>("ZINTERSTORE", new IntegerReplayConvertor());

Loading…
Cancel
Save