DATAREDIS-756 - Order results of partitioned multi-key commands by positional keys.
We now order and assemble results of multi-key commands (e.g. MGET with cross-slot keys) that are executed on different nodes by positional keys to retain duplicate keys in the requested order and retain the server response. Previously duplicate keys were treated as set of keys and the response didn't match the requested keys. Original Pull Request: #303
This commit is contained in:
committed by
Christoph Strobl
parent
765a6d1cb0
commit
f79d292142
@@ -243,9 +243,15 @@ public interface ClusterConnectionTests {
|
||||
// DATAREDIS-315
|
||||
void lSetShouldSetElementAtPositionCorrectly();
|
||||
|
||||
// DATAREDIS-756
|
||||
void mGetShouldReturnMultipleSameKeysWhenKeysDoNotMapToSameSlot();
|
||||
|
||||
// DATAREDIS-315
|
||||
void lRemShouldRemoveElementAtPositionCorrectly();
|
||||
|
||||
// DATAREDIS-756
|
||||
void mGetShouldReturnMultipleSameKeysWhenKeysMapToSameSlot();
|
||||
|
||||
// DATAREDIS-315
|
||||
void lPopShouldReturnElementCorrectly();
|
||||
|
||||
|
||||
@@ -967,6 +967,17 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(clusterConnection.sIsMember(KEY_1_BYTES, JedisConverters.toBytes("foo")), is(false));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-756
|
||||
public void mGetShouldReturnMultipleSameKeysWhenKeysDoNotMapToSameSlot() {
|
||||
|
||||
nativeConnection.set(KEY_1_BYTES, VALUE_1_BYTES);
|
||||
nativeConnection.set(KEY_2_BYTES, VALUE_2_BYTES);
|
||||
nativeConnection.set(KEY_3_BYTES, VALUE_3_BYTES);
|
||||
|
||||
List<byte[]> result = clusterConnection.mGet(KEY_1_BYTES, KEY_2_BYTES, KEY_3_BYTES, KEY_1_BYTES);
|
||||
assertThat(result, contains(VALUE_1_BYTES, VALUE_2_BYTES, VALUE_3_BYTES, VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void sInterShouldWorkForKeysMappingToSameSlot() {
|
||||
|
||||
@@ -976,6 +987,16 @@ public class JedisClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(clusterConnection.sInter(SAME_SLOT_KEY_1_BYTES, SAME_SLOT_KEY_2_BYTES), hasItem(VALUE_2_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-756
|
||||
public void mGetShouldReturnMultipleSameKeysWhenKeysMapToSameSlot() {
|
||||
|
||||
nativeConnection.set(SAME_SLOT_KEY_1_BYTES, VALUE_1_BYTES);
|
||||
nativeConnection.set(SAME_SLOT_KEY_2_BYTES, VALUE_2_BYTES);
|
||||
|
||||
List<byte[]> result = clusterConnection.mGet(SAME_SLOT_KEY_1_BYTES, SAME_SLOT_KEY_2_BYTES, SAME_SLOT_KEY_1_BYTES);
|
||||
assertThat(result, contains(VALUE_1_BYTES, VALUE_2_BYTES, VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void sInterShouldWorkForKeysNotMappingToSameSlot() {
|
||||
|
||||
|
||||
@@ -892,6 +892,16 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(nativeConnection.exists(KEY_2), is(true));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-756
|
||||
public void mGetShouldReturnMultipleSameKeysWhenKeysDoNotMapToSameSlot() {
|
||||
|
||||
nativeConnection.set(KEY_1, VALUE_1);
|
||||
nativeConnection.set(KEY_2, VALUE_2);
|
||||
|
||||
assertThat(clusterConnection.mGet(KEY_1_BYTES, KEY_2_BYTES, KEY_1_BYTES),
|
||||
contains(VALUE_1_BYTES, VALUE_2_BYTES, VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void bRPopLPushShouldWorkOnSameSlotKeys() {
|
||||
|
||||
@@ -901,6 +911,16 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
assertThat(nativeConnection.exists(SAME_SLOT_KEY_2), is(true));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-756
|
||||
public void mGetShouldReturnMultipleSameKeysWhenKeysMapToSameSlot() {
|
||||
|
||||
nativeConnection.set(SAME_SLOT_KEY_1, VALUE_1);
|
||||
nativeConnection.set(SAME_SLOT_KEY_2, VALUE_2);
|
||||
|
||||
assertThat(clusterConnection.mGet(SAME_SLOT_KEY_1_BYTES, SAME_SLOT_KEY_2_BYTES, SAME_SLOT_KEY_1_BYTES),
|
||||
contains(VALUE_1_BYTES, VALUE_2_BYTES, VALUE_1_BYTES));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void rPopLPushShouldWorkWhenKeysOnSameSlot() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user