mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
update docs and categories for functions
This commit is contained in:
parent
cff147efa6
commit
f8d99c086a
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.collections;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.core.bindings.DataMapper;
|
||||
@ -18,10 +20,11 @@ import java.util.function.LongFunction;
|
||||
*
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.collections})
|
||||
public class ListMapper implements LongFunction<List<?>> {
|
||||
|
||||
private int size;
|
||||
private DataMapper<String> elementMapper;
|
||||
private final int size;
|
||||
private final DataMapper<String> elementMapper;
|
||||
|
||||
@Example({"ListMapper(5,NumberNameToString())","creates a list of number names"})
|
||||
public ListMapper(int size, String genSpec) {
|
||||
|
@ -4,6 +4,8 @@ import com.datastax.driver.core.DataType;
|
||||
import com.datastax.driver.core.LocalDate;
|
||||
import com.datastax.driver.core.TupleValue;
|
||||
import com.datastax.driver.core.UDTValue;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -20,6 +22,7 @@ import java.util.function.Function;
|
||||
* Shows the compatible CQL type most associated with the incoming Java type.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.diagnostics})
|
||||
public class ToCqlType implements Function<Object, String> {
|
||||
|
||||
private final static Map<String, String> typemap = new HashMap<String, String>() {{
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.geometry;
|
||||
|
||||
import com.datastax.driver.dse.geometry.Point;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
@ -11,6 +13,7 @@ import java.util.function.LongToDoubleFunction;
|
||||
* com.datastax.driver.dse.geometry.Distance objects.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.objects})
|
||||
public class Distance implements LongFunction<com.datastax.driver.dse.geometry.Distance> {
|
||||
|
||||
private final io.nosqlbench.activitytype.cql.datamappers.functions.geometry.Point pointfunc;
|
||||
|
@ -2,14 +2,20 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.geometry;
|
||||
|
||||
//import com.datastax.driver.dse.geometry.Point;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongToDoubleFunction;
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
/**
|
||||
* Create a com.datastax.driver.dse.geometry.LineString
|
||||
*/
|
||||
@SuppressWarnings("Duplicates")
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.objects})
|
||||
public class LineString implements LongFunction<com.datastax.driver.dse.geometry.LineString> {
|
||||
|
||||
private final LongFunction<com.datastax.driver.dse.geometry.Point> pointfunc;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.geometry;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
@ -10,6 +12,7 @@ import java.util.function.LongToDoubleFunction;
|
||||
* objects.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.objects})
|
||||
public class Point implements LongFunction<com.datastax.driver.dse.geometry.Point> {
|
||||
|
||||
private final LongToDoubleFunction xfunc;
|
||||
|
@ -1,14 +1,20 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.geometry;
|
||||
|
||||
import com.datastax.driver.dse.geometry.Point;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongToDoubleFunction;
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
/**
|
||||
* Create a com.datastax.driver.dse.geometry.Polygon
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.objects})
|
||||
public class Polygon implements LongFunction<com.datastax.driver.dse.geometry.Polygon> {
|
||||
|
||||
private final LongFunction<Point> pointfunc;
|
||||
|
@ -2,6 +2,8 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.geometry;
|
||||
|
||||
import com.datastax.driver.dse.geometry.Point;
|
||||
import com.datastax.driver.dse.geometry.Polygon;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.curves4.discrete.long_int.Uniform;
|
||||
@ -25,6 +27,7 @@ import java.util.function.LongFunction;
|
||||
*/
|
||||
@SuppressWarnings("ALL")
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.objects})
|
||||
public class PolygonOnGrid implements LongFunction<Polygon> {
|
||||
|
||||
private final double rows;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.long_localdate;
|
||||
|
||||
import com.datastax.driver.core.LocalDate;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -12,6 +14,7 @@ import java.util.function.LongFunction;
|
||||
* the number of milliseconds since January 1st, 1970 GMT.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.datetime})
|
||||
public class EpochMillisToCqlLocalDate implements LongFunction<LocalDate> {
|
||||
|
||||
@Example({"EpochMillisToJavaLocalDate()", "Yields the LocalDate for the millis in GMT"})
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.long_localdate;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -22,6 +24,7 @@ import java.util.function.LongFunction;
|
||||
* Any timezone specifier may be used which can be read by {@link ZoneId#of(String)}
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.datetime})
|
||||
public class EpochMillisToJavaLocalDate implements LongFunction<LocalDate> {
|
||||
|
||||
ZoneId timezone;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.long_localdate;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -22,6 +24,7 @@ import java.util.function.LongFunction;
|
||||
* Any timezone specifier may be used which can be read by {@link ZoneId#of(String)}
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.datetime})
|
||||
public class EpochMillisToJavaLocalDateTime implements LongFunction<LocalDateTime> {
|
||||
|
||||
ZoneId timezone;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.long_localdate;
|
||||
|
||||
import com.datastax.driver.core.LocalDate;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -10,6 +12,7 @@ import java.util.function.LongFunction;
|
||||
* Days since Jan 1st 1970
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.datetime})
|
||||
public class LongToLocalDateDays implements LongFunction<LocalDate> {
|
||||
@Override
|
||||
public LocalDate apply(long value) {
|
||||
|
@ -20,13 +20,15 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.long_string;
|
||||
|
||||
import io.nosqlbench.nb.api.content.NBIO;
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.basics.shared.from_long.to_string.ModuloLineToString;
|
||||
import org.apache.commons.csv.CSVParser;
|
||||
import org.apache.commons.csv.CSVRecord;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -36,9 +38,12 @@ import java.util.function.LongFunction;
|
||||
/**
|
||||
* Select a value from a CSV file line by modulo division against the number
|
||||
* of lines in the file. The second parameter is the field name, and this must
|
||||
* be provided in the CSV header line as written.
|
||||
* be provided in the CSV header line as written. This version of the function is
|
||||
* a type-safe getter for UUID values.
|
||||
* @deprecated Use ModuloCSVLineToString(); ToUUID() instead
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.general})
|
||||
public class ModuloCSVLineToUUID implements LongFunction<UUID> {
|
||||
private final static Logger logger = LogManager.getLogger(ModuloLineToString.class);
|
||||
|
||||
|
@ -2,6 +2,9 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.rainbow;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
/**
|
||||
* Utility function used for advanced data generation experiments.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
public class TokenMapFileCycle extends TokenMapFileBaseFunction {
|
||||
|
||||
|
@ -2,6 +2,9 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.rainbow;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
/**
|
||||
* Utility function used for advanced data generation experiments.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
public class TokenMapFileNextCycle extends TokenMapFileBaseFunction {
|
||||
|
||||
|
@ -2,6 +2,9 @@ package io.nosqlbench.activitytype.cql.datamappers.functions.rainbow;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
/**
|
||||
* Utility function used for advanced data generation experiments.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
public class TokenMapFileNextToken extends TokenMapFileBaseFunction {
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.activitytype.cql.datamappers.functions.string_string;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import org.xerial.snappy.Snappy;
|
||||
|
||||
@ -7,10 +9,14 @@ import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Compress the input using snappy compression
|
||||
*/
|
||||
@Categories({Category.conversion})
|
||||
@ThreadSafeMapper
|
||||
public class SnappyComp implements Function<String, ByteBuffer> {
|
||||
|
||||
private Snappy snappy = new Snappy();
|
||||
private final Snappy snappy = new Snappy();
|
||||
|
||||
@Override
|
||||
public ByteBuffer apply(String s) {
|
||||
|
@ -8,5 +8,9 @@ public enum Category {
|
||||
conversion,
|
||||
collections,
|
||||
premade,
|
||||
nulls, functional, general
|
||||
nulls,
|
||||
functional,
|
||||
statistics,
|
||||
general,
|
||||
objects
|
||||
}
|
||||
|
@ -7,6 +7,9 @@ import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import java.nio.CharBuffer;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Convert the input string to a character buffer
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories(Category.conversion)
|
||||
public class ToCharBuffer implements Function<String, CharBuffer> {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.formatting;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -9,6 +11,7 @@ import java.util.function.DoubleFunction;
|
||||
* Formats a floating point value to a string using the java.text.DecimalFormat
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.conversion})
|
||||
public class DecimalFormat implements DoubleFunction<String> {
|
||||
private final java.text.DecimalFormat format;
|
||||
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_double.to_float;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.DoubleFunction;
|
||||
@ -8,6 +10,7 @@ import java.util.function.DoubleFunction;
|
||||
* Convert the input double value to the closest float value.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.conversion})
|
||||
public class DoubleToFloat implements DoubleFunction<Float> {
|
||||
@Override
|
||||
public Float apply(double value) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_int;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.murmur.Murmur3F;
|
||||
|
||||
@ -14,6 +16,7 @@ import java.util.function.LongToIntFunction;
|
||||
* This is to make it play nice with users and other libraries.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.general})
|
||||
public class Hash implements LongToIntFunction {
|
||||
|
||||
ThreadLocal<ByteBuffer> bb_TL = ThreadLocal.withInitial(() -> ByteBuffer.allocate(Long.BYTES));
|
||||
|
@ -5,7 +5,8 @@ import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
/**
|
||||
* Scale the input to the
|
||||
* Scale the input by the factor provided
|
||||
* @deprecated Use Mul(...) instead
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
public class Scale implements LongToIntFunction {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.basics.core.MVELExpr;
|
||||
import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
@ -12,6 +14,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.functional})
|
||||
public class Expr implements LongUnaryOperator {
|
||||
|
||||
private final String expr;
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.murmur.Murmur3F;
|
||||
|
||||
@ -14,9 +16,10 @@ import java.util.function.LongUnaryOperator;
|
||||
* This is to make it play nice with users and other libraries.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.general, Category.general})
|
||||
public class Hash implements LongUnaryOperator {
|
||||
|
||||
private ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public long applyAsLong(long value) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
@ -9,6 +11,7 @@ import java.util.function.LongFunction;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class Swap implements LongUnaryOperator {
|
||||
|
||||
private final String name;
|
||||
|
@ -25,6 +25,7 @@ import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Return the string representation of the provided long.
|
||||
* @deprecated use ToString() instead
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@DeprecatedFunction("This function is being replaced by ToString() for naming consistency.")
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_time_types;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongUnaryOperator;
|
||||
@ -9,6 +11,7 @@ import java.util.function.LongUnaryOperator;
|
||||
* CAUTION: This does not produce deterministic test data.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.datetime})
|
||||
public class CurrentEpochMillis implements LongUnaryOperator {
|
||||
@Override
|
||||
public long applyAsLong(long operand) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.from_long.to_uuid;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.UUID;
|
||||
@ -16,6 +18,7 @@ import java.util.function.LongFunction;
|
||||
* specify a different long value to pre-fill it with.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.conversion})
|
||||
public class ToUUID implements LongFunction<UUID> {
|
||||
|
||||
private final long msbs;
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
package io.nosqlbench.virtdata.library.basics.shared.nondeterministic.to_int;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongToIntFunction;
|
||||
@ -31,11 +33,12 @@ import java.util.regex.Pattern;
|
||||
* you can't change the thread name and get an updated value.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class ThreadNum implements LongToIntFunction {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("^.*?(\\d+).*$");
|
||||
|
||||
private ThreadLocal<Integer> threadLocalInt = new ThreadLocal<Integer>() {
|
||||
private final ThreadLocal<Integer> threadLocalInt = new ThreadLocal<Integer>() {
|
||||
@Override
|
||||
protected Integer initialValue() {
|
||||
Matcher matcher = pattern.matcher(Thread.currentThread().getName());
|
||||
|
@ -18,23 +18,20 @@
|
||||
|
||||
package io.nosqlbench.virtdata.library.basics.shared.nondeterministic.to_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
import java.util.function.LongUnaryOperator;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Matches a digit sequence in the current thread name and caches it in a thread local.
|
||||
* This allows you to use any intentionally indexed thread factories to provide an analogue for
|
||||
* concurrency. Note that once the thread number is cached, it will not be refreshed. This means
|
||||
* you can't change the thread name and get an updated value.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class ThreadNum implements LongUnaryOperator {
|
||||
|
||||
private static final Pattern pattern = Pattern.compile("^.*?(\\d+).*$");
|
||||
private ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
private final ThreadLocal<Long> threadLocalInt = new ThreadLocal<Long>() {
|
||||
@Override
|
||||
protected Long initialValue() {
|
||||
Matcher matcher = pattern.matcher(Thread.currentThread().getName());
|
||||
|
@ -9,9 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Clears the per-thread map which is used by the Expr function.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class Clear implements Function<Object,Object> {
|
||||
|
@ -9,11 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Load a named value from the per-thread state map.
|
||||
* The previous input value will be forgotten, and the named value will replace it
|
||||
* before the next function in the chain.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class Load implements Function<Object,Object> {
|
||||
|
@ -9,11 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Load a value from a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* If the named variable is not defined, then the default value is returned.
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class LoadDouble implements Function<Object,Double> {
|
||||
|
@ -9,11 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Load a value from a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* If the named variable is not defined, then the default value is returned.
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class LoadString implements Function<Object,String> {
|
||||
|
@ -10,13 +10,6 @@ import java.util.HashMap;
|
||||
import java.util.function.DoubleUnaryOperator;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Save a value to a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* Note that the input type is not that suitable for constructing names,
|
||||
* so this is more likely to be used in an indirect naming pattern like
|
||||
* SaveDouble(Load('id'))
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class SaveDouble implements DoubleUnaryOperator {
|
||||
|
@ -10,13 +10,6 @@ import java.util.HashMap;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
/**
|
||||
* Save a value to a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* Note that the input type is not that suitable for constructing names,
|
||||
* so this is more likely to be used in an indirect naming pattern like
|
||||
* SaveFloat(Load('id'))
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class SaveFloat implements UnaryOperator<Float> {
|
||||
|
@ -9,11 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Load a value from a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* If the named variable is not defined, then the default value is returned.
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class LoadFloat implements LongFunction<Float> {
|
||||
|
@ -10,10 +10,6 @@ import java.util.HashMap;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
/**
|
||||
* Save the current input value at this point in the function chain to a thread-local variable name.
|
||||
* The input value is unchanged, and available for the next function in the chain to use as-is.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class Save implements LongUnaryOperator {
|
||||
|
@ -9,13 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.function.LongFunction;
|
||||
import java.util.function.LongToIntFunction;
|
||||
|
||||
/**
|
||||
* Save a value to a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* Note that the input type is not that suitable for constructing names,
|
||||
* so this is more likely to be used in an indirect naming pattern like
|
||||
* SaveInteger(Load('id'))
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class SaveInteger implements LongToIntFunction {
|
||||
|
@ -9,13 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.LongUnaryOperator;
|
||||
|
||||
/**
|
||||
* Save a value to a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* Note that the input type is not that suitable for constructing names,
|
||||
* so this is more likely to be used in an indirect naming pattern like
|
||||
* SaveLong(Load('id'))
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class SaveLong implements LongUnaryOperator {
|
||||
|
@ -9,13 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Save a value to a named thread-local variable, where the variable
|
||||
* name is fixed or a generated variable name from a provided function.
|
||||
* Note that the input type is not that suitable for constructing names,
|
||||
* so this is more likely to be used in an indirect naming pattern like
|
||||
* SaveString(Load('id'))
|
||||
*/
|
||||
@Categories(Category.state)
|
||||
@ThreadSafeMapper
|
||||
public class SaveString implements LongFunction<String> {
|
||||
|
@ -9,9 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Show diagnostic values for the thread-local variable map.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state,Category.diagnostics})
|
||||
public class Show implements LongFunction<String> {
|
||||
|
@ -9,12 +9,6 @@ import io.nosqlbench.virtdata.library.basics.core.threadstate.SharedState;
|
||||
import java.util.HashMap;
|
||||
import java.util.function.LongFunction;
|
||||
|
||||
/**
|
||||
* Load a named value from the per-thread state map.
|
||||
* The previous input value will be stored in the named value, and the previously
|
||||
* stored value will be returned. A default value to return may be provided
|
||||
* in case there was no previously stored value under the given name.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.state})
|
||||
public class Swap implements LongFunction<Object> {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.unary_int;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.Example;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
|
||||
@ -9,9 +11,10 @@ import java.util.function.IntUnaryOperator;
|
||||
* Adds a value to the input.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.general})
|
||||
public class Add implements IntUnaryOperator {
|
||||
|
||||
private int addend;
|
||||
private final int addend;
|
||||
|
||||
@Example({"Add(23)", "adds integer 23 to the input integer value"})
|
||||
public Add(int addend) {
|
||||
|
@ -1,5 +1,7 @@
|
||||
package io.nosqlbench.virtdata.library.basics.shared.unary_int;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import io.nosqlbench.virtdata.murmur.Murmur3F;
|
||||
|
||||
@ -14,9 +16,10 @@ import java.util.function.IntUnaryOperator;
|
||||
* This is to make it play nice with users and other libraries.
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.general})
|
||||
public class Hash implements IntUnaryOperator {
|
||||
|
||||
private ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
private final ThreadLocal<Murmur3F> murmur3f_TL = ThreadLocal.withInitial(Murmur3F::new);
|
||||
|
||||
@Override
|
||||
public int applyAsInt(int operand) {
|
||||
|
@ -5,7 +5,8 @@ import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import java.util.function.IntUnaryOperator;
|
||||
|
||||
/**
|
||||
* Scale the input to the
|
||||
* Scale the input by the factor provided.
|
||||
* @deprecated use Mul(...) instead
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
public class Scale implements IntUnaryOperator {
|
||||
|
@ -1,8 +1,11 @@
|
||||
package io.nosqlbench.virtdata.library.curves4.continuous.long_double;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import org.apache.commons.statistics.distribution.BetaDistribution;
|
||||
|
||||
@Categories({Category.distributions})
|
||||
@ThreadSafeMapper
|
||||
public class Beta extends LongToDoubleContinuousCurve {
|
||||
public Beta(double alpha, double beta, String... mods) {
|
||||
|
@ -1,8 +1,11 @@
|
||||
package io.nosqlbench.virtdata.library.curves4.discrete.int_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import org.apache.commons.statistics.distribution.BinomialDistribution;
|
||||
|
||||
@Categories({Category.distributions})
|
||||
@ThreadSafeMapper
|
||||
public class Binomial extends IntToLongDiscreteCurve {
|
||||
public Binomial(int trials, double p, String... modslist) {
|
||||
|
@ -1,9 +1,12 @@
|
||||
package io.nosqlbench.virtdata.library.curves4.discrete.long_int;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import org.apache.commons.statistics.distribution.BinomialDistribution;
|
||||
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.distributions})
|
||||
public class Binomial extends LongToIntDiscreteCurve {
|
||||
public Binomial(int trials, double p, String... modslist) {
|
||||
super(new BinomialDistribution(trials, p), modslist);
|
||||
|
@ -1,9 +1,12 @@
|
||||
package io.nosqlbench.virtdata.library.curves4.discrete.long_long;
|
||||
|
||||
import io.nosqlbench.virtdata.api.annotations.Categories;
|
||||
import io.nosqlbench.virtdata.api.annotations.Category;
|
||||
import io.nosqlbench.virtdata.api.annotations.ThreadSafeMapper;
|
||||
import org.apache.commons.statistics.distribution.BinomialDistribution;
|
||||
|
||||
@ThreadSafeMapper
|
||||
@Categories({Category.distributions})
|
||||
public class Binomial extends LongToLongDiscreteCurve {
|
||||
public Binomial(int trials, double p, String... modslist) {
|
||||
super(new BinomialDistribution(trials, p), modslist);
|
||||
|
Loading…
Reference in New Issue
Block a user