mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-28 17:51:06 -06:00
add FixedValues for double
This commit is contained in:
parent
fa85704b83
commit
a3e0739ade
@ -0,0 +1,23 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_double;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongToDoubleFunction;
|
||||
|
||||
@ThreadSafeMapper
|
||||
public class FixedValues implements LongToDoubleFunction {
|
||||
|
||||
private final long[] fixedValues;
|
||||
|
||||
@Example({"FixedValues(3D,53D,73d)", "Yield 3D, 53D, 73D, 3D, 53D, 73D, 3D, ..."})
|
||||
public FixedValues(long... values) {
|
||||
this.fixedValues = values;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double applyAsDouble(long value) {
|
||||
int index = (int) (value % Integer.MAX_VALUE) % fixedValues.length;
|
||||
return fixedValues[index];
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user