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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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)); return new RawStmtsDocList(List.of(rawStmtsDoc));
} }
public static RawStmtsDocList none() {
return new RawStmtsDocList(List.of());
}
public List<RawStmtsDoc> getStmtsDocs() { public List<RawStmtsDoc> getStmtsDocs() {
return rawStmtsDocList; 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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; this.rawStmtsDocList = rawStmtsDocList;
} }
public static StmtsDocList none() {
return new StmtsDocList(RawStmtsDocList.none());
}
public List<StmtsDoc> getStmtDocs(String tagFilter) { public List<StmtsDoc> getStmtDocs(String tagFilter) {
TagFilter tf = new TagFilter(tagFilter); TagFilter tf = new TagFilter(tagFilter);
return getStmtDocs().stream() return getStmtDocs().stream()
@ -67,7 +71,6 @@ public class StmtsDocList implements Iterable<StmtsDoc> {
TagFilter ts = new TagFilter(tagFilterSpec); TagFilter ts = new TagFilter(tagFilterSpec);
List<OpTemplate> opTemplates = new ArrayList<>(); List<OpTemplate> opTemplates = new ArrayList<>();
getStmtDocs().stream() getStmtDocs().stream()
.flatMap(d -> d.getStmts().stream()) .flatMap(d -> d.getStmts().stream())
.filter(ts::matchesTagged) .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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with 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() { protected StmtsDocList loadStmtsDocList() {
try { try {
StmtsDocList stmtsDocList = null;
Optional<String> stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement"); Optional<String> stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement");
Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload"); Optional<String> op_yaml_loc = activityDef.getParams().getOptionalString("yaml", "workload");
if (stmt.isPresent()) { if (stmt.isPresent()) {
stmtsDocList = StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
workloadSource = "commandline:" + stmt.get(); workloadSource = "commandline:" + stmt.get();
return StatementsLoader.loadStmt(logger, stmt.get(), activityDef.getParams());
} else if (op_yaml_loc.isPresent()) { } else if (op_yaml_loc.isPresent()) {
stmtsDocList = StatementsLoader.loadPath(logger, op_yaml_loc.get(), activityDef.getParams(), "activities");
workloadSource = "yaml:" + op_yaml_loc.get(); 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) { } catch (Exception e) {
throw new OpConfigError("Error loading op templates: " + e, workloadSource, e); throw new OpConfigError("Error loading op templates: " + e, workloadSource, e);