use of org.apache.cassandra.stress.operations.userdefined.CASQuery in project cassandra by apache.
the class StressProfile method getQuery.
public Operation getQuery(String name, Timer timer, PartitionGenerator generator, SeedManager seeds, StressSettings settings, boolean isWarmup) {
name = name.toLowerCase();
if (!queries.containsKey(name))
throw new IllegalArgumentException("No query defined with name " + name);
if (queryStatements == null) {
synchronized (this) {
if (queryStatements == null) {
JavaDriverClient jclient = settings.getJavaDriverClient(keyspaceName);
Map<String, PreparedStatement> stmts = new HashMap<>();
Map<String, SchemaStatement.ArgSelect> args = new HashMap<>();
for (Map.Entry<String, StressYaml.QueryDef> e : queries.entrySet()) {
stmts.put(e.getKey().toLowerCase(), jclient.prepare(e.getValue().cql));
args.put(e.getKey().toLowerCase(), e.getValue().fields == null ? SchemaStatement.ArgSelect.MULTIROW : SchemaStatement.ArgSelect.valueOf(e.getValue().fields.toUpperCase()));
}
queryStatements = stmts;
argSelects = args;
}
}
}
if (dynamicConditionExists(queryStatements.get(name)))
return new CASQuery(timer, settings, generator, seeds, queryStatements.get(name), settings.command.consistencyLevel, argSelects.get(name), tableName);
return new SchemaQuery(timer, settings, generator, seeds, queryStatements.get(name), settings.command.consistencyLevel, argSelects.get(name));
}
Aggregations