From 0c6bdfd6eca3ad338e895cdce10198fe8f326687 Mon Sep 17 00:00:00 2001 From: Julien Ruaux Date: Sun, 31 Jul 2022 17:19:50 -0700 Subject: [PATCH] feat: Added TimeSeries generator options --- .../redis/riot/gen/DataStructureGeneratorCommand.java | 1 + .../redis/riot/gen/DataStructureGeneratorOptions.java | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorCommand.java b/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorCommand.java index e54150260..dd1af62fb 100644 --- a/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorCommand.java +++ b/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorCommand.java @@ -55,6 +55,7 @@ private ItemReader> reader() { .zsetScore(options.getZsetScore()).hashSize(options.getHashSize()) .hashFieldSize(options.getHashFieldSize()).jsonFieldCount(options.getJsonSize()) .jsonFieldSize(options.getJsonFieldSize()); + options.getTimeseriesStartTime().ifPresent(t -> reader.timeseriesStartTime(t.toEpochMilli())); options.getExpiration().ifPresent(reader::expiration); Optional sleep = options.getSleep(); if (sleep.isPresent() && sleep.get() > 0) { diff --git a/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorOptions.java b/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorOptions.java index 1725100db..1b1e29a15 100644 --- a/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorOptions.java +++ b/connectors/riot-gen/src/main/java/com/redis/riot/gen/DataStructureGeneratorOptions.java @@ -2,6 +2,7 @@ import static com.redis.spring.batch.reader.DataStructureGeneratorItemReader.*; +import java.time.Instant; import java.util.Arrays; import java.util.List; import java.util.Optional; @@ -43,6 +44,8 @@ public class DataStructureGeneratorOptions extends GeneratorOptions { private IntRange stringSize = DEFAULT_STRING_SIZE; @Option(names = "--ts-size", description = "Number of samples in timeseries (default: ${DEFAULT-VALUE}).", paramLabel = "") private IntRange timeseriesSize = DEFAULT_TIMESERIES_SIZE; + @Option(names = "--ts-time", description = "Start time for samples in timeseries, e.g. 2007-12-03T10:15:30.00Z (default: now).", paramLabel = "") + private Optional timeseriesStartTime = Optional.empty(); @Option(names = "--zset-size", description = "Number of elements in sorted sets (default: ${DEFAULT-VALUE}).", paramLabel = "") private IntRange zsetSize = DEFAULT_ZSET_SIZE; @Option(names = "--zset-score", description = "Score of sorted sets (default: ${DEFAULT-VALUE}).", paramLabel = "") @@ -172,6 +175,14 @@ public void setTimeseriesSize(IntRange timeseriesSize) { this.timeseriesSize = timeseriesSize; } + public Optional getTimeseriesStartTime() { + return timeseriesStartTime; + } + + public void setTimeseriesStartTime(Optional timeseriesStartTime) { + this.timeseriesStartTime = timeseriesStartTime; + } + public void setTypes(List types) { this.types = types; }