mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2024-11-23 09:16:37 -06:00
simply TagFilter for logging
This commit is contained in:
parent
5a436e9fd3
commit
8cf81b38e4
@ -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("^(?<conjugate>\\w+)\\((?<filter>.+)\\)$",Pattern.DOTALL|Pattern.MULTILINE);
|
||||
|
||||
public <T extends Tagged> List<T> filter(List<T> tagged) {
|
||||
return tagged.stream()
|
||||
.filter(this::matchesTagged)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public <T extends Tagged> List<String> filterLog(List<T> 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<String, String> tags) {
|
||||
return matches(tags);
|
||||
}
|
||||
|
||||
public Result matchesTaggedResult(Tagged item) {
|
||||
return matches(item.getTags());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user