mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
fix for the cql anchor fix to actually add curly braces
This commit is contained in:
parent
5b4f23bb4b
commit
10dd0cb02f
@ -144,18 +144,19 @@ public class CqlActivity extends SimpleActivity implements Activity, ActivityDef
|
||||
return session;
|
||||
}
|
||||
|
||||
private String canonicalizeBindings(String input) {
|
||||
// for testing
|
||||
public static String canonicalizeBindings(String input) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
Pattern questionPattern = Pattern.compile("\\?(?<arg>\\w+)");
|
||||
Matcher matcher = questionPattern.matcher(input);
|
||||
int count = 0;
|
||||
while (matcher.find()) {
|
||||
matcher.appendReplacement(sb, matcher.group("arg"));
|
||||
matcher.appendReplacement(sb, "{" + matcher.group("arg") + "}");
|
||||
count++;
|
||||
}
|
||||
matcher.appendTail(sb);
|
||||
if (count > 0) {
|
||||
logger.warn("You are using a deprecated data binding syntax in '" + input + "'. This is supported in the classic CQL driver," +
|
||||
logger.warn("You are using deprecated data binding syntax in '" + input + "'. This is supported in the classic CQL driver," +
|
||||
" but it is not recognized by other workloads. Please change to the {standard} binding syntax. The canonical" +
|
||||
" syntax for CQL is rendered automatically.");
|
||||
}
|
||||
@ -191,7 +192,7 @@ public class CqlActivity extends SimpleActivity implements Activity, ActivityDef
|
||||
|
||||
for (OpTemplate stmtDef : stmts) {
|
||||
|
||||
ParsedStmt parsed = stmtDef.getParsed(this::canonicalizeBindings).orError();
|
||||
ParsedStmt parsed = stmtDef.getParsed(CqlActivity::canonicalizeBindings).orError();
|
||||
boolean prepared = stmtDef.getParamOrDefault("prepared", true);
|
||||
boolean parameterized = stmtDef.getParamOrDefault("parameterized", false);
|
||||
long ratio = stmtDef.getParamOrDefault("ratio", 1);
|
||||
|
@ -0,0 +1,14 @@
|
||||
package io.nosqlbench.activitytype.cql.core;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class CqlActivityTest {
|
||||
|
||||
@Test
|
||||
public void testCanonicalize() {
|
||||
String cb = CqlActivity.canonicalizeBindings("A ?b C");
|
||||
assertThat(cb).isEqualTo("A {b} C");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user