DATAREDIS-873 - Polishing.
Add since tags. Add tests. Reformat code. Update docs. Original pull request: #361.
This commit is contained in:
@@ -7,6 +7,7 @@ This section briefly covers items that are new and noteworthy in the latest rele
|
||||
== New in Spring Data Redis 2.2
|
||||
|
||||
* <<redis.streams>>
|
||||
* Refined `union`/`diff`/`intersect` set-operation methods accepting a single collection of keys.
|
||||
|
||||
[[new-in-2.1.0]]
|
||||
== New in Spring Data Redis 2.1
|
||||
|
||||
@@ -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)));
|
||||
}
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -20,6 +20,7 @@ import static org.junit.Assume.*;
|
||||
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
@@ -171,7 +172,7 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
StepVerifier.create(setOperations.isMember(key, value1)).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void intersect() {
|
||||
|
||||
assumeFalse(valueFactory instanceof ByteBufferObjectFactory);
|
||||
@@ -191,9 +192,15 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
assertThat(actual).isEqualTo(shared);
|
||||
}) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.intersect(Arrays.asList(key, otherKey))) //
|
||||
.consumeNextWith(actual -> {
|
||||
assertThat(actual).isEqualTo(shared);
|
||||
}) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void intersectAndStore() {
|
||||
|
||||
K key = keyFactory.instance();
|
||||
@@ -211,9 +218,16 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
.verify();
|
||||
|
||||
StepVerifier.create(setOperations.isMember(destKey, shared)).expectNext(true).verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.delete(destKey)).expectNext(true).verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.intersectAndStore(Arrays.asList(key, otherKey), destKey)).expectNext(1L)
|
||||
.expectComplete().verify();
|
||||
|
||||
StepVerifier.create(setOperations.isMember(destKey, shared)).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void difference() {
|
||||
|
||||
assumeFalse(valueFactory instanceof ByteBufferObjectFactory);
|
||||
@@ -233,9 +247,15 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
assertThat(actual).isEqualTo(onlyInKey);
|
||||
}) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.difference(Arrays.asList(key, otherKey))) //
|
||||
.consumeNextWith(actual -> {
|
||||
assertThat(actual).isEqualTo(onlyInKey);
|
||||
}) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void differenceAndStore() {
|
||||
|
||||
K key = keyFactory.instance();
|
||||
@@ -252,10 +272,13 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
StepVerifier.create(setOperations.differenceAndStore(key, otherKey, destKey)).expectNext(1L).expectComplete()
|
||||
.verify();
|
||||
|
||||
StepVerifier.create(setOperations.differenceAndStore(Arrays.asList(key, otherKey), destKey)).expectNext(1L)
|
||||
.expectComplete().verify();
|
||||
|
||||
StepVerifier.create(setOperations.isMember(destKey, onlyInKey)).expectNext(true).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void union() {
|
||||
|
||||
assumeFalse(valueFactory instanceof ByteBufferObjectFactory);
|
||||
@@ -273,9 +296,13 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
StepVerifier.create(setOperations.union(key, otherKey)) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.union(Arrays.asList(key, otherKey))) //
|
||||
.expectNextCount(3) //
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-602
|
||||
@Test // DATAREDIS-602, DATAREDIS-873
|
||||
public void unionAndStore() {
|
||||
|
||||
K key = keyFactory.instance();
|
||||
@@ -291,6 +318,11 @@ public class DefaultReactiveSetOperationsIntegrationTests<K, V> {
|
||||
|
||||
StepVerifier.create(setOperations.unionAndStore(key, otherKey, destKey)).expectNext(3L).verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.delete(destKey)).expectNext(true).verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.unionAndStore(Arrays.asList(key, otherKey), destKey)).expectNext(3L)
|
||||
.verifyComplete();
|
||||
|
||||
StepVerifier.create(setOperations.isMember(destKey, onlyInKey)).expectNext(true).verifyComplete();
|
||||
StepVerifier.create(setOperations.isMember(destKey, shared)).expectNext(true).verifyComplete();
|
||||
StepVerifier.create(setOperations.isMember(destKey, onlyInOtherKey)).expectNext(true).verifyComplete();
|
||||
|
||||
@@ -22,6 +22,7 @@ import static org.junit.Assume.*;
|
||||
import static org.springframework.data.redis.matcher.RedisTestMatchers.*;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -49,6 +50,7 @@ import org.springframework.test.annotation.IfProfileValue;
|
||||
* @author Jennifer Hickey
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class DefaultSetOperationsTests<K, V> {
|
||||
@@ -243,7 +245,94 @@ public class DefaultSetOperationsTests<K, V> {
|
||||
assertThat(count, is(setOps.size(key)));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-448
|
||||
@Test // DATAREDIS-873
|
||||
public void diffShouldReturnDifference() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
K sourceKey2 = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
V v4 = valueFactory.instance();
|
||||
|
||||
setOps.add(sourceKey1, v1, v2, v3);
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.difference(Arrays.asList(sourceKey1, sourceKey2)), hasItems(v1));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-873
|
||||
public void diffAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestination() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
K sourceKey2 = keyFactory.instance();
|
||||
K destinationKey = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
V v4 = valueFactory.instance();
|
||||
|
||||
setOps.add(sourceKey1, v1, v2, v3);
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.differenceAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey), isEqual(1L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-873
|
||||
public void unionShouldConcatSets() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
K sourceKey2 = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
V v4 = valueFactory.instance();
|
||||
|
||||
setOps.add(sourceKey1, v1, v2, v3);
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.union(Arrays.asList(sourceKey1, sourceKey2)), hasItems(v1, v2, v3, v4));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-873
|
||||
public void unionAndStoreShouldReturnDifferenceShouldReturnNumberOfElementsInDestination() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
K sourceKey2 = keyFactory.instance();
|
||||
K destinationKey = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
V v4 = valueFactory.instance();
|
||||
|
||||
setOps.add(sourceKey1, v1, v2, v3);
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.unionAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey), isEqual(4L));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-873
|
||||
public void intersectShouldReturnElements() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
K sourceKey2 = keyFactory.instance();
|
||||
|
||||
V v1 = valueFactory.instance();
|
||||
V v2 = valueFactory.instance();
|
||||
V v3 = valueFactory.instance();
|
||||
V v4 = valueFactory.instance();
|
||||
|
||||
setOps.add(sourceKey1, v1, v2, v3);
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.intersect(Arrays.asList(sourceKey1, sourceKey2)), hasSize(2));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-448, DATAREDIS-873
|
||||
public void intersectAndStoreShouldReturnNumberOfElementsInDestination() {
|
||||
|
||||
K sourceKey1 = keyFactory.instance();
|
||||
@@ -259,5 +348,6 @@ public class DefaultSetOperationsTests<K, V> {
|
||||
setOps.add(sourceKey2, v2, v3, v4);
|
||||
|
||||
assertThat(setOps.intersectAndStore(sourceKey1, sourceKey2, destinationKey), is(2L));
|
||||
assertThat(setOps.intersectAndStore(Arrays.asList(sourceKey1, sourceKey2), destinationKey), is(2L));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user