RTimeSeries.putAll test added

pull/4125/head
Nikita Koksharov 3 years ago
parent 393d33585b
commit 18fcf99e34

@ -122,7 +122,7 @@ public class RedissonTimeSeries<V> extends RedissonExpirable implements RTimeSer
if (timeToLive > 0) {
return commandExecutor.evalWriteAsync(getRawName(), codec, RedisCommands.EVAL_VOID,
"for i = 2, #ARGV, 4 do " +
"for i = 2, #ARGV, 3 do " +
"local val = struct.pack('Bc0Lc0', string.len(ARGV[i+1]), ARGV[i+1], string.len(ARGV[i+2]), ARGV[i+2]); " +
"redis.call('zadd', KEYS[1], ARGV[i], val); " +
"redis.call('zadd', KEYS[2], ARGV[1], val); " +
@ -136,7 +136,7 @@ public class RedissonTimeSeries<V> extends RedissonExpirable implements RTimeSer
"if (#lastValues > 0 and tonumber(lastValues[2]) > tonumber(ARGV[1])) then " +
"expirationTime = tonumber(lastValues[2]); " +
"end; " +
"for i = 2, #ARGV, 4 do " +
"for i = 2, #ARGV, 3 do " +
"local val = struct.pack('Bc0Lc0', string.len(ARGV[i+1]), ARGV[i+1], string.len(ARGV[i+2]), ARGV[i+2]); " +
"redis.call('zadd', KEYS[1], ARGV[i], val); " +
"redis.call('zadd', KEYS[2], expirationTime + 1, val); " +

@ -5,7 +5,9 @@ import org.redisson.api.RTimeSeries;
import org.redisson.api.TimeSeriesEntry;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import static org.assertj.core.api.Assertions.assertThat;
@ -26,6 +28,18 @@ public class RedissonTimeSeriesTest extends BaseTest {
assertThat(ts.size()).isEqualTo(10000);
}
@Test
public void testPutAll() {
RTimeSeries<String> t = redisson.getTimeSeries("test");
Map<Long, String> map = new HashMap<>();
map.put(1L, "1");
map.put(2L, "2");
map.put(3L, "3");
map.put(4L, "4");
t.addAll(map);
assertThat(t.size()).isEqualTo(4);
}
@Test
public void testOrder() {
RTimeSeries<String> t = redisson.getTimeSeries("test");

Loading…
Cancel
Save