findmax 80% ready

This commit is contained in:
Jonathan Shook
2023-10-13 01:08:20 -05:00
parent bff86b5525
commit 137ce31136
24 changed files with 568 additions and 210 deletions

View File

@@ -19,6 +19,5 @@ package io.nosqlbench.components;
public interface NBComponentServices {
public NBCreators create();
public NBFinders find();
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright (c) 2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.components;
import java.util.function.Function;
public class NBComponentViews {
public static String treeView(NBComponent node) {
return treeView(new StringBuilder(), node, 0, Object::toString);
}
public static String treeView(NBComponent node, Function<NBComponent,String> representer) {
return treeView(new StringBuilder(), node, 0, representer);
}
private static String treeView(StringBuilder sb, NBComponent node, int level, Function<NBComponent,String> stringify) {
sb.append(" ".repeat(level)).append(stringify.apply(node)).append("\n");
for (NBComponent child : node.getChildren()) {
treeView(sb,child,level+1,stringify);
}
return sb.toString();
}
}

View File

@@ -18,4 +18,8 @@ package io.nosqlbench.components.events;
import io.nosqlbench.components.UpEvent;
public record ParamChange<T>(T value) implements UpEvent {}
public record ParamChange<T>(T value) implements UpEvent {
public static <T> ParamChange<T> of(T value) {
return new ParamChange<>(value);
}
}

View File

@@ -1,45 +0,0 @@
/*
* Copyright (c) 2023 nosqlbench
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.nosqlbench.components;
import io.nosqlbench.api.config.standard.TestComponent;
import org.junit.jupiter.api.Test;
class NBComponentViewsTest {
@Test
public void testBasicTreeView() {
var root1 = new TestComponent("a", "b");
var cd = new TestComponent(root1, "c", "d");
var UV = new TestComponent(cd, "U", "V");
var YZ = new TestComponent(cd, "Y", "Z");
var ef = new TestComponent(root1, "e", "f");
var root2 = new TestComponent("a", "b");
root2.attachChild(new TestComponent(root2, "c", "d")
.attachChild(new TestComponent("U", "V"))
.attachChild(new TestComponent("Y", "Z")))
.attachChild(new TestComponent("e", "f"));
System.out.println("root1:\n" + NBComponentViews.treeView(root1));
System.out.println("root1:\n" + NBComponentViews.treeView(root1, c -> String.valueOf(c.hashCode())));
System.out.println("root2:\n" + NBComponentViews.treeView(root2));
System.out.println("root2:\n" + NBComponentViews.treeView(root2, c -> String.valueOf(c.hashCode())));
}
}