Merge branch 'nbui' into nbui-more

This commit is contained in:
Jonathan Shook
2020-04-09 11:23:41 -05:00
34 changed files with 126 additions and 57 deletions

View File

@@ -265,6 +265,7 @@ public class NBCLIScenarioParser {
// }
private static Pattern templatePattern = Pattern.compile("TEMPLATE\\((.+?)\\)");
private static Pattern innerTemplatePattern = Pattern.compile("TEMPLATE\\((.+?)$");
private static Pattern templatePattern2 = Pattern.compile("<<(.+?)>>");
@@ -288,21 +289,11 @@ public class NBCLIScenarioParser {
StmtsDocList stmts = StatementsLoader.load(logger,content);
Set<String> templates = new HashSet<>();
Map<String, String> templates = new HashMap<>();
try {
List<String> lines = Files.readAllLines(yamlPath);
for (String line : lines) {
Matcher matcher = templatePattern.matcher(line);
while (matcher.find()) {
templates.add(matcher.group(1));
}
matcher = templatePattern2.matcher(line);
while (matcher.find()) {
templates.add(matcher.group(1));
}
templates = matchTemplates(line, templates);
}
} catch (IOException e) {
e.printStackTrace();
@@ -321,4 +312,34 @@ public class NBCLIScenarioParser {
return workloadDescriptions;
}
public static Map<String, String> matchTemplates(String line, Map<String, String> templates) {
Matcher matcher = templatePattern.matcher(line);
while (matcher.find()) {
String match = matcher.group(1);
Matcher innerMatcher = innerTemplatePattern.matcher(match);
String[] matchArray = match.split(",");
//TODO: support recursive matches
if (innerMatcher.find()) {
String[] innerMatch = innerMatcher.group(1).split(",");
//We want the outer name with the inner default value
templates.put(matchArray[0], innerMatch[1]);
}else{
templates.put(matchArray[0], matchArray[1]);
}
}
matcher = templatePattern2.matcher(line);
while (matcher.find()) {
String match = matcher.group(1);
String[] matchArray = match.split(":");
templates.put(matchArray[0],matchArray[1]);
}
return templates;
}
}

View File

@@ -1,14 +1,14 @@
package io.nosqlbench.engine.api.scenarios;
import java.util.List;
import java.util.Set;
import java.util.Map;
public class WorkloadDesc {
private final String yamlPath;
private final List<String> scenarioNames;
private final Set<String> templates;
private final Map<String, String> templates;
public WorkloadDesc(String yamlPath, List<String> scenarioNames, Set<String> templates) {
public WorkloadDesc(String yamlPath, List<String> scenarioNames, Map<String, String> templates) {
this.yamlPath = yamlPath;
this.scenarioNames = scenarioNames;
this.templates = templates;
@@ -27,7 +27,7 @@ public class WorkloadDesc {
return scenarioNames;
}
public Set<String> getTemplates() {
public Map<String, String> getTemplates() {
return templates;
}
}