com.redis.spring.batch.common.ToSampleFunction Maven / Gradle / Ivy
The newest version!
package com.redis.spring.batch.common;
import java.util.function.Function;
import java.util.function.ToDoubleFunction;
import java.util.function.ToLongFunction;
import com.redis.lettucemod.timeseries.Sample;
public class ToSampleFunction implements Function {
private final ToLongFunction timestampConverter;
private final ToDoubleFunction valueConverter;
public ToSampleFunction(ToLongFunction timestamp, ToDoubleFunction value) {
this.timestampConverter = timestamp;
this.valueConverter = value;
}
@Override
public Sample apply(T source) {
double value = this.valueConverter.applyAsDouble(source);
long timestamp = this.timestampConverter.applyAsLong(source);
return Sample.of(timestamp, value);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy