Skip to content

Commit

Permalink
feat: Added TimeSeries generator options
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien Ruaux committed Aug 1, 2022
1 parent 7d6c538 commit 0c6bdfd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ private ItemReader<DataStructure<String>> 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<Long> sleep = options.getSleep();
if (sleep.isPresent() && sleep.get() > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 = "<range>")
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 = "<epoch>")
private Optional<Instant> timeseriesStartTime = Optional.empty();
@Option(names = "--zset-size", description = "Number of elements in sorted sets (default: ${DEFAULT-VALUE}).", paramLabel = "<range>")
private IntRange zsetSize = DEFAULT_ZSET_SIZE;
@Option(names = "--zset-score", description = "Score of sorted sets (default: ${DEFAULT-VALUE}).", paramLabel = "<range>")
Expand Down Expand Up @@ -172,6 +175,14 @@ public void setTimeseriesSize(IntRange timeseriesSize) {
this.timeseriesSize = timeseriesSize;
}

public Optional<Instant> getTimeseriesStartTime() {
return timeseriesStartTime;
}

public void setTimeseriesStartTime(Optional<Instant> timeseriesStartTime) {
this.timeseriesStartTime = timeseriesStartTime;
}

public void setTypes(List<Type> types) {
this.types = types;
}
Expand Down

0 comments on commit 0c6bdfd

Please sign in to comment.