From 619f8e33c1469d759f7e35e441f7a656a3604229 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque <7600764+sazzad16@users.noreply.github.com> Date: Fri, 14 Jun 2024 10:25:30 +0600 Subject: [PATCH] Revert "Support IGNORE and other optional arguments for timeseries commands (#3860)" This reverts commit e7503d78f86f166028327e45ae1150bd96f2271b. The commit e7503d78f86f166028327e45ae1150bd96f2271b is merged (cherry-picked) into 5.2.0 branch by commit ac18fd00fd919b2f1b2294a2311a56d59fffd33c. --- .../redis/clients/jedis/CommandObjects.java | 20 +-- .../redis/clients/jedis/PipeliningBase.java | 15 -- .../redis/clients/jedis/UnifiedJedis.java | 15 -- .../jedis/timeseries/EncodingFormat.java | 24 ---- .../timeseries/RedisTimeSeriesCommands.java | 55 +------- .../RedisTimeSeriesPipelineCommands.java | 7 - .../clients/jedis/timeseries/TSAddParams.java | 128 ----------------- .../jedis/timeseries/TSAlterParams.java | 28 ---- .../jedis/timeseries/TSCreateParams.java | 39 ++---- .../timeseries/TSIncrOrDecrByParams.java | 132 ------------------ .../jedis/timeseries/TimeSeriesProtocol.java | 1 - .../PipeliningBaseTimeSeriesCommandsTest.java | 47 ++----- .../UnifiedJedisTimeSeriesCommandsTest.java | 71 ++-------- .../modules/timeseries/TimeSeriesTest.java | 55 -------- 14 files changed, 37 insertions(+), 600 deletions(-) delete mode 100644 src/main/java/redis/clients/jedis/timeseries/EncodingFormat.java delete mode 100644 src/main/java/redis/clients/jedis/timeseries/TSAddParams.java delete mode 100644 src/main/java/redis/clients/jedis/timeseries/TSIncrOrDecrByParams.java diff --git a/src/main/java/redis/clients/jedis/CommandObjects.java b/src/main/java/redis/clients/jedis/CommandObjects.java index 421b81c4e2..7226a014a7 100644 --- a/src/main/java/redis/clients/jedis/CommandObjects.java +++ b/src/main/java/redis/clients/jedis/CommandObjects.java @@ -3946,15 +3946,9 @@ public final CommandObject tsAdd(String key, long timestamp, double value) return new CommandObject<>(commandArguments(TimeSeriesCommand.ADD).key(key).add(timestamp).add(value), BuilderFactory.LONG); } - @Deprecated public final CommandObject tsAdd(String key, long timestamp, double value, TSCreateParams createParams) { - return new CommandObject<>(commandArguments(TimeSeriesCommand.ADD).key(key).add(timestamp).add(value) - .addParams(createParams), BuilderFactory.LONG); - } - - public final CommandObject tsAdd(String key, long timestamp, double value, TSAddParams addParams) { - return new CommandObject<>(commandArguments(TimeSeriesCommand.ADD).key(key).add(timestamp).add(value) - .addParams(addParams), BuilderFactory.LONG); + return new CommandObject<>(commandArguments(TimeSeriesCommand.ADD).key(key) + .add(timestamp).add(value).addParams(createParams), BuilderFactory.LONG); } public final CommandObject> tsMAdd(Map.Entry... entries) { @@ -3974,11 +3968,6 @@ public final CommandObject tsIncrBy(String key, double value, long timesta .add(TimeSeriesKeyword.TIMESTAMP).add(timestamp), BuilderFactory.LONG); } - public final CommandObject tsIncrBy(String key, double addend, TSIncrOrDecrByParams incrByParams) { - return new CommandObject<>(commandArguments(TimeSeriesCommand.INCRBY).key(key).add(addend) - .addParams(incrByParams), BuilderFactory.LONG); - } - public final CommandObject tsDecrBy(String key, double value) { return new CommandObject<>(commandArguments(TimeSeriesCommand.DECRBY).key(key).add(value), BuilderFactory.LONG); } @@ -3988,11 +3977,6 @@ public final CommandObject tsDecrBy(String key, double value, long timesta .add(TimeSeriesKeyword.TIMESTAMP).add(timestamp), BuilderFactory.LONG); } - public final CommandObject tsDecrBy(String key, double subtrahend, TSIncrOrDecrByParams decrByParams) { - return new CommandObject<>(commandArguments(TimeSeriesCommand.DECRBY).key(key).add(subtrahend) - .addParams(decrByParams), BuilderFactory.LONG); - } - public final CommandObject> tsRange(String key, long fromTimestamp, long toTimestamp) { return new CommandObject<>(commandArguments(TimeSeriesCommand.RANGE).key(key) .add(fromTimestamp).add(toTimestamp), TimeSeriesBuilderFactory.TIMESERIES_ELEMENT_LIST); diff --git a/src/main/java/redis/clients/jedis/PipeliningBase.java b/src/main/java/redis/clients/jedis/PipeliningBase.java index 9967a2e694..928126a704 100644 --- a/src/main/java/redis/clients/jedis/PipeliningBase.java +++ b/src/main/java/redis/clients/jedis/PipeliningBase.java @@ -3948,11 +3948,6 @@ public Response tsAdd(String key, long timestamp, double value, TSCreatePa return appendCommand(commandObjects.tsAdd(key, timestamp, value, createParams)); } - @Override - public Response tsAdd(String key, long timestamp, double value, TSAddParams addParams) { - return appendCommand(commandObjects.tsAdd(key, timestamp, value, addParams)); - } - @Override public Response> tsMAdd(Map.Entry... entries) { return appendCommand(commandObjects.tsMAdd(entries)); @@ -3968,11 +3963,6 @@ public Response tsIncrBy(String key, double value, long timestamp) { return appendCommand(commandObjects.tsIncrBy(key, value, timestamp)); } - @Override - public Response tsIncrBy(String key, double addend, TSIncrOrDecrByParams incrByParams) { - return appendCommand(commandObjects.tsIncrBy(key, addend, incrByParams)); - } - @Override public Response tsDecrBy(String key, double value) { return appendCommand(commandObjects.tsDecrBy(key, value)); @@ -3983,11 +3973,6 @@ public Response tsDecrBy(String key, double value, long timestamp) { return appendCommand(commandObjects.tsDecrBy(key, value, timestamp)); } - @Override - public Response tsDecrBy(String key, double subtrahend, TSIncrOrDecrByParams decrByParams) { - return appendCommand(commandObjects.tsDecrBy(key, subtrahend, decrByParams)); - } - @Override public Response> tsRange(String key, long fromTimestamp, long toTimestamp) { return appendCommand(commandObjects.tsRange(key, fromTimestamp, toTimestamp)); diff --git a/src/main/java/redis/clients/jedis/UnifiedJedis.java b/src/main/java/redis/clients/jedis/UnifiedJedis.java index 87ba0d8a14..2d6e77fcf0 100644 --- a/src/main/java/redis/clients/jedis/UnifiedJedis.java +++ b/src/main/java/redis/clients/jedis/UnifiedJedis.java @@ -4473,11 +4473,6 @@ public long tsAdd(String key, long timestamp, double value, TSCreateParams creat return executeCommand(commandObjects.tsAdd(key, timestamp, value, createParams)); } - @Override - public long tsAdd(String key, long timestamp, double value, TSAddParams addParams) { - return executeCommand(commandObjects.tsAdd(key, timestamp, value, addParams)); - } - @Override public List tsMAdd(Map.Entry... entries) { return executeCommand(commandObjects.tsMAdd(entries)); @@ -4493,11 +4488,6 @@ public long tsIncrBy(String key, double value, long timestamp) { return executeCommand(commandObjects.tsIncrBy(key, value, timestamp)); } - @Override - public long tsIncrBy(String key, double addend, TSIncrOrDecrByParams incrByParams) { - return executeCommand(commandObjects.tsIncrBy(key, addend, incrByParams)); - } - @Override public long tsDecrBy(String key, double value) { return executeCommand(commandObjects.tsDecrBy(key, value)); @@ -4508,11 +4498,6 @@ public long tsDecrBy(String key, double value, long timestamp) { return executeCommand(commandObjects.tsDecrBy(key, value, timestamp)); } - @Override - public long tsDecrBy(String key, double subtrahend, TSIncrOrDecrByParams decrByParams) { - return executeCommand(commandObjects.tsDecrBy(key, subtrahend, decrByParams)); - } - @Override public List tsRange(String key, long fromTimestamp, long toTimestamp) { return executeCommand(commandObjects.tsRange(key, fromTimestamp, toTimestamp)); diff --git a/src/main/java/redis/clients/jedis/timeseries/EncodingFormat.java b/src/main/java/redis/clients/jedis/timeseries/EncodingFormat.java deleted file mode 100644 index 5130d7da25..0000000000 --- a/src/main/java/redis/clients/jedis/timeseries/EncodingFormat.java +++ /dev/null @@ -1,24 +0,0 @@ -package redis.clients.jedis.timeseries; - -import redis.clients.jedis.args.Rawable; -import redis.clients.jedis.util.SafeEncoder; - -/** - * Specifies the series samples encoding format. - */ -public enum EncodingFormat implements Rawable { - - COMPRESSED, - UNCOMPRESSED; - - private final byte[] raw; - - private EncodingFormat() { - raw = SafeEncoder.encode(name()); - } - - @Override - public byte[] getRaw() { - return raw; - } -} diff --git a/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java b/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java index 67c1b26fcf..c002b94c08 100644 --- a/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java +++ b/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesCommands.java @@ -59,33 +59,16 @@ public interface RedisTimeSeriesCommands { long tsAdd(String key, long timestamp, double value); /** + * {@code TS.ADD key timestamp value [RETENTION retentionTime] [ENCODING [COMPRESSED|UNCOMPRESSED]] [CHUNK_SIZE size] [ON_DUPLICATE policy] [LABELS label value..]} + * * @param key * @param timestamp * @param value * @param createParams * @return timestamp - * @deprecated Use {@link RedisTimeSeriesCommands#tsAdd(java.lang.String, long, double, redis.clients.jedis.timeseries.TSAddParams)}. */ - @Deprecated long tsAdd(String key, long timestamp, double value, TSCreateParams createParams); - /** - * {@code TS.ADD key timestamp value - * [RETENTION retentionTime] - * [ENCODING ] - * [CHUNK_SIZE size] - * [DUPLICATE_POLICY policy] - * [ON_DUPLICATE policy_ovr] - * [LABELS label value..]} - * - * @param key - * @param timestamp - * @param value - * @param addParams - * @return timestamp - */ - long tsAdd(String key, long timestamp, double value, TSAddParams addParams); - /** * {@code TS.MADD key timestamp value [key timestamp value ...]} * @@ -98,44 +81,10 @@ public interface RedisTimeSeriesCommands { long tsIncrBy(String key, double value, long timestamp); - /** - * {@code TS.INCRBY key addend - * [TIMESTAMP timestamp] - * [RETENTION retentionPeriod] - * [ENCODING ] - * [CHUNK_SIZE size] - * [DUPLICATE_POLICY policy] - * [IGNORE ignoreMaxTimediff ignoreMaxValDiff] - * [LABELS [label value ...]]} - * - * @param key - * @param addend - * @param incrByParams - * @return timestamp - */ - long tsIncrBy(String key, double addend, TSIncrOrDecrByParams incrByParams); - long tsDecrBy(String key, double value); long tsDecrBy(String key, double value, long timestamp); - /** - * {@code TS.DECRBY key subtrahend - * [TIMESTAMP timestamp] - * [RETENTION retentionPeriod] - * [ENCODING ] - * [CHUNK_SIZE size] - * [DUPLICATE_POLICY policy] - * [IGNORE ignoreMaxTimediff ignoreMaxValDiff] - * [LABELS [label value ...]]} - * - * @param key - * @param subtrahend - * @param decrByParams - * @return timestamp - */ - long tsDecrBy(String key, double subtrahend, TSIncrOrDecrByParams decrByParams); - /** * {@code TS.RANGE key fromTimestamp toTimestamp} * diff --git a/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java b/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java index b3304716dd..288b3f195e 100644 --- a/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java +++ b/src/main/java/redis/clients/jedis/timeseries/RedisTimeSeriesPipelineCommands.java @@ -18,25 +18,18 @@ public interface RedisTimeSeriesPipelineCommands { Response tsAdd(String key, long timestamp, double value); - @Deprecated Response tsAdd(String key, long timestamp, double value, TSCreateParams createParams); - Response tsAdd(String key, long timestamp, double value, TSAddParams addParams); - Response> tsMAdd(Map.Entry... entries); Response tsIncrBy(String key, double value); Response tsIncrBy(String key, double value, long timestamp); - Response tsIncrBy(String key, double addend, TSIncrOrDecrByParams incrByParams); - Response tsDecrBy(String key, double value); Response tsDecrBy(String key, double value, long timestamp); - Response tsDecrBy(String key, double subtrahend, TSIncrOrDecrByParams decrByParams); - Response> tsRange(String key, long fromTimestamp, long toTimestamp); Response> tsRange(String key, TSRangeParams rangeParams); diff --git a/src/main/java/redis/clients/jedis/timeseries/TSAddParams.java b/src/main/java/redis/clients/jedis/timeseries/TSAddParams.java deleted file mode 100644 index 0a9713cefb..0000000000 --- a/src/main/java/redis/clients/jedis/timeseries/TSAddParams.java +++ /dev/null @@ -1,128 +0,0 @@ -package redis.clients.jedis.timeseries; - -import static redis.clients.jedis.Protocol.toByteArray; -import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*; - -import java.util.LinkedHashMap; -import java.util.Map; -import redis.clients.jedis.CommandArguments; -import redis.clients.jedis.params.IParams; - -/** - * Represents optional arguments of TS.ADD command. - */ -public class TSAddParams implements IParams { - - private Long retentionPeriod; - private EncodingFormat encoding; - private Long chunkSize; - private DuplicatePolicy duplicatePolicy; - private DuplicatePolicy onDuplicate; - - private boolean ignore; - private long ignoreMaxTimediff; - private double ignoreMaxValDiff; - - private Map labels; - - public TSAddParams() { - } - - public static TSAddParams addParams() { - return new TSAddParams(); - } - - public TSAddParams retention(long retentionPeriod) { - this.retentionPeriod = retentionPeriod; - return this; - } - - public TSAddParams encoding(EncodingFormat encoding) { - this.encoding = encoding; - return this; - } - - public TSAddParams chunkSize(long chunkSize) { - this.chunkSize = chunkSize; - return this; - } - - public TSAddParams duplicatePolicy(DuplicatePolicy duplicatePolicy) { - this.duplicatePolicy = duplicatePolicy; - return this; - } - - public TSAddParams onDuplicate(DuplicatePolicy onDuplicate) { - this.onDuplicate = onDuplicate; - return this; - } - - public TSAddParams ignore(long maxTimediff, double maxValDiff) { - this.ignore = true; - this.ignoreMaxTimediff = maxTimediff; - this.ignoreMaxValDiff = maxValDiff; - return this; - } - - /** - * Set label-value pairs - * - * @param labels label-value pairs - * @return the object itself - */ - public TSAddParams labels(Map labels) { - this.labels = labels; - return this; - } - - /** - * Add label-value pair. Multiple pairs can be added through chaining. - * @param label - * @param value - * @return the object itself - */ - public TSAddParams label(String label, String value) { - if (this.labels == null) { - this.labels = new LinkedHashMap<>(); - } - this.labels.put(label, value); - return this; - } - - @Override - public void addParams(CommandArguments args) { - - if (retentionPeriod != null) { - args.add(RETENTION).add(toByteArray(retentionPeriod)); - } - - if (encoding != null) { - args.add(ENCODING).add(encoding); - } - - if (chunkSize != null) { - args.add(CHUNK_SIZE).add(toByteArray(chunkSize)); - } - - if (duplicatePolicy != null) { - args.add(DUPLICATE_POLICY).add(duplicatePolicy); - } - - if (duplicatePolicy != null) { - args.add(DUPLICATE_POLICY).add(duplicatePolicy); - } - - if (onDuplicate != null) { - args.add(ON_DUPLICATE).add(onDuplicate); - } - - if (ignore) { - args.add(IGNORE).add(ignoreMaxTimediff).add(ignoreMaxValDiff); - } - - if (labels != null) { - args.add(LABELS); - labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue())); - } - } -} diff --git a/src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java b/src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java index 50ba9723ac..4576a1b6b7 100644 --- a/src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java +++ b/src/main/java/redis/clients/jedis/timeseries/TSAlterParams.java @@ -17,11 +17,6 @@ public class TSAlterParams implements IParams { private Long retentionPeriod; private Long chunkSize; private DuplicatePolicy duplicatePolicy; - - private boolean ignore; - private long ignoreMaxTimediff; - private double ignoreMaxValDiff; - private Map labels; public TSAlterParams() { @@ -46,30 +41,11 @@ public TSAlterParams duplicatePolicy(DuplicatePolicy duplicatePolicy) { return this; } - public TSAlterParams ignore(long maxTimediff, double maxValDiff) { - this.ignore = true; - this.ignoreMaxTimediff = maxTimediff; - this.ignoreMaxValDiff = maxValDiff; - return this; - } - - /** - * Set label-value pairs - * - * @param labels label-value pairs - * @return the object itself - */ public TSAlterParams labels(Map labels) { this.labels = labels; return this; } - /** - * Add label-value pair. Multiple pairs can be added through chaining. - * @param label - * @param value - * @return the object itself - */ public TSAlterParams label(String label, String value) { if (this.labels == null) { this.labels = new LinkedHashMap<>(); @@ -97,10 +73,6 @@ public void addParams(CommandArguments args) { args.add(DUPLICATE_POLICY).add(duplicatePolicy); } - if (ignore) { - args.add(IGNORE).add(ignoreMaxTimediff).add(ignoreMaxValDiff); - } - if (labels != null) { args.add(LABELS); labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue())); diff --git a/src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java b/src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java index 0611383d4d..ca07de1f01 100644 --- a/src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java +++ b/src/main/java/redis/clients/jedis/timeseries/TSCreateParams.java @@ -14,14 +14,10 @@ public class TSCreateParams implements IParams { private Long retentionPeriod; - private EncodingFormat encoding; + private boolean uncompressed; + private boolean compressed; private Long chunkSize; private DuplicatePolicy duplicatePolicy; - - private boolean ignore; - private long ignoreMaxTimediff; - private double ignoreMaxValDiff; - private Map labels; public TSCreateParams() { @@ -36,18 +32,13 @@ public TSCreateParams retention(long retentionPeriod) { return this; } - // TODO: deprecate public TSCreateParams uncompressed() { - return encoding(EncodingFormat.UNCOMPRESSED); + this.uncompressed = true; + return this; } - // TODO: deprecate public TSCreateParams compressed() { - return encoding(EncodingFormat.COMPRESSED); - } - - public TSCreateParams encoding(EncodingFormat encoding) { - this.encoding = encoding; + this.compressed = true; return this; } @@ -61,13 +52,6 @@ public TSCreateParams duplicatePolicy(DuplicatePolicy duplicatePolicy) { return this; } - public TSCreateParams ignore(long maxTimediff, double maxValDiff) { - this.ignore = true; - this.ignoreMaxTimediff = maxTimediff; - this.ignoreMaxValDiff = maxValDiff; - return this; - } - /** * Set label-value pairs * @@ -81,9 +65,6 @@ public TSCreateParams labels(Map labels) { /** * Add label-value pair. Multiple pairs can be added through chaining. - * @param label - * @param value - * @return the object itself */ public TSCreateParams label(String label, String value) { if (this.labels == null) { @@ -100,8 +81,10 @@ public void addParams(CommandArguments args) { args.add(RETENTION).add(toByteArray(retentionPeriod)); } - if (encoding != null) { - args.add(ENCODING).add(encoding); + if (uncompressed) { + args.add(ENCODING).add(UNCOMPRESSED); + } else if (compressed) { + args.add(ENCODING).add(COMPRESSED); } if (chunkSize != null) { @@ -112,10 +95,6 @@ public void addParams(CommandArguments args) { args.add(DUPLICATE_POLICY).add(duplicatePolicy); } - if (ignore) { - args.add(IGNORE).add(ignoreMaxTimediff).add(ignoreMaxValDiff); - } - if (labels != null) { args.add(LABELS); labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue())); diff --git a/src/main/java/redis/clients/jedis/timeseries/TSIncrOrDecrByParams.java b/src/main/java/redis/clients/jedis/timeseries/TSIncrOrDecrByParams.java deleted file mode 100644 index fde848fb5a..0000000000 --- a/src/main/java/redis/clients/jedis/timeseries/TSIncrOrDecrByParams.java +++ /dev/null @@ -1,132 +0,0 @@ -package redis.clients.jedis.timeseries; - -import static redis.clients.jedis.Protocol.toByteArray; -import static redis.clients.jedis.timeseries.TimeSeriesProtocol.TimeSeriesKeyword.*; - -import java.util.LinkedHashMap; -import java.util.Map; -import redis.clients.jedis.CommandArguments; -import redis.clients.jedis.params.IParams; - -/** - * Represents optional arguments of TS.INCRBY or TS.DECRBY commands. - */ -public class TSIncrOrDecrByParams implements IParams { - - private Long timestamp; - private Long retentionPeriod; - private EncodingFormat encoding; - private Long chunkSize; - private DuplicatePolicy duplicatePolicy; - - private boolean ignore; - private long ignoreMaxTimediff; - private double ignoreMaxValDiff; - - private Map labels; - - public TSIncrOrDecrByParams() { - } - - public static TSIncrOrDecrByParams params() { - return new TSIncrOrDecrByParams(); - } - - public static TSIncrOrDecrByParams incrByParams() { - return new TSIncrOrDecrByParams(); - } - - public static TSIncrOrDecrByParams decrByParams() { - return new TSIncrOrDecrByParams(); - } - - public TSIncrOrDecrByParams timestamp(long timestamp) { - this.timestamp = timestamp; - return this; - } - - public TSIncrOrDecrByParams retention(long retentionPeriod) { - this.retentionPeriod = retentionPeriod; - return this; - } - - public TSIncrOrDecrByParams encoding(EncodingFormat encoding) { - this.encoding = encoding; - return this; - } - - public TSIncrOrDecrByParams chunkSize(long chunkSize) { - this.chunkSize = chunkSize; - return this; - } - - public TSIncrOrDecrByParams duplicatePolicy(DuplicatePolicy duplicatePolicy) { - this.duplicatePolicy = duplicatePolicy; - return this; - } - - public TSIncrOrDecrByParams ignore(long maxTimediff, double maxValDiff) { - this.ignore = true; - this.ignoreMaxTimediff = maxTimediff; - this.ignoreMaxValDiff = maxValDiff; - return this; - } - - /** - * Set label-value pairs - * - * @param labels label-value pairs - * @return the object itself - */ - public TSIncrOrDecrByParams labels(Map labels) { - this.labels = labels; - return this; - } - - /** - * Add label-value pair. Multiple pairs can be added through chaining. - * @param label - * @param value - * @return the object itself - */ - public TSIncrOrDecrByParams label(String label, String value) { - if (this.labels == null) { - this.labels = new LinkedHashMap<>(); - } - this.labels.put(label, value); - return this; - } - - @Override - public void addParams(CommandArguments args) { - - if (timestamp != null) { - args.add(TIMESTAMP).add(timestamp); - } - - if (retentionPeriod != null) { - args.add(RETENTION).add(toByteArray(retentionPeriod)); - } - - if (encoding != null) { - args.add(ENCODING).add(encoding); - } - - if (chunkSize != null) { - args.add(CHUNK_SIZE).add(toByteArray(chunkSize)); - } - - if (duplicatePolicy != null) { - args.add(DUPLICATE_POLICY).add(duplicatePolicy); - } - - if (ignore) { - args.add(IGNORE).add(ignoreMaxTimediff).add(ignoreMaxValDiff); - } - - if (labels != null) { - args.add(LABELS); - labels.entrySet().forEach((entry) -> args.add(entry.getKey()).add(entry.getValue())); - } - } -} diff --git a/src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java b/src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java index 384a454921..2476979f0d 100644 --- a/src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java +++ b/src/main/java/redis/clients/jedis/timeseries/TimeSeriesProtocol.java @@ -57,7 +57,6 @@ public enum TimeSeriesKeyword implements Rawable { UNCOMPRESSED, CHUNK_SIZE, DUPLICATE_POLICY, - IGNORE, ON_DUPLICATE, ALIGN, FILTER_BY_TS, diff --git a/src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java b/src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java index b8cfb85dc8..44e653c011 100644 --- a/src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java +++ b/src/test/java/redis/clients/jedis/mocked/pipeline/PipeliningBaseTimeSeriesCommandsTest.java @@ -3,7 +3,6 @@ import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.contains; import static org.hamcrest.Matchers.is; -import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.util.AbstractMap; @@ -12,7 +11,17 @@ import org.junit.Test; import redis.clients.jedis.Response; -import redis.clients.jedis.timeseries.*; +import redis.clients.jedis.timeseries.AggregationType; +import redis.clients.jedis.timeseries.TSAlterParams; +import redis.clients.jedis.timeseries.TSCreateParams; +import redis.clients.jedis.timeseries.TSElement; +import redis.clients.jedis.timeseries.TSGetParams; +import redis.clients.jedis.timeseries.TSInfo; +import redis.clients.jedis.timeseries.TSMGetElement; +import redis.clients.jedis.timeseries.TSMGetParams; +import redis.clients.jedis.timeseries.TSMRangeElements; +import redis.clients.jedis.timeseries.TSMRangeParams; +import redis.clients.jedis.timeseries.TSRangeParams; public class PipeliningBaseTimeSeriesCommandsTest extends PipeliningBaseMockedTestBase { @@ -48,18 +57,6 @@ public void testTsAddWithTimestampAndParams() { assertThat(response, is(predefinedResponse)); } - @Test - public void testTsAddWithParams() { - TSAddParams addParams = mock(TSAddParams.class); - - when(commandObjects.tsAdd("myTimeSeries", 1000L, 42.0, addParams)).thenReturn(longCommandObject); - - Response response = pipeliningBase.tsAdd("myTimeSeries", 1000L, 42.0, addParams); - - assertThat(commands, contains(longCommandObject)); - assertThat(response, is(predefinedResponse)); - } - @Test public void testTsAlter() { TSAlterParams alterParams = TSAlterParams.alterParams(); @@ -141,17 +138,6 @@ public void testTsDecrByWithTimestamp() { assertThat(response, is(predefinedResponse)); } - @Test - public void testTsDecrByWithParams() { - TSIncrOrDecrByParams DecrByParams = mock(TSIncrOrDecrByParams.class); - when(commandObjects.tsDecrBy("myTimeSeries", 1.0, DecrByParams)).thenReturn(longCommandObject); - - Response response = pipeliningBase.tsDecrBy("myTimeSeries", 1.0, DecrByParams); - - assertThat(commands, contains(longCommandObject)); - assertThat(response, is(predefinedResponse)); - } - @Test public void testTsDel() { when(commandObjects.tsDel("myTimeSeries", 1000L, 2000L)).thenReturn(longCommandObject); @@ -214,17 +200,6 @@ public void testTsIncrByWithTimestamp() { assertThat(response, is(predefinedResponse)); } - @Test - public void testTsIncrByWithParams() { - TSIncrOrDecrByParams incrByParams = mock(TSIncrOrDecrByParams.class); - when(commandObjects.tsIncrBy("myTimeSeries", 1.0, incrByParams)).thenReturn(longCommandObject); - - Response response = pipeliningBase.tsIncrBy("myTimeSeries", 1.0, incrByParams); - - assertThat(commands, contains(longCommandObject)); - assertThat(response, is(predefinedResponse)); - } - @Test public void testTsInfo() { when(commandObjects.tsInfo("myTimeSeries")).thenReturn(tsInfoCommandObject); diff --git a/src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java b/src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java index 53c673da49..d9e06ce77c 100644 --- a/src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java +++ b/src/test/java/redis/clients/jedis/mocked/unified/UnifiedJedisTimeSeriesCommandsTest.java @@ -15,7 +15,17 @@ import java.util.Map; import org.junit.Test; -import redis.clients.jedis.timeseries.*; +import redis.clients.jedis.timeseries.AggregationType; +import redis.clients.jedis.timeseries.TSAlterParams; +import redis.clients.jedis.timeseries.TSCreateParams; +import redis.clients.jedis.timeseries.TSElement; +import redis.clients.jedis.timeseries.TSGetParams; +import redis.clients.jedis.timeseries.TSInfo; +import redis.clients.jedis.timeseries.TSMGetElement; +import redis.clients.jedis.timeseries.TSMGetParams; +import redis.clients.jedis.timeseries.TSMRangeElements; +import redis.clients.jedis.timeseries.TSMRangeParams; +import redis.clients.jedis.timeseries.TSRangeParams; public class UnifiedJedisTimeSeriesCommandsTest extends UnifiedJedisMockedTestBase { @@ -73,25 +83,6 @@ public void testTsAddWithTimestampAndParams() { verify(commandObjects).tsAdd(key, timestamp, value, createParams); } - @Test - public void testTsAddWithParams() { - String key = "testKey"; - long timestamp = 1582605077000L; - double value = 123.45; - TSAddParams createParams = mock(TSAddParams.class); - long expectedResponse = timestamp; // Timestamp of the added value - - when(commandObjects.tsAdd(key, timestamp, value, createParams)).thenReturn(longCommandObject); - when(commandExecutor.executeCommand(longCommandObject)).thenReturn(expectedResponse); - - long result = jedis.tsAdd(key, timestamp, value, createParams); - - assertEquals(expectedResponse, result); - - verify(commandExecutor).executeCommand(longCommandObject); - verify(commandObjects).tsAdd(key, timestamp, value, createParams); - } - @Test public void testTsAlter() { String key = "testKey"; @@ -203,7 +194,7 @@ public void testTsDecrByWithTimestamp() { String key = "testKey"; double value = 1.5; long timestamp = 1582605077000L; - long expectedResponse = 5L; + long expectedResponse = -1L; // Assuming the decrement results in a total of -1 when(commandObjects.tsDecrBy(key, value, timestamp)).thenReturn(longCommandObject); when(commandExecutor.executeCommand(longCommandObject)).thenReturn(expectedResponse); @@ -216,24 +207,6 @@ public void testTsDecrByWithTimestamp() { verify(commandObjects).tsDecrBy(key, value, timestamp); } - @Test - public void testTsDecrByWithParams() { - String key = "testKey"; - double value = 1.5; - TSIncrOrDecrByParams decrByParams = mock(TSIncrOrDecrByParams.class); - long expectedResponse = 5L; - - when(commandObjects.tsDecrBy(key, value, decrByParams)).thenReturn(longCommandObject); - when(commandExecutor.executeCommand(longCommandObject)).thenReturn(expectedResponse); - - long result = jedis.tsDecrBy(key, value, decrByParams); - - assertEquals(expectedResponse, result); - - verify(commandExecutor).executeCommand(longCommandObject); - verify(commandObjects).tsDecrBy(key, value, decrByParams); - } - @Test public void testTsDel() { String key = "testKey"; @@ -324,7 +297,7 @@ public void testTsIncrByWithTimestamp() { String key = "testKey"; double value = 2.5; long timestamp = 1582605077000L; - long expectedResponse = 5L; + long expectedResponse = 5L; // Assuming the increment results in a total of 5 when(commandObjects.tsIncrBy(key, value, timestamp)).thenReturn(longCommandObject); when(commandExecutor.executeCommand(longCommandObject)).thenReturn(expectedResponse); @@ -337,24 +310,6 @@ public void testTsIncrByWithTimestamp() { verify(commandObjects).tsIncrBy(key, value, timestamp); } - @Test - public void testTsIncrByWithParams() { - String key = "testKey"; - double value = 2.5; - TSIncrOrDecrByParams incrByParams = mock(TSIncrOrDecrByParams.class); - long expectedResponse = 5L; - - when(commandObjects.tsIncrBy(key, value, incrByParams)).thenReturn(longCommandObject); - when(commandExecutor.executeCommand(longCommandObject)).thenReturn(expectedResponse); - - long result = jedis.tsIncrBy(key, value, incrByParams); - - assertEquals(expectedResponse, result); - - verify(commandExecutor).executeCommand(longCommandObject); - verify(commandObjects).tsIncrBy(key, value, incrByParams); - } - @Test public void testTsInfo() { String key = "testKey"; diff --git a/src/test/java/redis/clients/jedis/modules/timeseries/TimeSeriesTest.java b/src/test/java/redis/clients/jedis/modules/timeseries/TimeSeriesTest.java index dd0688f080..fe0f7d1604 100644 --- a/src/test/java/redis/clients/jedis/modules/timeseries/TimeSeriesTest.java +++ b/src/test/java/redis/clients/jedis/modules/timeseries/TimeSeriesTest.java @@ -122,23 +122,6 @@ public void testAlter() { assertEquals("v33", info.getLabel("l3")); } - @Test - public void createAndAlterParams() { - Map labels = new HashMap<>(); - labels.put("l1", "v1"); - labels.put("l2", "v2"); - - assertEquals("OK", client.tsCreate("ts-params", - TSCreateParams.createParams().retention(60000).encoding(EncodingFormat.UNCOMPRESSED).chunkSize(4096) - .duplicatePolicy(DuplicatePolicy.BLOCK).ignore(50, 12.5).labels(labels))); - - labels.put("l1", "v11"); - labels.remove("l2"); - labels.put("l3", "v33"); - assertEquals("OK", client.tsAlter("ts-params", TSAlterParams.alterParams().retention(15000).chunkSize(8192) - .duplicatePolicy(DuplicatePolicy.SUM).ignore(50, 12.5).labels(labels))); - } - @Test public void testRule() { assertEquals("OK", client.tsCreate("source")); @@ -164,21 +147,6 @@ public void testRule() { } } - @Test - public void addParams() { - Map labels = new HashMap<>(); - labels.put("l1", "v1"); - labels.put("l2", "v2"); - - assertEquals(1000L, client.tsAdd("add1", 1000L, 1.1, - TSAddParams.addParams().retention(10000).encoding(EncodingFormat.UNCOMPRESSED).chunkSize(1000) - .duplicatePolicy(DuplicatePolicy.FIRST).onDuplicate(DuplicatePolicy.LAST).ignore(50, 12.5).labels(labels))); - - assertEquals(1000L, client.tsAdd("add2", 1000L, 1.1, - TSAddParams.addParams().retention(10000).encoding(EncodingFormat.COMPRESSED).chunkSize(1000) - .duplicatePolicy(DuplicatePolicy.MIN).onDuplicate(DuplicatePolicy.MAX).ignore(50, 12.5).labels(labels))); - } - @Test public void testAdd() { Map labels = new HashMap<>(); @@ -446,29 +414,6 @@ public void testIncrByDecrBy() throws InterruptedException { client.tsDecrBy("seriesIncDec", 33); } - @Test - public void incrByDecrByParams() { - Map labels = new HashMap<>(); - labels.put("l1", "v1"); - labels.put("l2", "v2"); - - assertEquals(1000L, client.tsIncrBy("incr1", 1.1, - TSIncrOrDecrByParams.incrByParams().timestamp(1000).retention(10000).encoding(EncodingFormat.UNCOMPRESSED) - .chunkSize(1000).duplicatePolicy(DuplicatePolicy.FIRST).ignore(50, 12.5).labels(labels))); - - assertEquals(1000L, client.tsIncrBy("incr2", 1.1, - TSIncrOrDecrByParams.incrByParams().timestamp(1000).retention(10000).encoding(EncodingFormat.COMPRESSED) - .chunkSize(1000).duplicatePolicy(DuplicatePolicy.MIN).ignore(50, 12.5).labels(labels))); - - assertEquals(1000L, client.tsDecrBy("decr1", 1.1, - TSIncrOrDecrByParams.decrByParams().timestamp(1000).retention(10000).encoding(EncodingFormat.COMPRESSED) - .chunkSize(1000).duplicatePolicy(DuplicatePolicy.LAST).ignore(50, 12.5).labels(labels))); - - assertEquals(1000L, client.tsDecrBy("decr2", 1.1, - TSIncrOrDecrByParams.decrByParams().timestamp(1000).retention(10000).encoding(EncodingFormat.UNCOMPRESSED) - .chunkSize(1000).duplicatePolicy(DuplicatePolicy.MAX).ignore(50, 12.5).labels(labels))); - } - @Test public void align() { client.tsAdd("align", 1, 10d);