From 8cf81b38e4e071298b4c8e03be705a2f0edfb4c2 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Thu, 19 Jan 2023 16:52:13 -0600 Subject: [PATCH] simply TagFilter for logging --- .../nosqlbench/engine/api/util/TagFilter.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/adapters-api/src/main/java/io/nosqlbench/engine/api/util/TagFilter.java b/adapters-api/src/main/java/io/nosqlbench/engine/api/util/TagFilter.java index d3c24d85e..2dbb19c71 100644 --- a/adapters-api/src/main/java/io/nosqlbench/engine/api/util/TagFilter.java +++ b/adapters-api/src/main/java/io/nosqlbench/engine/api/util/TagFilter.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. @@ -18,7 +18,10 @@ package io.nosqlbench.engine.api.util; import io.nosqlbench.api.engine.util.Tagged; -import java.util.*; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import java.util.function.BiFunction; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -98,6 +101,19 @@ public class TagFilter { private final static Pattern conjugateForm = Pattern.compile("^(?\\w+)\\((?.+)\\)$",Pattern.DOTALL|Pattern.MULTILINE); + public List filter(List tagged) { + return tagged.stream() + .filter(this::matchesTagged) + .collect(Collectors.toList()); + } + + public List filterLog(List tagged) { + return tagged.stream() + .map(this::matchesTaggedResult) + .map(Result::getLog) + .collect(Collectors.toList()); + } + private enum Conjugate { any((i,j) -> (j>0)), all((i,j) -> (i.intValue()==j.intValue())), @@ -201,10 +217,6 @@ public class TagFilter { return new Result(matched, log); } - public Result matchesMap(Map tags) { - return matches(tags); - } - public Result matchesTaggedResult(Tagged item) { return matches(item.getTags()); }