io.nosqlbench.virtdata.core.bindings.ContextualArrayBindings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-cql-shaded Show documentation
Show all versions of driver-cql-shaded Show documentation
A Shaded CQL ActivityType driver for http://nosqlbench.io/
package io.nosqlbench.virtdata.core.bindings;
/**
* A thread-local template that describes a set of data mappers, a context object,
* and a method for applying mapped values to the context object via an object array.
* This type is used in thread-local scope to map thread-specific
* data mapper instances to a contextual template object and a method for
* applying mapped values to it.
*
* This type is generally constructed by a ContextualBindingsTemplate.
*
* @param The type of the contextual template object.
* @param The resulting type from binding mapped values with the contextual template C
*/
public class ContextualArrayBindings implements Binder {
private final C context;
private final Bindings bindings;
private final ValuesArrayBinder valuesArrayBinder;
public ContextualArrayBindings(Bindings bindings, C context, ValuesArrayBinder valuesArrayBinder) {
this.bindings = bindings;
this.context = context;
this.valuesArrayBinder = valuesArrayBinder;
}
public Bindings getBindings() {
return bindings;
}
public C getContext() {
return context;
}
@Override
public R bind(long value) {
Object[] allGeneratedValues = bindings.getAll(value);
try { // Provide bindings context data where it may be useful
return valuesArrayBinder.bindValues(context, allGeneratedValues);
} catch (Exception e) {
throw new RuntimeException("Binding error:" + bindings.getTemplate().toString(allGeneratedValues), e);
}
}
public String toString() {
return "context: '" + this.context.toString() + "' bindings:'" + this.bindings.toString() + "'";
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy