rename StmtDef to OpDef

This commit is contained in:
Jonathan Shook 2021-02-23 15:46:46 -06:00
parent 6ba95e7f93
commit 30be470bc1
8 changed files with 26 additions and 26 deletions

View File

@ -2,7 +2,7 @@ package io.nosqlbench.activitytype.cql.core;
import com.datastax.driver.core.*;
import io.nosqlbench.engine.api.activityconfig.ParsedStmt;
import io.nosqlbench.engine.api.activityconfig.yaml.StmtDef;
import io.nosqlbench.engine.api.activityconfig.yaml.OpDef;
import java.math.BigDecimal;
import java.net.InetAddress;
@ -129,13 +129,13 @@ public class CQLBindHelper {
}
}
public static Map<String, String> parseAndGetSpecificBindings(StmtDef stmtDef, ParsedStmt parsed) {
public static Map<String, String> parseAndGetSpecificBindings(OpDef opDef, ParsedStmt parsed) {
List<String> spans = new ArrayList<>();
String statement = stmtDef.getStmt();
String statement = opDef.getStmt();
Set<String> extraBindings = new HashSet<>();
extraBindings.addAll(stmtDef.getBindings().keySet());
extraBindings.addAll(opDef.getBindings().keySet());
Map<String, String> specificBindings = new LinkedHashMap<>();
Matcher m = stmtToken.matcher(statement);
@ -153,9 +153,9 @@ public class CQLBindHelper {
if (extraBindings.contains(tokenName)) {
if (specificBindings.get(tokenName) != null){
String postfix = UUID.randomUUID().toString();
specificBindings.put(tokenName+postfix, stmtDef.getBindings().get(tokenName));
specificBindings.put(tokenName + postfix, opDef.getBindings().get(tokenName));
}else {
specificBindings.put(tokenName, stmtDef.getBindings().get(tokenName));
specificBindings.put(tokenName, opDef.getBindings().get(tokenName));
}
}
}

View File

@ -26,7 +26,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
public class StmtDef implements OpTemplate {
public class OpDef implements OpTemplate {
private final RawStmtDef rawStmtDef;
private final StmtsBlock block;
@ -34,7 +34,7 @@ public class StmtDef implements OpTemplate {
private final LinkedHashMap<String, String> bindings;
private final LinkedHashMap<String, String> tags;
public StmtDef(StmtsBlock block, RawStmtDef rawStmtDef) {
public OpDef(StmtsBlock block, RawStmtDef rawStmtDef) {
this.block = block;
this.rawStmtDef = rawStmtDef;
this.params = composeParams();

View File

@ -30,8 +30,8 @@ public class StmtsBlock implements Tagged, Iterable<OpTemplate> {
private final static String NameToken = "name";
private final static String StmtToken = "stmt";
private final RawStmtsBlock rawStmtsBlock;
private StmtsDoc rawStmtsDoc;
private int blockIdx;
private final StmtsDoc rawStmtsDoc;
private final int blockIdx;
public StmtsBlock(RawStmtsBlock rawStmtsBlock, StmtsDoc rawStmtsDoc, int blockIdx) {
@ -40,14 +40,14 @@ public class StmtsBlock implements Tagged, Iterable<OpTemplate> {
this.blockIdx = blockIdx;
}
public List<OpTemplate> getStmts() {
public List<OpTemplate> getOps() {
List<OpTemplate> rawOpTemplates = new ArrayList<>();
List<RawStmtDef> statements = rawStmtsBlock.getRawStmtDefs();
for (int i = 0; i < statements.size(); i++) {
rawOpTemplates.add(
new StmtDef(this, statements.get(i))
new OpDef(this, statements.get(i))
);
}
return rawOpTemplates;
@ -106,6 +106,6 @@ public class StmtsBlock implements Tagged, Iterable<OpTemplate> {
@Override
@NotNull
public Iterator<OpTemplate> iterator() {
return getStmts().iterator();
return getOps().iterator();
}
}
}

View File

@ -33,7 +33,7 @@ import java.util.stream.Collectors;
*/
public class StmtsDoc implements Tagged, Iterable<StmtsBlock> {
private RawStmtsDoc rawStmtsDoc;
private final RawStmtsDoc rawStmtsDoc;
public StmtsDoc(RawStmtsDoc rawStmtsDoc) {
this.rawStmtsDoc = rawStmtsDoc;
@ -91,7 +91,7 @@ public class StmtsDoc implements Tagged, Iterable<StmtsBlock> {
* including the inherited and overridden values from the this doc and the parent block.
*/
public List<OpTemplate> getStmts() {
return getBlocks().stream().flatMap(b -> b.getStmts().stream()).collect(Collectors.toList());
return getBlocks().stream().flatMap(b -> b.getOps().stream()).collect(Collectors.toList());
}
/**

View File

@ -47,9 +47,9 @@ public class StmtEscapingTest {
StmtsBlock block1 = doc1.getBlocks().get(0);
assertThat(block1.getBindings()).hasSize(0);
assertThat(block1.getTags()).hasSize(0);
assertThat(block1.getStmts()).hasSize(3);
assertThat(block1.getOps()).hasSize(3);
defs = block1.getStmts();
defs = block1.getOps();
}
@Test

View File

@ -38,14 +38,14 @@ public class ParsedStmtTest {
@Test
public void testBasicParser() {
StmtsBlock block0 = doclist.getStmtDocs().get(0).getBlocks().get(0);
OpTemplate stmtDef0 = block0.getStmts().get(0);
OpTemplate stmtDef0 = block0.getOps().get(0);
ParsedStmt parsed0 = stmtDef0.getParsed();
assertThat(parsed0.getExtraBindings()).containsExactly("alpha","gamma");
assertThat(parsed0.getMissingBindings()).containsExactly("delta");
assertThat(parsed0.hasError()).isTrue();
StmtsBlock block1 = doclist.getStmtDocs().get(0).getBlocks().get(1);
OpTemplate stmtDef1 = block1.getStmts().get(0);
OpTemplate stmtDef1 = block1.getOps().get(0);
ParsedStmt parsed1 = stmtDef1.getParsed();
assertThat(parsed1.getExtraBindings()).containsExactly();
assertThat(parsed1.getMissingBindings()).containsExactly();
@ -56,12 +56,12 @@ public class ParsedStmtTest {
public void testMultipleBindingUsage() {
StmtsBlock block2 = doclist.getStmtDocs().get(0).getBlocks().get(2);
OpTemplate stmtDef0 = block2.getStmts().get(0);
OpTemplate stmtDef0 = block2.getOps().get(0);
ParsedStmt parsed0 = stmtDef0.getParsed();
assertThat(parsed0.getMissingBindings()).isEmpty();
assertThat(parsed0.hasError()).isFalse();
OpTemplate stmtDef1 = block2.getStmts().get(1);
OpTemplate stmtDef1 = block2.getOps().get(1);
ParsedStmt parsed1 = stmtDef1.getParsed();
assertThat(parsed1.getMissingBindings().isEmpty());
assertThat(parsed1.hasError()).isFalse();

View File

@ -41,8 +41,8 @@ public class StmtDetailOverrideTest {
assertThat(doc1.getBlocks()).hasSize(2);
StmtsBlock doc1block0 = doc1.getBlocks().get(0);
assertThat(doc1block0.getStmts().size()).isEqualTo(1);
OpTemplate s = doc1block0.getStmts().get(0);
assertThat(doc1block0.getOps().size()).isEqualTo(1);
OpTemplate s = doc1block0.getOps().get(0);
assertThat(s.getName()).isEqualTo("block0--stmt1");
assertThat(s.getStmt()).isEqualTo("globalstatement1");
assertThat(s.getBindings()).hasSize(1);
@ -50,7 +50,7 @@ public class StmtDetailOverrideTest {
assertThat(s.getTags()).hasSize(1);
StmtsBlock doc1block1 = doc1.getBlocks().get(1);
List<OpTemplate> stmts = doc1block1.getStmts();
List<OpTemplate> stmts = doc1block1.getOps();
assertThat(stmts).hasSize(4);
s = stmts.get(0);

View File

@ -77,7 +77,7 @@ public class StmtsDocListTest {
@Test
public void testStmtInheritsBlockData() {
StmtsDoc doc0 = doclist.getStmtDocs().get(0);
List<OpTemplate> stmts1 = doc0.getBlocks().get(0).getStmts();
List<OpTemplate> stmts1 = doc0.getBlocks().get(0).getOps();
assertThat(stmts1).hasSize(2);
StmtsBlock block0 = doc0.getBlocks().get(0);