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:
Jonathan Shook
2022-05-23 17:08:30 -05:00
parent 0edd8b99be
commit 0164c49f97
9 changed files with 50 additions and 17 deletions

View File

@@ -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());
}
}
}

View File

@@ -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"))