DATAREDIS-873 - Polishing.

Add since tags. Add tests. Reformat code. Update docs.

Original pull request: #361.
This commit is contained in:
Mark Paluch
2018-11-23 11:48:25 +01:00
parent 724579b8a9
commit b440dc1f1f
7 changed files with 181 additions and 29 deletions

View File

@@ -182,10 +182,10 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
return createFlux(connection -> Flux.fromIterable(keys)
return createFlux(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMapMany(connection::sInter)
.flatMapMany(connection::sInter) //
.map(this::readValue));
}
@@ -226,9 +226,9 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
Assert.notNull(destKey, "Destination key must not be null!");
return createMono(connection -> Flux.fromIterable(keys)
.map(this::rawKey)
.collectList()
return createMono(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMap(rawKeys -> connection.sInterStore(rawKey(destKey), rawKeys)));
}
@@ -267,10 +267,10 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
return createFlux(connection -> Flux.fromIterable(keys)
.map(this::rawKey)
.collectList()
.flatMapMany(connection::sUnion)
return createFlux(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMapMany(connection::sUnion) //
.map(this::readValue));
}
@@ -312,9 +312,9 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
Assert.notNull(destKey, "Destination key must not be null!");
return createMono(connection -> Flux.fromIterable(keys)
.map(this::rawKey)
.collectList()
return createMono(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMap(rawKeys -> connection.sUnionStore(rawKey(destKey), rawKeys)));
}
@@ -353,10 +353,10 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
return createFlux(connection -> Flux.fromIterable(keys)
.map(this::rawKey)
.collectList()
.flatMapMany(connection::sDiff)
return createFlux(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMapMany(connection::sDiff) //
.map(this::readValue));
}
@@ -398,9 +398,9 @@ class DefaultReactiveSetOperations<K, V> implements ReactiveSetOperations<K, V>
Assert.notNull(keys, "Keys must not be null!");
Assert.notNull(destKey, "Destination key must not be null!");
return createMono(connection -> Flux.fromIterable(keys)
.map(this::rawKey)
.collectList()
return createMono(connection -> Flux.fromIterable(keys) //
.map(this::rawKey) //
.collectList() //
.flatMap(rawKeys -> connection.sDiffStore(rawKey(destKey), rawKeys)));
}

View File

@@ -65,6 +65,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Set<V> difference(K key, Collection<K> otherKeys) {
byte[][] rawKeys = rawKeys(key, otherKeys);
Set<byte[]> rawValues = execute(connection -> connection.sDiff(rawKeys), true);
@@ -77,6 +78,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Set<V> difference(Collection<K> keys) {
byte[][] rawKeys = rawKeys(keys);
Set<byte[]> rawValues = execute(connection -> connection.sDiff(rawKeys), true);
@@ -101,6 +103,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
byte[][] rawKeys = rawKeys(key, otherKeys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sDiffStore(rawDestKey, rawKeys), true);
}
@@ -110,8 +113,10 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Long differenceAndStore(Collection<K> keys, K destKey) {
byte[][] rawKeys = rawKeys(keys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sDiffStore(rawDestKey, rawKeys), true);
}
@@ -143,10 +148,12 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Set<V> intersect(Collection<K> keys) {
byte[][] rawKeys = rawKeys(keys);
Set<byte[]> rawValues = execute(connection -> connection.sInter(rawKeys), true);
return deserializeValues(rawValues); }
return deserializeValues(rawValues);
}
/*
* (non-Javadoc)
@@ -166,6 +173,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
byte[][] rawKeys = rawKeys(key, otherKeys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sInterStore(rawDestKey, rawKeys), true);
}
@@ -175,9 +183,12 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Long intersectAndStore(Collection<K> keys, K destKey) {
byte[][] rawKeys = rawKeys(keys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sInterStore(rawDestKey, rawKeys), true); }
return execute(connection -> connection.sInterStore(rawDestKey, rawKeys), true);
}
/*
* (non-Javadoc)
@@ -188,6 +199,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
byte[] rawKey = rawKey(key);
byte[] rawValue = rawValue(o);
return execute(connection -> connection.sIsMember(rawKey, rawValue), true);
}
@@ -346,6 +358,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Set<V> union(Collection<K> keys) {
byte[][] rawKeys = rawKeys(keys);
Set<byte[]> rawValues = execute(connection -> connection.sUnion(rawKeys), true);
@@ -370,6 +383,7 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
byte[][] rawKeys = rawKeys(key, otherKeys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sUnionStore(rawDestKey, rawKeys), true);
}
@@ -379,9 +393,12 @@ class DefaultSetOperations<K, V> extends AbstractOperations<K, V> implements Set
*/
@Override
public Long unionAndStore(Collection<K> keys, K destKey) {
byte[][] rawKeys = rawKeys(keys);
byte[] rawDestKey = rawKey(destKey);
return execute(connection -> connection.sUnionStore(rawDestKey, rawKeys), true); }
return execute(connection -> connection.sUnionStore(rawDestKey, rawKeys), true);
}
/*
* (non-Javadoc)

View File

@@ -126,6 +126,7 @@ public interface ReactiveSetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
* @since 2.2
*/
Flux<V> intersect(Collection<K> keys);
@@ -158,6 +159,7 @@ public interface ReactiveSetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
* @since 2.2
*/
Mono<Long> intersectAndStore(Collection<K> keys, K destKey);
@@ -187,6 +189,7 @@ public interface ReactiveSetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
* @since 2.2
*/
Flux<V> union(Collection<K> keys);
@@ -219,6 +222,7 @@ public interface ReactiveSetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
* @since 2.2
*/
Mono<Long> unionAndStore(Collection<K> keys, K destKey);
@@ -248,6 +252,7 @@ public interface ReactiveSetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
* @since 2.2
*/
Flux<V> difference(Collection<K> keys);
@@ -280,6 +285,7 @@ public interface ReactiveSetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
* @since 2.2
*/
Mono<Long> differenceAndStore(Collection<K> keys, K destKey);

View File

@@ -136,6 +136,7 @@ public interface SetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sinter">Redis Documentation: SINTER</a>
* @since 2.2
*/
@Nullable
Set<V> intersect(Collection<K> keys);
@@ -171,6 +172,7 @@ public interface SetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sinterstore">Redis Documentation: SINTERSTORE</a>
* @since 2.2
*/
@Nullable
Long intersectAndStore(Collection<K> keys, K destKey);
@@ -203,6 +205,7 @@ public interface SetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sunion">Redis Documentation: SUNION</a>
* @since 2.2
*/
@Nullable
Set<V> union(Collection<K> keys);
@@ -238,6 +241,7 @@ public interface SetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sunionstore">Redis Documentation: SUNIONSTORE</a>
* @since 2.2
*/
@Nullable
Long unionAndStore(Collection<K> keys, K destKey);
@@ -270,6 +274,7 @@ public interface SetOperations<K, V> {
* @param keys must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sdiff">Redis Documentation: SDIFF</a>
* @since 2.2
*/
@Nullable
Set<V> difference(Collection<K> keys);
@@ -305,6 +310,7 @@ public interface SetOperations<K, V> {
* @param destKey must not be {@literal null}.
* @return {@literal null} when used in pipeline / transaction.
* @see <a href="http://redis.io/commands/sdiffstore">Redis Documentation: SDIFFSTORE</a>
* @since 2.2
*/
@Nullable
Long differenceAndStore(Collection<K> keys, K destKey);