provide an empty value type for op templates

This commit is contained in:
Jonathan Shook 2023-01-19 19:29:28 -06:00
parent 7af2680034
commit 2b521edbbf
3 changed files with 14 additions and 9 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) 2022-2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -31,6 +31,10 @@ public class RawStmtsDocList {
return new RawStmtsDocList(List.of(rawStmtsDoc));
}
public static RawStmtsDocList none() {
return new RawStmtsDocList(List.of());
}
public List<RawStmtsDoc> getStmtsDocs() {
return rawStmtsDocList;
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) 2022-2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -41,6 +41,10 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
this.rawStmtsDocList = rawStmtsDocList;
}
public static StmtsDocList none() {
return new StmtsDocList(RawStmtsDocList.none());
}
public List<StmtsDoc> getStmtDocs(String tagFilter) {
TagFilter tf = new TagFilter(tagFilter);
return getStmtDocs().stream()
@ -67,7 +71,6 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
TagFilter ts = new TagFilter(tagFilterSpec);
List<OpTemplate> opTemplates = new ArrayList<>();
getStmtDocs().stream()
.flatMap(d -> d.getStmts().stream())
.filter(ts::matchesTagged)

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2022 nosqlbench
* Copyright (c) 2022-2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -652,19 +652,17 @@ public class SimpleActivity implements Activity, ProgressCapable, ActivityDefObs
protected StmtsDocList loadStmtsDocList() {
try {
StmtsDocList stmtsDocList = null;
Optional<String> stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement");
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
if (stmt.isPresent()) {
stmtsDocList = StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
workloadSource = "commandline:" + stmt.get();
return StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
} else if (op_yaml_loc.isPresent()) {
stmtsDocList = StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
workloadSource = "yaml:" + op_yaml_loc.get();
return StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
}
return stmtsDocList;
return StmtsDocList.none();
} catch (Exception e) {
throw new OpConfigError("Error loading op templates: " + e, workloadSource, e);