mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-26 02:30:39 -06:00
improve function adapter coverage
This commit is contained in:
parent
fdeacc86f2
commit
7ee172651a
@ -712,6 +712,9 @@ public class AdaptFunctionsFlexibly {
|
||||
return v->(long) (f.applyAsLong(v));
|
||||
}
|
||||
|
||||
public static LongFunction<Object> adapt(Function<Object,Class> f, Object i1, Class i2, LongFunction i3, Object i4) {
|
||||
return f::apply;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -44,10 +44,10 @@ public class VirtDataConversions {
|
||||
|
||||
}
|
||||
|
||||
public static <F, T> List<T> adaptList(F[] funcs, Class<T> resultType, Class<Object>... resultSignature) {
|
||||
public static <F, T> List<T> adaptFunctionList(F[] funcs, Class<T> resultType, Class<Object>... resultSignature) {
|
||||
List<T> functions = new ArrayList<>();
|
||||
for (Object func : funcs) {
|
||||
T adapted = adapt(func, resultType, resultSignature);
|
||||
T adapted = adaptFunction(func, resultType, resultSignature);
|
||||
functions.add(adapted);
|
||||
}
|
||||
return functions;
|
||||
@ -62,7 +62,7 @@ public class VirtDataConversions {
|
||||
* @param resultSignature The signature of all output types, linearized for use after type-erasure.
|
||||
* @return An instance of T
|
||||
*/
|
||||
public static <F, T> T adapt(F func, Class<T> resultType, Class<?>... resultSignature) {
|
||||
public static <F, T> T adaptFunction(F func, Class<T> resultType, Class<?>... resultSignature) {
|
||||
FuncType funcType = FuncType.valueOf(func.getClass());
|
||||
|
||||
List<Class<?>> signature = new ArrayList<>();
|
||||
|
@ -89,40 +89,40 @@ public class VirtDataConversionsTest {
|
||||
@Test
|
||||
public void testFunctionConversions() {
|
||||
for (Object func : funcs) {
|
||||
LongUnaryOperator f1 = VirtDataConversions.adapt(func, LongUnaryOperator.class);
|
||||
LongUnaryOperator f1 = VirtDataConversions.adaptFunction(func, LongUnaryOperator.class);
|
||||
f1.applyAsLong(1);
|
||||
|
||||
LongToDoubleFunction f2 = VirtDataConversions.adapt(func, LongToDoubleFunction.class);
|
||||
LongToDoubleFunction f2 = VirtDataConversions.adaptFunction(func, LongToDoubleFunction.class);
|
||||
f2.applyAsDouble(2);
|
||||
|
||||
LongToIntFunction f3 = VirtDataConversions.adapt(func, LongToIntFunction.class);
|
||||
LongToIntFunction f3 = VirtDataConversions.adaptFunction(func, LongToIntFunction.class);
|
||||
f3.applyAsInt(3);
|
||||
|
||||
LongFunction<Double> f4 = VirtDataConversions.adapt(func, LongFunction.class, Double.class);
|
||||
LongFunction<Double> f4 = VirtDataConversions.adaptFunction(func, LongFunction.class, Double.class);
|
||||
f4.apply(4L);
|
||||
|
||||
LongFunction<Object> f41 = VirtDataConversions.adapt(func, LongFunction.class, Object.class);
|
||||
LongFunction<Object> f41 = VirtDataConversions.adaptFunction(func, LongFunction.class, Object.class);
|
||||
f41.apply(41L);
|
||||
|
||||
LongFunction<Integer> f5 = VirtDataConversions.adapt(func, LongFunction.class, Integer.class);
|
||||
LongFunction<Integer> f5 = VirtDataConversions.adaptFunction(func, LongFunction.class, Integer.class);
|
||||
f5.apply(5L);
|
||||
|
||||
IntUnaryOperator f6 = VirtDataConversions.adapt(func, IntUnaryOperator.class);
|
||||
IntUnaryOperator f6 = VirtDataConversions.adaptFunction(func, IntUnaryOperator.class);
|
||||
f6.applyAsInt(6);
|
||||
|
||||
IntFunction<Long> f7 = VirtDataConversions.adapt(func, IntFunction.class, Long.class);
|
||||
IntFunction<Long> f7 = VirtDataConversions.adaptFunction(func, IntFunction.class, Long.class);
|
||||
f7.apply(7);
|
||||
|
||||
IntFunction<Integer> f8 = VirtDataConversions.adapt(func,IntFunction.class, Integer.class);
|
||||
IntFunction<Integer> f8 = VirtDataConversions.adaptFunction(func,IntFunction.class, Integer.class);
|
||||
f8.apply(8);
|
||||
|
||||
IntFunction<Double> f9 = VirtDataConversions.adapt(func,IntFunction.class, Double.class);
|
||||
IntFunction<Double> f9 = VirtDataConversions.adaptFunction(func,IntFunction.class, Double.class);
|
||||
f9.apply(9);
|
||||
|
||||
DoubleUnaryOperator f10 = VirtDataConversions.adapt(func, DoubleUnaryOperator.class);
|
||||
DoubleUnaryOperator f10 = VirtDataConversions.adaptFunction(func, DoubleUnaryOperator.class);
|
||||
f10.applyAsDouble(10d);
|
||||
|
||||
LongFunction<Long> f11 = VirtDataConversions.adapt(func, LongFunction.class, Long.class);
|
||||
LongFunction<Long> f11 = VirtDataConversions.adaptFunction(func, LongFunction.class, Long.class);
|
||||
f11.apply(11L);
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user