Class ParsedOp
- All Implemented Interfaces:
NBComponent,NBComponentAdvisors,NBComponentEvents,NBComponentMetrics,NBComponentProps,NBComponentServices,NBComponentTimeline,NBProviderSearch,NBTokenWords,DynamicFieldReader,StaticFieldReader,NBLabeledElement,AutoCloseable,LongFunction<Map<String,?>>
ParsedOp API
This is the primary developer-focused API for driver developers to use when up-converting op
templates
to operations. This ParsedOp is a wrapper around the op template structure. It provides
many
ways of constructing higher-order objects from a variety of sources.
Supporting Variety
For some drivers or protocols, the primary user interface is a statement format or grammar. For CQL or SQL, the most natural way of describing templates for operations is in that native format. For others, an operation template may look like a block of JSON or a HTTP request. All these forms are supported. In order to deal with the variety, there is a set of detailed rules for how the workload definitions are transformed into driver operations for a native driver. The high-level flow is:
- Op Template Form
- Normalized Data Structure
- ParsedOp Form
The specifications govern how the raw op template form is transformed into the normalized data structure. This documentation focuses on the API provided by the last form, this class, although peripheral awareness of the first two forms will certainly help for any advanced scenarios. You can find detailed examples and specification tests under the workload_definition folder of the adapters-api module.
Op Template Parsing
- Rule #1: All op templates are parsed into an internal normalized structure which contains:
- A map of op fields, which can consist of:
- static field values
- dynamic field values, the actual value of which can only be known for a given cycle
- Access to auxiliary configuration values like activity parameters. These can back-fill when values aren't present in the direct static or dynamic op fields.
- A map of op fields, which can consist of:
- Rule #2: When asking for a dynamic parameter, static parameters may be automatically promoted to functional form as a back-fill.
- Rule #3: When asking for static parameters, config parameters may automatically be promoted as a back-fill.
Distinguishing Op Payload from Op Config
When a user specifies an op template, they may choose to provide only a single set of op fields without distinguishing between config or payload, or they may choose to directly configure each.
ops:
# both op and params explicitly named
op1:
op:
opfield1: value1
params:
param2: value2
# neither op field nor params named, so all assumed to be op fields
op2:
opfield1: value1
param2: value2
# in this case, if param2 is meant to be config level,
# it is a likely config error that should be thrown to the user
# only op field explicitly named, so remainder automatically pushed into params
op3:
op:
opfield1: value1
param2: value2
# only params explicitly named, so remainder pushed into op payload
op4:
params:
param2: value2
opfield1: value1
All of these are considered valid constructions, and all of them may actually achieve the same result. This looks like an undesirable problem, but it serves to simplify things for users in one specific way: It allows them to be a vague, within guidelines, and still have a valid workload definition. The NoSQLBench runtime does a non-trivial amount of processing on the op template to ensure that it can conform to an unambiguous normalized internal structure on your behalf. This is needed because of how awful YAML is as a user configuration language in spite of its ubiquity in practice. The basic design guideline for these forms is that the op template must mean what a reasonable user would assume without looking at any documentation.
Design Invariants
The above rules imply invariants, which are made explicit here.
Single Purpose Fields
You may not use an op field name or parameter name for more than one purpose.
Shared Namespace
Treat all parameters supported by a driver adapter and it's op fields as a globally shared namespace, even if it is not.
This avoids creating any confusion about what a parameter can be used for and how to use it for the right thing in the right place. For example, you may not use the parameter name `socket` in an op template to mean one thing and then use it at the driver adapter level to mean something different. However, if the meaning is congruent, a driver developer may choose to support some cross-cutting parameters at the activity level. These allowances are explicit, however, as each driver dictates what it will allow as activity parameters.
Layered Resolution
Users may specify op payload fields within op params or activity params as fallback config sources in that order.
- IF a name is valid as an op field, it must also be valid as such when specified in op params.
- If a name is valid as an op field, it must also be valid as such when specified in activity
params, within the
scope of
ParsedOp - When an op field is found via op params or activity params, it may NOT be dynamic. If dynamic values are intended to be provided at a common layer in the workload, then bindings or template variables support this already.
Configuration Fields
You must access non-payload params via Config-oriented methods.- Op Templates contain op payload data and op configs (params, activity params).
- You must use only
ParsedOpgetters with "...Config..." names, such asgetConfigOr(String, Object, long)when accessing non-payload fields. - When a dynamic value is found via one of these calls, an error should be thrown, as configuration level data is not expected to be variant per-operation or cycle.
Sanity Checks
The user must be warned when a required or optional config value is missing from op params (or activity params), but a value of the same name is found in op payload fields. If rule #1 is followed, and names are unambiguous across the driver, then it is almost certainly a configuration error.
Precedence
The order of precedence for values is:
- op payload fields
- op param fields
- activity params (when enabled, see below)
Enabling Activity Params
If a user wants to allow an activity param as an default for an fields, they must publish the op field name in the configuration model for the activity. Otherwise it is an error to specify the value at the activity level.
Op Payload Forms
Field values can come from multiple sources. These forms and any of their combinations are supported.Static Op Fields
op:
field1: value1
field2:
map3:
key4: value4
map5:
key6: value6
field7: false
field8: 8.8
As shown, any literal value of any valid YAML type, including structured values like lists or maps are accepted as static op template values. A static value is any value which contains zero bind points at any level.
Dynamic Op Fields with Binding References
op:
field1: "{binding1}"
field2: "value is: {binding1}"
In this form, {binding1} is known as a binding reference, since the binding
function is defined
elsewhere under the given name. The first field "field1" is specified with no leading nor trailing
literals, and
is thus taken as a raw binding reference, meaning that it will not be converted to a
String. The second,
named "field2", is what is known as a string template, and is syntactical sugar for a more
complex binding
which concatenates static and dynamic parts together. In this form, object types produced by binding
functions are
converted to string form before concatenation.
Note that a raw {binding1} value (without quotes) would be NOT be a binding reference,
since YAML
is a superset of JSON. this means that {binding1} would be converted to a map or JSON object
type
with invalid contents. This is warned about when detected as a null valued map key, although it also
makes
null values invalid for ANY op template value.
Dynamic Op Fields with Binding Definitions
op:
field1: "{{NumberNameToString()}}"
field2: "value is: {{NumberNameToString()}}"
This form has exactly the same effect as the previous example as long as your bindings definitions included:
bindings:
binding1: NumberNameToString();
Dynamic Op Fields with Structure
op:
field1:
k1: "{binding1}
k2: "literal value"
field2:
- "value3"
- "{binding4}"
- "a value: {binding5}"
- "{{NumberNameToString}}"
- "a value: {{NumberNameToString()}}"
This example combines the previous ones with structure and dynamic values. Both field1 and field2
are dynamic,
since each contains some dynamic value or template within. When field1 is accessed within a cycle,
that cycle's
value
will be used as the seed to generate equivalent structures with all the literal and dynamic elements
inserted as
the template implies. As before, direct binding references like {binding4} will be inserted
into the
structure with whatever type the binding definition produces, so if you want strings in them, ensure
that you
configure your binding definitions thusly.
Op Template Params
params:
prepared: true
ops:
op1:
field1: value1
params:
prepared: false
The params section are the first layer of external configuration values that an op template can use
to distinguish
op configuration parameters from op payload content.
Op Template Params are referenced when any of the getConfigOr(String, Object, long) or
other
...Config...
getters are used (bypassing non-param fields). They are also accessed as a fallback when no static
nor dynamic value
is found
for a reference op template field. Unlike op fields, op params cascade from within the workload YAML
from the
document level,
down to each block and then down to each statement.
Activity Params
./nb run driver=... workload=... cl=LOCAL_QUORUM
When explicitly allowed by a driver adapter's configuration model, values like cl above
can be seen as
another fallback source for configuration parameters. The ParsedOp implementation will
automatically look
in the activity parameters if needed to find a missing configuration parameter, but this will only
work if
the specific named parameter is allowed at the activity level.
Alternate Names
Sometimes you may need to support more than one name for the same purpose. In such cases, there are helper methods which can be used to reduce from a set of possible field names to a single one.
requiredFieldOf(String...)andrequiredFieldOf(List)will find exactly one field within the set of possible fields. Zero or more than one will throw an error.optionalFieldOf(String...)andoptionalFieldOf(List)will find exactly zero or one field within the set of possible fields. More than one will throw an error.
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
NBLabeledElement.BasicLabeledElement -
Field Summary
Fields inherited from class io.nosqlbench.nb.api.components.core.NBBaseComponent
bufferOrphanedMetrics, closed_ns, error, errored_ns, metricsBuffer, parent, started_epoch_ms, started_ns, state, teardown_nsFields inherited from interface io.nosqlbench.nb.api.components.core.NBComponent
EMPTY_COMPONENTFields inherited from interface io.nosqlbench.nb.api.components.core.NBComponentProps
HDRDIGITS, SUMMARYFields inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
EMPTY -
Constructor Summary
ConstructorsConstructorDescriptionParsedOp(OpTemplate opTemplate, NBConfiguration activityCfg, List<Function<Map<String, Object>, Map<String, Object>>> preprocessors, NBComponent parent) Create a parsed command from an Op template. -
Method Summary
Modifier and TypeMethodDescriptionapply(long value) <FA,FE> LongFunction <FA> enhanceDefaultFunc(LongFunction<FA> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith another required named field or function combiner OR a default value.<S extends FA,FA, FE extends Enum<FE>>
LongFunction<S> enhanceEnumOptionally(LongFunction<S> func, String field, Class<FE> type, BiFunction<S, FE, S> combiner) Enhance aFunctionwith an optional enum function IFF it is defined.<FA,FE> LongFunction <FA> enhanceFunc(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith a named required function, or throw an error.<FA,FE> LongFunction <FA> enhanceFuncOptionally(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith a named optional function IFF it exists.<FA,FE, FF>
LongFunction<FA> enhanceFuncOptionally2(LongFunction<FA> func, String field, Class<FE> type, String field2, Class<FF> type2, TriFunction<FA, FE, FF> triCombiner) <FA,FE, FR>
LongFunction<FR> enhanceFuncPivot(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FR> combiner) <FA,FE> Optional <LongFunction<FA>> enhanceOptionalDefaultFunc(Optional<LongFunction<FA>> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) <FA,FE> Optional <LongFunction<FA>> enhanceOptionalFuncOptionally(Optional<LongFunction<FA>> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) <T> TGet the named field value for a given long input.<V> LongFunction<V> getAsCachedFunctionOr(String fieldname, String defaultValue, Function<String, V> init) Get a LongFunction that first creates a LongFunction of String as ingetAsRequiredFunction(String, Class), but then applies the result and caches it for subsequent access.<V> LongFunction<V> getAsFunctionOr(String name, V defaultValue) Get a LongFunction which returns either the static value, the dynamic value, or the default value, in that order, depending on where it is found first.<V extends Enum<V>>
Optional<LongFunction<V>> getAsOptionalEnumFunction(String name, Class<? extends V> type) <V> Optional<LongFunction<String>> getAsOptionalFunction(String name) <V> Optional<LongFunction<V>> getAsOptionalFunction(String name, Class<V> type) Get the op field as aLongFunctiongetAsRequiredFunction(String name) Get the op field as aLongFunctionof String.<V> LongFunction<V> getAsRequiredFunction(String name, Class<? extends V> type) getAsSubOp(String name, ParsedOp.SubOpNaming naming) getAsSubOps(String fromOpField, ParsedOp.SubOpNaming naming) getAsTemplate(String fieldname) <T> TgetConfigOr(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.<E extends Enum<E>>
EgetEnumFromFieldOr(Class<E> enumClass, E defaultEnum, String fieldName) LongFunction<?> Get theLongFunctionwhich is used to resolve a dynamic field value.getName()getOptionalEnumFromField(Class<E> enumclass, String fieldName) <T> Optional<T> getOptionalStaticConfig(String name, Class<T> type) <T> Optional<T> getOptionalStaticValue(String field, Class<T> classOfT) Return an optional value for the named field.<E extends Enum<E>,V>
Optional<TypeAndTarget<E, V>> getOptionalTypeAndTargetEnum(Class<E> enumclass, Class<V> valueClass) <E extends Enum<E>,V>
Optional<TypeAndTarget<E, V>> getOptionalTypeAndTargetEnum(Class<E> enumclass, Class<V> valueClass, String alternateTypeField, String alternateValueField) intintgetSize()getStaticConfig(String name, Class<String> clazz) <T> TgetStaticConfigOr(String name, T defaultValue) Get the specified parameter by the user using the defined field which is closest to the op template.<T> TgetStaticValue(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(String field, Class<T> classOfT) Get the static value for the provided name, cast to the required type.<T> TgetStaticValueOr(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.<E extends Enum<E>,V>
TypeAndTarget<E, V> getTypeAndTarget(Class<E> enumclass, Class<V> valueClass) <E extends Enum<E>,V>
TypeAndTarget<E, V> getTypeAndTarget(Class<E> enumclass, Class<V> valueclass, String tname, String vname) <E extends Enum<E>,V>
Optional<TypeAndTarget<E, V>> getTypeAndTargetFromEnum(Class<E> enumclass, Class<V> valueClass) Given an enum of any type, return the enum value which is found in any of the field names of the op template, ignoring case and any non-word characters.Class<?> getValueType(String fieldname) booleanbooleanbooleanbooleanisDefinedAll(String... fields) convenience method for conjugatingisDefined(String)with ANDbooleanisDefinedExactly(String... fields) booleanbooleanbooleanbooleanisUndefined(String field) Inverse ofisDefined(String), provided for clarify in some situationsnewArrayBinder(String... fields) newArrayBinder(List<String> fields) newArrayBinderFromBindPoints(List<BindPoint> bindPoints) newListBinder(String... fields) newListBinder(List<String> fields) newOrderedMapBinder(String... fields) optionalFieldOf(String... fields) optionalFieldOf(List<String> fields) parseStaticCmdMap(String key, String mainField) parseStaticCmdMaps(String key, String mainField) requiredFieldOf(String... fields) requiredFieldOf(List<String> fields) takeAsOptionalStringTemplate(String fieldname) <E extends Enum<E>>
EtakeEnumFromFieldOr(Class<E> enumClass, E defaultEnum, String fieldName) <T> Optional<T> takeOptionalStaticValue(String field, Class<T> classOfT) <T> TtakeStaticConfigOr(String name, T defaultValue) Get the parameter value from a static op template field OR any of the provided optional sources of op template values, including the activity parameterstoString()Methods inherited from class io.nosqlbench.nb.api.components.core.NBBaseComponent
addAdvisor, addMetricsCloseable, attachChild, beforeDetach, close, create, detachChild, find, findParentService, getAdvisors, getChildren, getComponentOnlyLabels, getComponentProp, getComponentState, getLabels, getNanosSinceStart, getParent, getTokens, nanosof_close, nanosof_error, nanosof_start, nanosof_teardown, onError, onEvent, reportExecutionMetric, setComponentProp, started_epoch_ms, teardownMethods inherited from class io.nosqlbench.nb.api.components.core.NBBaseComponentMetrics
addComponentMetric, addListener, findComponentMetrics, findComponentMetrics, getComponentMetric, getComponentMetrics, removeListenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponent
attachChild, beforeDetach, close, detachChild, getChildren, getComponentOnlyLabels, getNanosSinceStart, getParent, reportExecutionMetricMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponentAdvisors
addAdvisor, getAdvisorResults, getAdvisorsMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponentEvents
onEventMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponentMetrics
addComponentMetric, findComponentMetrics, findComponentMetrics, findOneComponentMetric, findOneComponentMetric, getComponentMetric, getComponentMetricsMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponentProps
getComponentProp, setComponentPropMethods inherited from interface io.nosqlbench.nb.api.components.core.NBComponentServices
create, findMethods inherited from interface io.nosqlbench.nb.api.labels.NBLabeledElement
description, getLabelsMethods inherited from interface io.nosqlbench.nb.api.components.decorators.NBProviderSearch
findParentService
-
Constructor Details
-
ParsedOp
public ParsedOp(OpTemplate opTemplate, NBConfiguration activityCfg, List<Function<Map<String, Object>, Map<String, Object>>> preprocessors, NBComponent parent) Create a parsed command from an Op template. This version is exactly like 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
-
getTemplateMap
-
apply
-
isDynamic
- Specified by:
isDynamicin interfaceDynamicFieldReader
-
isStatic
- 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
-
isDefined
- Specified by:
isDefinedin interfaceStaticFieldReader- 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
Get the static value for the provided name, cast to the required type.- Specified by:
getStaticValuein interfaceStaticFieldReader- 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
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 interfaceStaticFieldReader- 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
-
getAsTemplate
-
takeAsOptionalStringTemplate
-
getStaticValueOr
Get the named static field value, or return the provided default, but throw an exception if the named field is dynamic.- Specified by:
getStaticValueOrin interfaceStaticFieldReader- 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:
RuntimeException- if the field name is only present in the dynamic fields.
-
getStaticConfigOr
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:
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.
-
takeStaticConfigOr
Get the parameter value from a static op template field OR any of the provided optional sources of op template values, including the activity parameters- Type Parameters:
T- The type of the field- Parameters:
name- The config field namedefaultValue- The default value, if the field is not defined in the op template nor the activity params- Returns:
- The config value.
-
getStaticConfig
-
getOptionalStaticConfig
-
getConfigOr
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. -
getOptionalStaticValue
Return an optional value for the named field. This is anOptionalform ofgetStaticValue(java.lang.String, java.lang.Class<T>).- Specified by:
getOptionalStaticValuein interfaceStaticFieldReader- 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.
-
takeOptionalStaticValue
-
get
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 interfaceDynamicFieldReader- 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
-
getAsRequiredFunction
Get the op field as aLongFunctionof String. This is a convenience form forgetAsRequiredFunction(String, Class)- Parameters:
name- The field name which must be defined as static or dynamic- Returns:
- A function which can provide the named field value
-
getAsOptionalFunction
Get the op field as aLongFunction- Parameters:
name- The field name which must be defined as static or dynamictype- The value type which the field must be assignable to- Returns:
- A function which can provide a value for the given name and type
-
getAsOptionalEnumFunction
public <V extends Enum<V>> Optional<LongFunction<V>> getAsOptionalEnumFunction(String name, Class<? extends V> type) -
getAsOptionalFunction
-
getAsRequiredFunction
-
getAsFunctionOr
Get a LongFunction which returns either the static value, the dynamic value, or the default value, in that order, depending on where it is found first.- Specified by:
getAsFunctionOrin interfaceDynamicFieldReader- Type Parameters:
V- The type of value to return- Parameters:
name- The param name for the valuedefaultValue- The default value to provide the value is not defined for static nor dynamic- Returns:
- A
LongFunctionof type V
-
getAsCachedFunctionOr
public <V> LongFunction<V> getAsCachedFunctionOr(String fieldname, String defaultValue, Function<String, V> init) Get a LongFunction that first creates a LongFunction of String as ingetAsRequiredFunction(String, Class), but then applies the result and caches it for subsequent access. This relies onObjectCacheinternally.- Type Parameters:
V- The type of object to return- Parameters:
fieldname- The name of the field which could contain a static or dynamic valuedefaultValue- The default value to use in the init function if the fieldname is not defined as static nor dynamicinit- A function to apply to the value to produce the product type- Returns:
- A caching function which chains to the init function, with caching
-
isDefined
- Specified by:
isDefinedin interfaceStaticFieldReader- Parameters:
field- The requested field name- Returns:
- true if the named field is defined as static or dynamic
-
isUndefined
Inverse ofisDefined(String), provided for clarify in some situations- Parameters:
field- The field name- Returns:
- true if the named field is defined neither as static nor as dynamic
-
isDefined
- Specified by:
isDefinedin interfaceStaticFieldReader- Parameters:
field- The requested field nametype- The required type of the field value- Returns:
- true if the named field is defined as static or dynamic and the value produced can be assigned to the specified type
-
isDefinedAll
convenience method for conjugatingisDefined(String)with AND- Parameters:
fields- The fields which should be defined as either static or dynamic- Returns:
- true if all specified fields are defined as static or dynamic
-
newListBinder
- Parameters:
fields- The ordered field names for which theListBinderwill be created- Returns:
- a new
ListBinderwhich can produce aListof Objects from a long input.
-
newListBinder
- Parameters:
fields- The ordered field names for which theListBinderwill be created- Returns:
- a new
ListBinderwhich can produce aListof Objects from a long input.
-
newOrderedMapBinder
- Parameters:
fields- The ordered field names for which theOrderedMapBinderwill be created- Returns:
- a new
OrderedMapBinderwhich can produce aMapof String to Objects from a long input.
-
newArrayBinder
- Parameters:
fields- The ordered field names for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
newArrayBinder
- Parameters:
fields- The ordered field names for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
newArrayBinderFromBindPoints
- Parameters:
bindPoints- TheBindPoints for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
getMapper
Get theLongFunctionwhich is used to resolve a dynamic field value.- Parameters:
field- The field name for a dynamic parameter- Returns:
- The mapping function
-
getSize
public int getSize()- Returns:
- the logical map size, including all static and dynamic fields
-
getValueType
-
getTypeAndTargetFromEnum
public <E extends Enum<E>,V> Optional<TypeAndTarget<E,V>> getTypeAndTargetFromEnum(Class<E> enumclass, Class<V> valueClass) Given an enum of any type, return the enum value which is found in any of the field names of the op template, ignoring case and any non-word characters. This is useful for matching op templates to op types where the presence of a field determines the type. Further, if there are multiple matching names, anOpConfigErroris thrown to avoid possible ambiguity.- Type Parameters:
E- Generic type for the enum class- Parameters:
enumclass- The enum class for matching values- Returns:
- Optionally, an enum value which matches, or
Optional.empty() - Throws:
OpConfigError- if more than one field matches
-
getOptionalTypeAndTargetEnum
public <E extends Enum<E>,V> Optional<TypeAndTarget<E,V>> getOptionalTypeAndTargetEnum(Class<E> enumclass, Class<V> valueClass) -
getOptionalTypeAndTargetEnum
-
getTypeAndTarget
public <E extends Enum<E>,V> TypeAndTarget<E,V> getTypeAndTarget(Class<E> enumclass, Class<V> valueClass) -
getTypeAndTarget
-
getOptionalEnumFromField
-
getEnumFromFieldOr
-
takeEnumFromFieldOr
-
enhanceDefaultFunc
public <FA,FE> LongFunction<FA> enhanceDefaultFunc(LongFunction<FA> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith another required named field or function combiner OR a default value.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuedefaultFe- The default value of the field, if none is providedcombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- an enhanced function
-
enhanceFunc
public <FA,FE> LongFunction<FA> enhanceFunc(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith a named required function, or throw an error.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- a version of the base function, optionally enhanced
-
enhanceFuncOptionally
public <FA,FE> LongFunction<FA> enhanceFuncOptionally(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith a named optional function IFF it exists.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- a version of the base function, optionally enhanced
-
getRefKey
public int getRefKey() -
getAsSubOps
-
getAsSubOp
-
enhanceOptionalFuncOptionally
public <FA,FE> Optional<LongFunction<FA>> enhanceOptionalFuncOptionally(Optional<LongFunction<FA>> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance an
OptionalFunctionwith an optional named field or value combiner, IFF both functions are defined.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- the enhanced optional function
-
enhanceOptionalDefaultFunc
public <FA,FE> Optional<LongFunction<FA>> enhanceOptionalDefaultFunc(Optional<LongFunction<FA>> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance an
OptionalFunctionwith a named field or function combiner OR a default value, IFF the base function is present.Create a required function for the specified field and default value, IFF the main function is present. The base type of the function remains the same, and if present, will be extended with the required field value or function in the provided combiner.
- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuedefaultFe- The default value of the field, if none is providedcombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- the enhanced optional base function
-
enhanceEnumOptionally
public <S extends FA,FA, LongFunction<S> enhanceEnumOptionallyFE extends Enum<FE>> (LongFunction<S> func, String field, Class<FE> type, BiFunction<S, FE, S> combiner) Enhance a
Functionwith an optional enum function IFF it is defined.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- an (optionally) enhanced base function
-
parseStaticCmdMap
-
parseStaticCmdMaps
-
toString
- Overrides:
toStringin classNBBaseComponent
-
getCaptures
-
getBindPoints
-
isDefinedExactly
-
enhanceFuncOptionally2
public <FA,FE, LongFunction<FA> enhanceFuncOptionally2FF> (LongFunction<FA> func, String field, Class<FE> type, String field2, Class<FF> type2, TriFunction<FA, FE, FF> triCombiner) -
enhanceFuncPivot
public <FA,FE, LongFunction<FR> enhanceFuncPivotFR> (LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FR> combiner) -
optionalFieldOf
-
optionalFieldOf
-
requiredFieldOf
-
requiredFieldOf
-