Class ParsedOp
java.lang.Object
io.nosqlbench.engine.api.templating.ParsedOp
- All Implemented Interfaces:
io.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader,io.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader,java.util.function.LongFunction<java.util.Map<java.lang.String,?>>
public class ParsedOp
extends java.lang.Object
implements java.util.function.LongFunction<java.util.Map<java.lang.String,?>>, io.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader, io.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader
Parse an OpTemplate into a ParsedOp, which can dispense object maps
-
Constructor Summary
Constructors Constructor Description ParsedOp(OpTemplate ot, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg)Create a parsed command from an Op template.ParsedOp(OpTemplate opTemplate, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg, java.util.List<java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>>> preprocessors)Create a parsed command from an Op template. -
Method Summary
Modifier and Type Method Description java.util.Map<java.lang.String,java.lang.Object>apply(long value)voidassertDefinedStatic(java.lang.String... fields)<T> Tget(java.lang.String field, long input)Get the named field value for a given long input.<V> java.util.function.LongFunction<V>getAsCachedFunctionOr(java.lang.String fieldname, java.lang.String defaultValue, java.util.function.Function<java.lang.String,V> init)<V> java.util.function.LongFunction<V>getAsFunction(java.lang.String name, java.lang.Class<? extends V> type)<V> java.util.function.LongFunction<V>getAsFunctionOr(java.lang.String name, V defaultValue)<T> TgetConfigOr(java.lang.String name, T defaultValue, long input)Works exactly likegetStaticConfigOr(String, Object), except that dynamic values at the op field level will be generated on a per-input basis.java.util.Set<java.lang.String>getDefinedNames()java.util.Map<java.lang.String,java.util.function.LongFunction<?>>getDynamicPrototype()java.util.function.LongFunction<?>getMapper(java.lang.String field)java.lang.StringgetName()<T> java.util.Optional<T>getOptionalStaticConfig(java.lang.String name, java.lang.Class<T> type)<T> java.util.Optional<T>getOptionalValue(java.lang.String field, java.lang.Class<T> classOfT)Return an optional value for the named field.intgetSize()<T> TgetStaticConfigOr(java.lang.String name, T defaultValue)Get the specified parameter by the user using the defined field which is closest to the op template.java.util.Map<java.lang.String,java.lang.Object>getStaticPrototype()<T> TgetStaticValue(java.lang.String field)Get the static value for the provided name, cast to the required type, where the type is inferred from the calling context.<T> TgetStaticValue(java.lang.String field, java.lang.Class<T> classOfT)Get the static value for the provided name, cast to the required type.<T> java.util.Optional<T>getStaticValueOptionally(java.lang.String field)<T> TgetStaticValueOr(java.lang.String name, T defaultValue)Get the named static field value, or return the provided default, but throw an exception if the named field is dynamic.java.util.Optional<io.nosqlbench.virtdata.core.templates.ParsedTemplate>getStmtAsTemplate()booleanisDefined(java.lang.String field)booleanisDefined(java.lang.String... fields)booleanisDefined(java.lang.String field, java.lang.Class<?> type)booleanisDefinedAll(java.lang.String... fields)booleanisDefinedDynamic(java.lang.String field)booleanisStatic(java.lang.String field)booleanisStatic(java.lang.String field, java.lang.Class<?> type)booleanisUndefined(java.lang.String field)java.util.function.LongFunction<java.lang.Object[]>newArrayBinder(java.lang.String... fields)java.util.function.LongFunction<java.lang.Object[]>newArrayBinder(java.util.List<java.lang.String> fields)java.util.function.LongFunction<java.lang.Object[]>newArrayBinderFromBindPoints(java.util.List<io.nosqlbench.virtdata.core.templates.BindPoint> bindPoints)java.util.function.LongFunction<java.util.List<java.lang.Object>>newListBinder(java.lang.String... fields)java.util.function.LongFunction<java.util.List<java.lang.Object>>newListBinder(java.util.List<java.lang.String> fields)java.util.function.LongFunction<java.util.Map<java.lang.String,java.lang.Object>>newOrderedMapBinder(java.lang.String... fields)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
ParsedOp
Create a parsed command from an Op template.- Parameters:
ot- An OpTemplate representing an operation to be performed in a native driver.activityCfg- The activity configuration, used for reading config parameters
-
ParsedOp
public ParsedOp(OpTemplate opTemplate, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg, java.util.List<java.util.function.Function<java.util.Map<java.lang.String,java.lang.Object>,java.util.Map<java.lang.String,java.lang.Object>>> preprocessors)Create a parsed command from an Op template. This version is exactly like(OpTemplate,NBConfiguration)except that it allows preprocessors. Preprocessors are all applied to the the op template before it is applied to the parsed command fields, allowing you to combine or destructure fields from more tha one representation into a single canonical representation for processing.- Parameters:
opTemplate- The OpTemplate as provided by a user via YAML, JSON, or API (data structure)activityCfg- The activity configuration, used to resolve nested config parameterspreprocessors- Map->Map transformers.
-
-
Method Details
-
getName
public java.lang.String getName() -
getStaticPrototype
public java.util.Map<java.lang.String,java.lang.Object> getStaticPrototype() -
getDynamicPrototype
public java.util.Map<java.lang.String,java.util.function.LongFunction<?>> getDynamicPrototype() -
apply
public java.util.Map<java.lang.String,java.lang.Object> apply(long value)- Specified by:
applyin interfacejava.util.function.LongFunction<java.util.Map<java.lang.String,?>>
-
isDefinedDynamic
public boolean isDefinedDynamic(java.lang.String field)- Specified by:
isDefinedDynamicin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader
-
isStatic
public boolean isStatic(java.lang.String field)- Parameters:
field- The field name to look for in the static field map.- Returns:
- true if and only if the named field is present in the static field map.
-
isStatic
public boolean isStatic(java.lang.String field, java.lang.Class<?> type) -
isDefined
public boolean isDefined(java.lang.String... fields)- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Parameters:
fields- Names of fields to look for in the static field map.- Returns:
- true if and only if all provided field names are present in the static field map.
-
getStaticValue
public <T> T getStaticValue(java.lang.String field, java.lang.Class<T> classOfT)Get the static value for the provided name, cast to the required type.- Specified by:
getStaticValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return type, used at compile time only to qualify asserted return type- Parameters:
field- Name of the field to getclassOfT- The type of the field to return. If actual type is not compatible to a cast to this type, then a casting error will be thrown.- Returns:
- A value of type T, or null
-
getStaticValue
public <T> T getStaticValue(java.lang.String field)Get the static value for the provided name, cast to the required type, where the type is inferred from the calling context.- Specified by:
getStaticValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return type. used at compile time only to quality return type.- Parameters:
field- Name of the field to get- Returns:
- A value of type T, or null
-
getStmtAsTemplate
public java.util.Optional<io.nosqlbench.virtdata.core.templates.ParsedTemplate> getStmtAsTemplate() -
getStaticValueOr
public <T> T getStaticValueOr(java.lang.String name, T defaultValue)Get the named static field value, or return the provided default, but throw an exception if the named field is dynamic.- Specified by:
getStaticValueOrin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The type of the field to return.- Parameters:
name- The name of the field value to return.defaultValue- A value to return if the named value is not present in static nor dynamic fields.- Returns:
- The value
- Throws:
java.lang.RuntimeException- if the field name is only present in the dynamic fields.
-
getStaticConfigOr
public <T> T getStaticConfigOr(java.lang.String name, T defaultValue)Get the specified parameter by the user using the defined field which is closest to the op template. This is the standard way of getting parameter values which can be specified at the op template, op param, or activity level.- Type Parameters:
T- The type of the value to return- Parameters:
name- The name of the configuration paramdefaultValue- the default value to return if the value is not defined anywhere in (op fields, op params, activity params)- Returns:
- A configuration value
- Throws:
io.nosqlbench.nb.api.config.standard.NBConfigError- if the named field is defined dynamically, as in this case, it is presumed that the parameter is not supported unless it is defined statically.
-
getOptionalStaticConfig
public <T> java.util.Optional<T> getOptionalStaticConfig(java.lang.String name, java.lang.Class<T> type) -
getConfigOr
public <T> T getConfigOr(java.lang.String name, T defaultValue, long input)Works exactly likegetStaticConfigOr(String, Object), except that dynamic values at the op field level will be generated on a per-input basis. This is a shortcut method for allowing configuration values to be accessed dynamically where it makes sense. -
getOptionalValue
public <T> java.util.Optional<T> getOptionalValue(java.lang.String field, java.lang.Class<T> classOfT)Return an optional value for the named field. This is anOptionalform ofgetStaticValue(java.lang.String, java.lang.Class<T>).- Specified by:
getOptionalValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return- Parameters:
field- Name of the field to getclassOfT- The type of field to return. If the actual type is not compatible to a cast to this type, then a casting error will be thrown.- Returns:
- An optional value, empty unless the named value is defined in the static field map.
-
getStaticValueOptionally
public <T> java.util.Optional<T> getStaticValueOptionally(java.lang.String field) -
get
public <T> T get(java.lang.String field, long input)Get the named field value for a given long input. This uses parameter type inference -- The casting to the return type will be based on the type of any assignment or casting on the caller's side. Thus, if the actual type is not compatable to a cast to the needed return type, a casting error will be thrown.- Specified by:
getin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader- Type Parameters:
T- The parameter type of the returned value. Inferred from usage context.- Parameters:
field- The name of the field to get.input- The seed value, or cycle value for which to generate the value.- Returns:
- The value.
-
getDefinedNames
public java.util.Set<java.lang.String> getDefinedNames() -
getAsFunction
public <V> java.util.function.LongFunction<V> getAsFunction(java.lang.String name, java.lang.Class<? extends V> type) -
getAsFunctionOr
public <V> java.util.function.LongFunction<V> getAsFunctionOr(java.lang.String name, V defaultValue)- Specified by:
getAsFunctionOrin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader
-
getAsCachedFunctionOr
public <V> java.util.function.LongFunction<V> getAsCachedFunctionOr(java.lang.String fieldname, java.lang.String defaultValue, java.util.function.Function<java.lang.String,V> init) -
isDefined
public boolean isDefined(java.lang.String field)- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader
-
isDefined
public boolean isDefined(java.lang.String field, java.lang.Class<?> type)- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader
-
isDefinedAll
public boolean isDefinedAll(java.lang.String... fields) -
assertDefinedStatic
public void assertDefinedStatic(java.lang.String... fields)- Specified by:
assertDefinedStaticin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader
-
newListBinder
public java.util.function.LongFunction<java.util.List<java.lang.Object>> newListBinder(java.lang.String... fields) -
newListBinder
public java.util.function.LongFunction<java.util.List<java.lang.Object>> newListBinder(java.util.List<java.lang.String> fields) -
newOrderedMapBinder
public java.util.function.LongFunction<java.util.Map<java.lang.String,java.lang.Object>> newOrderedMapBinder(java.lang.String... fields) -
newArrayBinder
public java.util.function.LongFunction<java.lang.Object[]> newArrayBinder(java.lang.String... fields) -
newArrayBinder
public java.util.function.LongFunction<java.lang.Object[]> newArrayBinder(java.util.List<java.lang.String> fields) -
newArrayBinderFromBindPoints
public java.util.function.LongFunction<java.lang.Object[]> newArrayBinderFromBindPoints(java.util.List<io.nosqlbench.virtdata.core.templates.BindPoint> bindPoints) -
getMapper
public java.util.function.LongFunction<?> getMapper(java.lang.String field) -
getSize
public int getSize() -
isUndefined
public boolean isUndefined(java.lang.String field)
-