Skip to content

Commit

Permalink
Merge branch 'main' into update-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
jjbrosnan authored Aug 28, 2023
2 parents 6748dfc + 5627e13 commit 895e7f2
Show file tree
Hide file tree
Showing 800 changed files with 57,781 additions and 17,563 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ workspaces/
devopsLocal/
pyclient/venv
pyclient/dist
pyclient/*.egg-info
.venv/
*.egg-info/

jenkins/failures

Expand Down
1 change: 1 addition & 0 deletions BenchmarkSupport/BenchmarkSupport.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ sourceSets {
}

dependencies {
implementation project(':Base')
implementation project(':engine-table')
implementation project(':extensions-parquet-table')
implementation project(':Configuration')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@
import java.util.Random;
import java.util.stream.Collectors;

import static io.deephaven.benchmarking.generator.NumberGenerator.getLowerBoundForType;
import static io.deephaven.benchmarking.generator.NumberGenerator.getUpperBoundForType;

/**
* An entry point to get instances of {@link BenchmarkTableBuilder}s.
*/
Expand Down Expand Up @@ -88,7 +91,7 @@ BenchmarkTableBuilder tableBuilder(String name, Table fromTable) {
*/
@ScriptApi
public static ColumnGenerator<String> stringCol(String name, int nVals, int minLen, int maxLen, long seed) {
return stringCol(name, nVals, minLen, maxLen, seed, EnumStringColumnGenerator.Mode.Random);
return stringCol(name, nVals, minLen, maxLen, seed, EnumStringGenerator.Mode.Random);
}

/**
Expand All @@ -97,8 +100,8 @@ public static ColumnGenerator<String> stringCol(String name, int nVals, int minL
* </p>
*
* <ul>
* <li><i>{@link EnumStringColumnGenerator.Mode#Random}</i> - Select enum values randomly</li>
* <li><i>{@link EnumStringColumnGenerator.Mode#Rotate}</i> - Select enum values in order, and wrap around</li>
* <li><i>{@link EnumStringGenerator.Mode#Random}</i> - Select enum values randomly</li>
* <li><i>{@link EnumStringGenerator.Mode#Rotate}</i> - Select enum values in order, and wrap around</li>
* </ul>
*
* @param name The name of the column
Expand All @@ -112,8 +115,9 @@ public static ColumnGenerator<String> stringCol(String name, int nVals, int minL
*/
@ScriptApi
public static ColumnGenerator<String> stringCol(String name, int nVals, int minLen, int maxLen, long seed,
EnumStringColumnGenerator.Mode mode) {
return new EnumStringColumnGenerator(name, nVals, minLen, maxLen, seed, mode);
EnumStringGenerator.Mode mode) {
return new ObjectColumnGenerator<>(String.class, name,
new EnumStringGenerator(nVals, seed, mode, minLen, maxLen));
}

/**
Expand All @@ -127,7 +131,20 @@ public static ColumnGenerator<String> stringCol(String name, int nVals, int minL
*/
@ScriptApi
public static ColumnGenerator<String> stringCol(String name, int minLen, int maxLen) {
return new RandomStringColumnGenerator(name, minLen, maxLen);
return new ObjectColumnGenerator<>(String.class, name, new RandomStringGenerator(minLen, maxLen));
}

/**
* Create a {@link ColumnGenerator<String>} that generates random strings constrained by length.
*
* @param name The name of the column
* @param generator the generator
* @return a {@link ColumnGenerator<String>} suitable for use with
* {@link BenchmarkTableBuilder#addColumn(ColumnGenerator)}
*/
@ScriptApi
public static ColumnGenerator<String> stringCol(String name, ObjectGenerator<String> generator) {
return new ObjectColumnGenerator<>(String.class, name, generator);
}

/**
Expand All @@ -141,7 +158,7 @@ public static ColumnGenerator<String> stringCol(String name, int minLen, int max
*/
@ScriptApi
public static ColumnGenerator<Character> charCol(String name, char min, char max) {
return new CharColumnGenerator(name, min, max);
return new NumberColumnGenerator<>(Character.class, name, new RandomNumberGenerator(min, max));
}

/**
Expand All @@ -151,7 +168,8 @@ public static ColumnGenerator<Character> charCol(String name, char min, char max
*/
@ScriptApi
public static ColumnGenerator<Instant> instantCol(String name) {
return new InstantColumnGenerator(name);
return new ObjectColumnGenerator<>(Instant.class, name,
new InstantGenerator(new RandomNumberGenerator(0, Long.MAX_VALUE)));
}

/**
Expand All @@ -163,7 +181,20 @@ public static ColumnGenerator<Instant> instantCol(String name) {
*/
@ScriptApi
public static ColumnGenerator<Instant> instantCol(String name, Instant min, Instant max) {
return new InstantColumnGenerator(name, min, max);
return new ObjectColumnGenerator<>(Instant.class, name,
new InstantGenerator(new RandomNumberGenerator(min.getNano(), max.getNano())));
}

/**
* @param name The name of the column
* @param min the minimum value
* @param max the maximum value
* @return a {@link ColumnGenerator<Instant>} for use with {@link BenchmarkTableBuilder#addColumn(ColumnGenerator)}
*/
@ScriptApi
public static ColumnGenerator<Instant> seqDateCol(String name, Instant min, Instant max, long stepNanos) {
return new ObjectColumnGenerator<>(Instant.class, name, new InstantGenerator(new SequentialNumberGenerator(
min.getNano(), stepNanos, max.getNano(), SequentialNumberGenerator.Mode.RollAtLimit)));
}

/**
Expand All @@ -176,7 +207,8 @@ public static ColumnGenerator<Instant> instantCol(String name, Instant min, Inst
*/
@ScriptApi
public static <T extends Number> ColumnGenerator<T> numberCol(String name, Class<T> type) {
return new RandomNumColumnGenerator<>(type, name);
return new NumberColumnGenerator<>(type, name, new RandomNumberGenerator(
getLowerBoundForType(type), getUpperBoundForType(type)));
}

/**
Expand All @@ -191,7 +223,22 @@ public static <T extends Number> ColumnGenerator<T> numberCol(String name, Class
*/
@ScriptApi
public static <T extends Number> ColumnGenerator<T> numberCol(String name, Class<T> type, double min, double max) {
return new RandomNumColumnGenerator<>(type, name, min, max);
return new NumberColumnGenerator<>(type, name, new RandomNumberGenerator(min, max));
}

/**
* Create a {@link ColumnGenerator<T>} that generates a random number of the desired type within a range.
*
* @param name The name of the column
* @param type The type of number
* @param generator the number generator
* @param <T> The type of number
* @return a {@link ColumnGenerator<T>} for use with {@link BenchmarkTableBuilder#addColumn(ColumnGenerator)}
*/
@ScriptApi
public static <T extends Number> ColumnGenerator<T> numberCol(String name, Class<T> type,
NumberGenerator generator) {
return new NumberColumnGenerator<>(type, name, generator);
}

/**
Expand All @@ -207,21 +254,21 @@ public static <T extends Number> ColumnGenerator<T> numberCol(String name, Class
@ScriptApi
public static <T extends Number> ColumnGenerator<T> seqNumberCol(String name, Class<T> type, double start,
double step) {
return new SequentialNumColumnGenerator<>(type, name, start, step);
return new NumberColumnGenerator<>(type, name, new SequentialNumberGenerator(
start, step, getUpperBoundForType(type), SequentialNumberGenerator.Mode.RollAtLimit));
}

/**
* <p>
* Create a {@link ColumnGenerator<T>} that generates a number of the desired type which steps based on the input
* {@link SequentialNumColumnGenerator.Mode}.
* {@link SequentialNumberGenerator.Mode}.
* </p>
*
* <ul>
* <li><i>{@link SequentialNumColumnGenerator.Mode#NoLimit}</i> - Monotonically increasing with no limit</li>
* <li><i>{@link SequentialNumColumnGenerator.Mode#RollAtLimit}</i> - Roll over to the start value when the limit is
* <li><i>{@link SequentialNumberGenerator.Mode#RollAtLimit}</i> - Roll over to the start value when the limit is
* reached</li>
* <li><i>{@link SequentialNumberGenerator.Mode#ReverseAtLimit}</i> - Change increment direction when the limit is
* reached</li>
* <li><i>{@link SequentialNumColumnGenerator.Mode#ReverseAtLimit}</i> - Change increment direction when the limit
* is reached</li>
* </ul>
*
* @param name The name of the column
Expand All @@ -235,8 +282,8 @@ public static <T extends Number> ColumnGenerator<T> seqNumberCol(String name, Cl
*/
@ScriptApi
public static <T extends Number> ColumnGenerator<T> seqNumberCol(String name, Class<T> type, double start,
double step, double max, SequentialNumColumnGenerator.Mode mode) {
return new SequentialNumColumnGenerator<>(type, name, start, step, max, mode);
double step, double max, SequentialNumberGenerator.Mode mode) {
return new NumberColumnGenerator<>(type, name, new SequentialNumberGenerator(start, step, max, mode));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static void recordResults(final Collection<RunResult> results, final File
for (final RunResult runResult : results) {
final BenchmarkParams runParams = runResult.getParams();
headers.addAll(runParams.getParamsKeys());
runResult.getSecondaryResults().keySet().stream()
.map(s -> s.replaceAll("\\s+", "_"))
.forEach(headers::add);
}

writer.writeHeaders(headers);
Expand All @@ -68,6 +71,10 @@ public static void recordResults(final Collection<RunResult> results, final File
values.put("Run", Integer.toString(runNo));
values.put("Iteration", Integer.toString(itNo));

itResult.getSecondaryResults().forEach((res, val) -> {
values.put(res.replaceAll("\\s+", "_"), decimalFormat.format(val.getScore()));
});

writer.writeRow(headers.stream().map(values::get).collect(Collectors.toList()));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/**
* Copyright (c) 2016-2023 Deephaven Data Labs and Patent Pending
*/
package io.deephaven.benchmarking.generator;

import io.deephaven.engine.table.ColumnDefinition;
import org.jetbrains.annotations.NotNull;

/**
* A {@link ColumnGenerator} that can be used to generate a typed column
*
* @param <T> The type.
*/
public abstract class AbstractColumnGenerator<T> implements ColumnGenerator<T> {
private final ColumnDefinition<T> def;

AbstractColumnGenerator(@NotNull final Class<T> type, @NotNull final String name) {
this.def = ColumnDefinition.fromGenericType(name, type);
}

@NotNull
@Override
public String getName() {
return def.getName();
}

@NotNull
@Override
public ColumnDefinition<T> getDefinition() {
return def;
}

@NotNull
@Override
public String getUpdateString(@NotNull final String varName) {
return def.getName() + "=(" + def.getDataType().getSimpleName() + ")" + varName + chooseGetter(def);
}

public T get() {
throw new UnsupportedOperationException("Not Implemented");
}

public byte getByte() {
throw new UnsupportedOperationException("Not Implemented");
}

public char getChar() {
throw new UnsupportedOperationException("Not Implemented");
}

public short getShort() {
throw new UnsupportedOperationException("Not Implemented");
}

public int getInt() {
throw new UnsupportedOperationException("Not Implemented");
}

public long getLong() {
throw new UnsupportedOperationException("Not Implemented");
}

public float getFloat() {
throw new UnsupportedOperationException("Not Implemented");
}

public double getDouble() {
throw new UnsupportedOperationException("Not Implemented");
}

/**
* @return the string to use in update() to get the correct type.
*/
private static String chooseGetter(@NotNull final ColumnDefinition<?> def) {
final Class<?> type = def.getDataType();
if (type == byte.class || type == Byte.class) {
return ".getByte()";
} else if (type == short.class || type == Short.class) {
return ".getShort()";
} else if (type == int.class || type == Integer.class) {
return ".getInt()";
} else if (type == long.class || type == Long.class) {
return ".getLong()";
} else if (type == float.class || type == Float.class) {
return ".getFloat()";
} else if (type == double.class || type == Double.class) {
return ".getDouble()";
}

return ".get()";
}
}

This file was deleted.

Loading

0 comments on commit 895e7f2

Please sign in to comment.