com.datastax.ebdrivers.dsegraph.statements.ReadyGraphStatementTemplate Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of driver-dsegraph-shaded Show documentation
Show all versions of driver-dsegraph-shaded Show documentation
A DSE Graph ActivityType driver for nosqlbench, based on http://nosqlbench.io/
package com.datastax.ebdrivers.dsegraph.statements;
import com.datastax.driver.dse.graph.SimpleGraphStatement;
import io.nosqlbench.virtdata.core.bindings.Bindings;
import io.nosqlbench.virtdata.core.bindings.BindingsTemplate;
import io.nosqlbench.virtdata.core.bindings.ContextualBindingsTemplate;
import io.nosqlbench.virtdata.core.bindings.ValuesBinder;
import io.nosqlbench.virtdata.core.templates.BindPoint;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ReadyGraphStatementTemplate {
private final ContextualBindingsTemplate contextualBindingsTemplate;
private final String name;
private String[] fields;
public ReadyGraphStatementTemplate(String name, String stmtTemplate, List bindPoints, String[] fields) {
this.name = name;
SimpleGraphStatement simpleGraphStatement = new SimpleGraphStatement(stmtTemplate);
BindingsTemplate bindingsTemplate = new BindingsTemplate(bindPoints);
contextualBindingsTemplate = new ContextualBindingsTemplate<>(
simpleGraphStatement, bindingsTemplate,
new ParameterizedGraphStatementValuesBinder(fields)
);
}
public ReadyGraphStatementTemplate(String name, String stmtTemplate, List bindPoints, String[] fields, int repeat) {
this.name = name;
SimpleGraphStatement simpleGraphStatement = new SimpleGraphStatement(stmtTemplate);
BindingsTemplate bindingsTemplate = new BindingsTemplate(bindPoints);
contextualBindingsTemplate = new ContextualBindingsTemplate<>(simpleGraphStatement, bindingsTemplate, new ParameterizedIteratedGraphStatementValuesBinder(fields, repeat));
}
public static class ParameterizedIteratedGraphStatementValuesBinder implements ValuesBinder {
private final String[] fields;
private final int repeat;
public ParameterizedIteratedGraphStatementValuesBinder(String[] fields, int repeat) {
this.fields = fields;
this.repeat = repeat;
}
@Override
public SimpleGraphStatement bindValues(SimpleGraphStatement context, Bindings bindings, long cycle) {
Map iteratedSuffixMap = bindings.getIteratedSuffixMap(cycle, repeat, fields);
return new SimpleGraphStatement(context.getQueryString(), iteratedSuffixMap);
}
}
public static class ParameterizedGraphStatementValuesBinder
implements ValuesBinder {
private final String[] fields;
private final Map valuesMap = new HashMap();
private final ThreadLocal
© 2015 - 2025 Weber Informatics LLC | Privacy Policy