io.quarkus.redis.datasource.timeseries.IncrementArgs Maven / Gradle / Ivy
Show all versions of quarkus-redis-client Show documentation
package io.quarkus.redis.datasource.timeseries;
import static io.smallrye.mutiny.helpers.ParameterValidation.nonNull;
import java.time.Duration;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import io.quarkus.redis.datasource.RedisCommandExtraArguments;
/**
* Represents the extra arguments of the {@code ts.decrby} and {@code tx.incrby} commands.
*/
public class IncrementArgs implements RedisCommandExtraArguments {
private long timestamp = -1;
private Duration retention;
private boolean uncompressed;
private int chunkSize;
private final Map labels = new HashMap<>();
/**
* Set (integer) UNIX sample timestamp in milliseconds.
*
* timestamp must be equal to or higher than the maximum existing timestamp. When equal, the value of the sample
* with the maximum existing timestamp is decreased. If it is higher, a new sample with a timestamp set to timestamp
* is created, and its value is set to the value of the sample with the maximum existing timestamp minus value.
*
* If the time series is empty, the value is set to {@code value}.
*
* When not specified, the timestamp is set according to the server clock.
*
* @param value the value
* @return the current {@code IncrementArgs}
*/
public IncrementArgs setTimestamp(long value) {
this.timestamp = value;
return this;
}
/**
* Set the maximum retention period, compared to the maximum existing timestamp, in milliseconds.
*
* Use it only if you are creating a new time series.
* It is ignored if you are adding samples to an existing time series.
*
* @param retention the retention, must not be {@code null}
* @return the current {@code IncrementArgs}
*/
public IncrementArgs setRetention(Duration retention) {
this.retention = nonNull(retention, "retention");
return this;
}
/**
* Changes data storage from compressed (default) to uncompressed.
*
* Use it only if you are creating a new time series.
* It is ignored if you are adding samples to an existing time series
*
* @return the current {@code IncrementArgs}
*/
public IncrementArgs uncompressed() {
this.uncompressed = true;
return this;
}
/**
* Sets memory size, in bytes, allocated for each data chunk. Use it only if you are creating a new time series.
* It is ignored if you are adding samples to an existing time series.
*
* @param size the chunk size, between 48 and 1048576
* @return the current {@code IncrementArgs}
*/
public IncrementArgs chunkSize(int size) {
this.chunkSize = size;
return this;
}
/**
* Set a label-value pairs that represent metadata labels of the time series.
*
* @param label the label, must not be {@code null}
* @param value the value, must not be {@code null}
* @return the current {@code IncrementArgs}
*/
public IncrementArgs label(String label, Object value) {
labels.put(label, value);
return this;
}
@Override
public List