Class NBFunctionConverter

java.lang.Object
io.nosqlbench.virtdata.api.bindings.NBFunctionConverter

public class NBFunctionConverter extends Object

Synopsis

Static methods on this class are intended to adapt one java Functional type to another. The fill-in logic which bridges functions in this class are intended to be flexible, but this means that strict data type handling will be secondary to having functions that will return a value even when an overflow would normally occur.

Handling Overflow

In any case where an overflow error would occur, or a loss of numeric precision due to a narrowing conversion, the value which is too large for the smaller register is reduced in magnitude to fit into the smaller data type using modulo division by the maximum positive value of the smaller type.

This is suitable for testing cases where you need voluminous data according to a sketch or recipe, but it is not appropriate for use in rigorous mathematical or algebraic scenarios. Use these methods appropriately, i.e. for generating bulk test data only.

Method Naming

The method naming used in this class follows a pattern to make reflective lookup easy and type aware. However, the second and subsequent parameters are not used in the call to the function. They will be null. This allows for explicit method matching, including with respect to variant types within generic parameters in target types. Thus, target types with one generic parameter will have a signature like (func, targetclass, generic0) while those with two generic parameters will have a signature like (func, targetclass, generic0, generic1). What matters is that the return type is accurate and type compatible with the actual function that is returned.

Alternative methods were explored, but this method works well and is actually easier to follow than most other methods considered.

To ensure coverage of function types, add to the VirtDataConversionsTest class.