io.nosqlbench.virtdata.library.curves4.discrete.common.DiscreteLongLongSampler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package io.nosqlbench.virtdata.library.curves4.discrete.common;
import java.util.function.DoubleToIntFunction;
import java.util.function.LongUnaryOperator;
public class DiscreteLongLongSampler implements LongUnaryOperator {
private final DoubleToIntFunction f;
private ThreadSafeHash hash;
public DiscreteLongLongSampler(DoubleToIntFunction parentFunc, boolean hash) {
this.f = parentFunc;
if (hash) {
this.hash = new ThreadSafeHash();
}
}
@Override
public long applyAsLong(long value) {
if (hash!=null) {
value = hash.applyAsLong(value);
}
double unit = (double) value / (double) Long.MAX_VALUE;
int sample =f.applyAsInt(unit);
return sample;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy