named scenario structural flexibility

This commit is contained in:
Jonathan Shook 2020-03-24 18:58:10 -05:00
parent 6fa256cd70
commit 58cb56f0bb
2 changed files with 29 additions and 14 deletions

View File

@ -1,8 +1,6 @@
package io.nosqlbench.engine.api.activityconfig.rawyaml;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
public class RawScenarios extends LinkedHashMap<String, LinkedList<String>> {
@ -11,6 +9,23 @@ public class RawScenarios extends LinkedHashMap<String, LinkedList<String>> {
}
public List<String> getNamedScenario(String scenarioName) {
return this.get(scenarioName);
Object v = this.get(scenarioName);
if (v==null) { return null; }
// Yes this looks strange. Yes it will work. SnakeYaml and generics are a bad combo.
if (v instanceof List) {
return (List<String>) v;
} else if (v instanceof CharSequence) {
return List.of(v.toString());
} else if (v instanceof Map) {
Object[] o = ((Map) v).values().toArray();
ArrayList<String> strings = new ArrayList<>(o.length);
for (Object o1 : o) {
strings.add(o.toString());
}
return strings;
} else {
throw new RuntimeException("Unknown type while access raw named scenarios data: " + v.getClass().getCanonicalName());
}
}
}

View File

@ -1,20 +1,20 @@
# eb sequences concat
# yields ABBCCCDDDDABBCCCDDDD
# yields A B B C C C D D D D A B B C C C D D D D
# eb run driver=stdout workload=examples/sequences cycles=20 seq=interval
# yields ABCDDCBDCDABCDDCBDCD
# yields A B C D D C B D C D A B C D D C B D C D
# eb run driver=stdout workload=examples/sequences cycles=20 seq=bucket
# yields ABCDBCDCDDABCDBCDCDD
# yields A B C D B C D C D D A B C D B C D C D D
scenarios:
concat: driver===stdout seq===concat
bucket: driver===stdout seq===bucket
interval: driver===stdout seq===interval
concat: run driver===stdout seq===concat cycles=20
bucket: run driver===stdout seq===bucket cycles=20
interval: run driver===stdout seq===interval cycles=20
statements:
- A1: "|"
- A1: "A "
ratio: 1
- B2: "_"
- B2: "B "
ratio: 2
- C3: "="
- C3: "C "
ratio: 3
- D4: ":"
- D4: "D "
ratio: 4