mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Provide activity parameter default strict=true for driver adapters, which requires strict usage checking on op fields.
Unused op fields will cause an error by default.
This commit is contained in:
@@ -21,6 +21,7 @@ import com.google.gson.GsonBuilder;
|
||||
import io.nosqlbench.engine.api.util.Tagged;
|
||||
import io.nosqlbench.nb.api.config.params.Element;
|
||||
import io.nosqlbench.nb.api.config.params.NBParams;
|
||||
import io.nosqlbench.nb.api.errors.OpConfigError;
|
||||
import io.nosqlbench.virtdata.core.templates.ParsedTemplate;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
@@ -332,4 +333,26 @@ public abstract class OpTemplate implements Tagged {
|
||||
public Element getParamReader() {
|
||||
return NBParams.one(getName(),getParams());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the size of remaining fields from the op template and the params map.
|
||||
*/
|
||||
public int size() {
|
||||
return getOp().map(Map::size).orElse(0) + getParams().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the map of all remaining fields from the op template and the params map.
|
||||
*/
|
||||
public Map<String, Object> remainingFields() {
|
||||
Map<String,Object> remaining = new LinkedHashMap<>(getOp().orElse(Map.of()));
|
||||
remaining.putAll(getParams());
|
||||
return remaining;
|
||||
}
|
||||
|
||||
public void assertConsumed() {
|
||||
if (size()>0) {
|
||||
throw new OpConfigError("The op template named '" + getName() + "' was not fully consumed. These fields are not being applied:" + remainingFields());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ public abstract class BaseDriverAdapter<R extends Op,S> implements DriverAdapter
|
||||
public NBConfigModel getConfigModel() {
|
||||
return ConfigModel.of(BaseDriverAdapter.class)
|
||||
.add(Param.optional("alias"))
|
||||
.add(Param.defaultTo("strict",true,"strict op field mode, which requires that provided op fields are recognized and used"))
|
||||
.add(Param.optional(List.of("op", "stmt", "statement"), String.class, "op template in statement form"))
|
||||
.add(Param.optional(List.of("workload", "yaml"), String.class, "location of workload yaml file"))
|
||||
.add(Param.optional("tags", String.class, "tags to be used to filter operations"))
|
||||
|
||||
Reference in New Issue
Block a user