From 18fcf99e34efb3f38d646469cfcb4345dca55353 Mon Sep 17 00:00:00 2001 From: Nikita Koksharov Date: Tue, 8 Feb 2022 13:34:09 +0300 Subject: [PATCH] RTimeSeries.putAll test added --- .../main/java/org/redisson/RedissonTimeSeries.java | 4 ++-- .../java/org/redisson/RedissonTimeSeriesTest.java | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/redisson/src/main/java/org/redisson/RedissonTimeSeries.java b/redisson/src/main/java/org/redisson/RedissonTimeSeries.java index c17817097..949eaa6b0 100644 --- a/redisson/src/main/java/org/redisson/RedissonTimeSeries.java +++ b/redisson/src/main/java/org/redisson/RedissonTimeSeries.java @@ -122,7 +122,7 @@ public class RedissonTimeSeries 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 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); " + diff --git a/redisson/src/test/java/org/redisson/RedissonTimeSeriesTest.java b/redisson/src/test/java/org/redisson/RedissonTimeSeriesTest.java index ac8883e0d..f7d38e8ba 100644 --- a/redisson/src/test/java/org/redisson/RedissonTimeSeriesTest.java +++ b/redisson/src/test/java/org/redisson/RedissonTimeSeriesTest.java @@ -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 t = redisson.getTimeSeries("test"); + Map 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 t = redisson.getTimeSeries("test");