Skip to content

Commit

Permalink
Added BobyqaOptimizer and CsvOutputWriter as builders and removed the…
Browse files Browse the repository at this point in the history
…m from plugins
  • Loading branch information
MarkWolters committed Oct 5, 2023
1 parent 3a6b849 commit 44fd5cd
Show file tree
Hide file tree
Showing 16 changed files with 67 additions and 226 deletions.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package io.nosqlbench.engine.extensions.csvoutput;

import io.nosqlbench.api.csvoutput.CsvOutputPluginWriter;
import io.nosqlbench.components.NBBaseComponent;
import org.assertj.core.util.Files;
import org.graalvm.polyglot.Value;
import org.junit.jupiter.api.Test;
Expand All @@ -30,7 +32,7 @@ public void testCsvOutputWriter() {
File tmpfile = Files.newTemporaryFile();
tmpfile.deleteOnExit();
System.out.println("tmpfile="+ tmpfile.getPath());
CsvOutputPluginWriter out = new CsvOutputPluginWriter(tmpfile.getPath(), "one", "two");
CsvOutputPluginWriter out = new CsvOutputPluginWriter(new NBBaseComponent(null), tmpfile.getPath(), "one", "two");
out.write(Value.asValue(Map.of("one","one_","two","two_")));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,10 +12,13 @@
* 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.engine.extensions.csvoutput;
package io.nosqlbench.api.csvoutput;

import io.nosqlbench.components.NBBaseComponent;
import io.nosqlbench.components.NBComponent;
import org.apache.commons.csv.CSVFormat;
import org.apache.commons.csv.CSVPrinter;
import org.graalvm.polyglot.Value;
Expand All @@ -27,14 +30,15 @@
import java.nio.file.attribute.PosixFilePermissions;
import java.util.*;

public class CsvOutputPluginWriter {
public class CsvOutputPluginWriter extends NBBaseComponent {

private final CSVPrinter printer;
private final FileWriter filewriter;
private final LinkedHashSet<String> headerKeys;
private final String filename;

public CsvOutputPluginWriter(String filename, String... headers) {
public CsvOutputPluginWriter(NBComponent component, String filename, String... headers) {
super(component);
try {
this.filename = filename;
Path filepath = Path.of(filename);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@
* 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.engine.extensions.conversions;
package io.nosqlbench.api.engine.conversions;

public class ConverterUtils {
public static int[] toIntArray(String[] strings) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,10 @@
* 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.engine.extensions.optimizers;
package io.nosqlbench.api.engine.optimizers;

import io.nosqlbench.components.NBBaseComponent;
import io.nosqlbench.components.NBComponent;
Expand All @@ -23,16 +24,16 @@
import org.apache.commons.math3.optim.nonlinear.scalar.GoalType;
import org.apache.commons.math3.optim.nonlinear.scalar.ObjectiveFunction;
import org.apache.commons.math3.optim.nonlinear.scalar.noderiv.BOBYQAOptimizer;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import javax.script.ScriptContext;
import java.util.Arrays;
import java.util.List;
import java.util.function.Function;

public class BobyqaOptimizerInstance {
public class BobyqaOptimizerInstance extends NBBaseComponent {

private final Logger logger;
private static final Logger logger = LogManager.getLogger(BobyqaOptimizerInstance.class);
private final NBComponent baseComponent;

private int interpolations = 0;
Expand All @@ -49,8 +50,8 @@ public class BobyqaOptimizerInstance {
private MVLogger mvLogger;
private double guessSlew = 0.25d;

public BobyqaOptimizerInstance(Logger logger, NBComponent baseComponent) {
this.logger = logger;
public BobyqaOptimizerInstance(NBComponent baseComponent) {
super(baseComponent);
this.baseComponent = baseComponent;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,10 @@
* 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.engine.extensions.optimizers;
package io.nosqlbench.api.engine.optimizers;

import org.apache.commons.math3.analysis.MultivariateFunction;

Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,10 @@
* 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.engine.extensions.optimizers;
package io.nosqlbench.api.engine.optimizers;

import java.util.ArrayList;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,10 @@
* 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.engine.extensions.optimizers;
package io.nosqlbench.api.engine.optimizers;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -12,9 +12,10 @@
* 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.engine.extensions.optimizers;
package io.nosqlbench.api.engine.optimizers;

import org.apache.commons.math3.analysis.MultivariateFunction;
import org.graalvm.polyglot.proxy.ProxyObject;
Expand Down
Loading

0 comments on commit 44fd5cd

Please sign in to comment.