mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
allow OpTemplate to convert string to int for ratio fixup
This commit is contained in:
@@ -21,6 +21,7 @@ import com.google.gson.GsonBuilder;
|
|||||||
import io.nosqlbench.engine.api.util.Tagged;
|
import io.nosqlbench.engine.api.util.Tagged;
|
||||||
import io.nosqlbench.nb.api.config.params.Element;
|
import io.nosqlbench.nb.api.config.params.Element;
|
||||||
import io.nosqlbench.nb.api.config.params.NBParams;
|
import io.nosqlbench.nb.api.config.params.NBParams;
|
||||||
|
import io.nosqlbench.nb.api.config.standard.NBTypeConverter;
|
||||||
import io.nosqlbench.nb.api.errors.OpConfigError;
|
import io.nosqlbench.nb.api.errors.OpConfigError;
|
||||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplate;
|
import io.nosqlbench.virtdata.core.templates.ParsedTemplate;
|
||||||
|
|
||||||
@@ -204,11 +205,12 @@ public abstract class OpTemplate implements Tagged {
|
|||||||
|
|
||||||
Object value = getParams().remove(name);
|
Object value = getParams().remove(name);
|
||||||
|
|
||||||
try {
|
if (defaultValue.getClass().isAssignableFrom(value.getClass())) {
|
||||||
return (V) defaultValue.getClass().cast(value);
|
return (V) value;
|
||||||
} catch (Exception e) {
|
} else {
|
||||||
throw new RuntimeException("Unable to cast type " + value.getClass().getCanonicalName() + " to " + defaultValue.getClass().getCanonicalName(), e);
|
return NBTypeConverter.convertOr(value,defaultValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
Reference in New Issue
Block a user