mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
temlpate parameters and unit test fixes
This commit is contained in:
@@ -27,6 +27,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -92,4 +92,5 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
|
||||
public Scenarios getDocScenarios() {
|
||||
return this.getStmtDocs().get(0).getScenarios();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,19 +26,20 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.*;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public class NosqlBenchFiles {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(NosqlBenchFiles.class);
|
||||
private static Pattern templatePattern = Pattern.compile("TEMPLATE\\((.+)\\)");
|
||||
private static Pattern templatePattern2 = Pattern.compile("<<(.+)>>");
|
||||
|
||||
|
||||
public static InputStream findRequiredStreamOrFile(String basename, String extension, String... searchPaths) {
|
||||
Optional<InputStream> optionalStreamOrFile = findOptionalStreamOrFile(basename, extension, searchPaths);
|
||||
@@ -145,28 +146,76 @@ public class NosqlBenchFiles {
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<String, List<String>> getWorkloadsWithScenarioScripts() {
|
||||
public static List<WorkloadDesc> getWorkloadsWithScenarioScripts() {
|
||||
|
||||
String dir = "activities/";
|
||||
String dir = "./";
|
||||
|
||||
Path basePath = VirtDataResources.findPathIn(dir);
|
||||
List<Path> yamlPathList = PathWalker.findAll(basePath).stream().filter(f -> f.toString().endsWith(".yaml")).collect(Collectors.toList());
|
||||
List<Path> yamlPathList = PathWalker.findAll(basePath)
|
||||
.stream()
|
||||
.filter(f -> f.toString().endsWith(".yaml"))
|
||||
.filter(f -> f.toString().contains("activities"))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
HashMap workloadMap = new HashMap();
|
||||
List<WorkloadDesc> workloadDescriptions = new ArrayList<>();
|
||||
for (Path yamlPath : yamlPathList) {
|
||||
String substring = yamlPath.toString().substring(1);
|
||||
String substring = yamlPath.toString().substring(2);
|
||||
StmtsDocList stmts = StatementsLoader.load(logger, substring);
|
||||
|
||||
Set<String> templates = new HashSet<>();
|
||||
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));
|
||||
}
|
||||
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
Scenarios scenarios = stmts.getDocScenarios();
|
||||
|
||||
List<String> scenarioNames = scenarios.getScenarioNames();
|
||||
|
||||
if (scenarioNames != null && scenarioNames.size() >0){
|
||||
workloadMap.put(yamlPath.getFileName().toString(), scenarioNames);
|
||||
workloadDescriptions.add(new WorkloadDesc(yamlPath.getFileName().toString(), scenarioNames, templates));
|
||||
}
|
||||
}
|
||||
|
||||
return workloadMap;
|
||||
return workloadDescriptions;
|
||||
}
|
||||
|
||||
public static class WorkloadDesc {
|
||||
private final String yamlPath;
|
||||
private final List<String> scenarioNames;
|
||||
private final Set<String> temlpates;
|
||||
|
||||
public WorkloadDesc(String yamlPath, List<String> scenarioNames, Set<String> templates) {
|
||||
this.yamlPath = yamlPath;
|
||||
this.scenarioNames = scenarioNames;
|
||||
this.temlpates = templates;
|
||||
}
|
||||
|
||||
public String getYamlPath() {
|
||||
return yamlPath;
|
||||
}
|
||||
|
||||
public List<String> getScenarioNames() {
|
||||
return scenarioNames;
|
||||
}
|
||||
|
||||
public Set<String> getTemlpates() {
|
||||
return temlpates;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user