From 2b521edbbf331a084f8b023bdacf4c39de3e83eb Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Thu, 19 Jan 2023 19:29:28 -0600 Subject: [PATCH] provide an empty value type for op templates --- .../api/activityconfig/rawyaml/RawStmtsDocList.java | 6 +++++- .../engine/api/activityconfig/yaml/StmtsDocList.java | 7 +++++-- .../engine/api/activityimpl/SimpleActivity.java | 10 ++++------ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/rawyaml/RawStmtsDocList.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/rawyaml/RawStmtsDocList.java index 65f0517dc..a87ae402f 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/rawyaml/RawStmtsDocList.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/rawyaml/RawStmtsDocList.java @@ -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 getStmtsDocs() { return rawStmtsDocList; } diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/yaml/StmtsDocList.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/yaml/StmtsDocList.java index 7a13d74ec..800438219 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/yaml/StmtsDocList.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/activityconfig/yaml/StmtsDocList.java @@ -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 { this.rawStmtsDocList = rawStmtsDocList; } + public static StmtsDocList none() { + return new StmtsDocList(RawStmtsDocList.none()); + } + public List getStmtDocs(String tagFilter) { TagFilter tf = new TagFilter(tagFilter); return getStmtDocs().stream() @@ -67,7 +71,6 @@ public class StmtsDocList implements Iterable { TagFilter ts = new TagFilter(tagFilterSpec); List opTemplates = new ArrayList<>(); - getStmtDocs().stream() .flatMap(d -> d.getStmts().stream()) .filter(ts::matchesTagged) diff --git a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java index 9a4da328a..0045fa415 100644 --- a/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java +++ b/engine-api/src/main/java/io/nosqlbench/engine/api/activityimpl/SimpleActivity.java @@ -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 stmt = activityDef.getParams().getOptionalString("op", "stmt", "statement"); Optional 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);