mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-12-28 01:31:05 -06:00
improve StringSet argument compatibility
This commit is contained in:
parent
a123487935
commit
480db201fe
@ -8,6 +8,7 @@ import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import java.util.HashSet;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongToIntFunction;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
/**
|
||||
* Create a {@code Set<String>} from a long
|
||||
@ -35,6 +36,16 @@ public class StringSet implements LongFunction<java.util.Set<String>> {
|
||||
this.valueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public StringSet(LongToIntFunction sizeFunc, LongUnaryOperator valueFunc) {
|
||||
this.sizeFunc = sizeFunc;
|
||||
this.valueFunc = valueFunc::applyAsLong;
|
||||
}
|
||||
|
||||
public StringSet(LongToIntFunction sizeFunc, LongToIntFunction valueFunc) {
|
||||
this.sizeFunc = sizeFunc;
|
||||
this.valueFunc = valueFunc::applyAsInt;
|
||||
}
|
||||
|
||||
@Override
|
||||
public java.util.Set<String> apply(long value) {
|
||||
int size = sizeFunc.applyAsInt(value);
|
||||
|
@ -2,6 +2,8 @@ package io.nosqlbench.virtdata.library.basics.shared.from_long.to_collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class SetTest {
|
||||
@ -15,7 +17,7 @@ public class SetTest {
|
||||
|
||||
@Test
|
||||
public void testStringSet() {
|
||||
StringSet set = new StringSet(s -> 3, e -> e);
|
||||
StringSet set = new StringSet(s -> 3, (LongToIntFunction) (e -> (int)e));
|
||||
java.util.Set<String> s1 = set.apply(15L);
|
||||
assertThat(s1).containsOnly("15","16","17");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user