com.redis.spring.batch.writer.operation.TsAddAll Maven / Gradle / Ivy
package com.redis.spring.batch.writer.operation;
import java.util.Collection;
import java.util.List;
import java.util.function.Function;
import com.redis.lettucemod.api.async.RedisTimeSeriesAsyncCommands;
import com.redis.lettucemod.timeseries.AddOptions;
import com.redis.lettucemod.timeseries.Sample;
import io.lettuce.core.RedisFuture;
import io.lettuce.core.api.async.BaseRedisAsyncCommands;
public class TsAddAll extends AbstractOperation {
private Function> samples;
private AddOptions options = null;
public void setSamples(Function> samples) {
this.samples = samples;
}
public void setOptions(AddOptions options) {
this.options = options;
}
@SuppressWarnings("unchecked")
@Override
public void execute(BaseRedisAsyncCommands commands, T item, List> futures) {
K key = key(item);
for (Sample sample : samples(item)) {
futures.add(((RedisTimeSeriesAsyncCommands) commands).tsAdd(key, sample, options));
}
}
private Collection samples(T item) {
return samples.apply(item);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy