From 6a22d411a0d07d66c96b46e1c3e97389b7c16818 Mon Sep 17 00:00:00 2001 From: Jonathan Shook Date: Tue, 7 Jul 2020 11:40:26 -0500 Subject: [PATCH] make list function descriptions follow a pattern --- .../to_collection/ListFunctions.java | 19 ++++++++------- .../from_long/to_collection/ListHashed.java | 18 +++++++------- .../from_long/to_collection/ListSized.java | 24 +++++++++++-------- .../to_collection/ListSizedHashed.java | 11 +++++---- .../to_collection/ListSizedStepped.java | 13 +++++----- .../from_long/to_collection/ListStepped.java | 12 ++++------ 6 files changed, 53 insertions(+), 44 deletions(-) diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListFunctions.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListFunctions.java index ca7f97f71..ebc879cfb 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListFunctions.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListFunctions.java @@ -13,10 +13,13 @@ import java.util.function.LongFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on list of functions without any size boundaries, - * each function in the list functions populate the list with - * object value. + * Create a List from a long input based on a set of provided functions. + * + * As a 'Pair-wise' function, the size of the resulting collection is determined directly by the + * number of provided element functions. + * + * As neither a 'Stepped' nor a 'Hashed' function, the input value used by each element function is the same + * as that provided to the outer function. */ @Categories({Category.collections}) @ThreadSafeMapper @@ -26,8 +29,8 @@ public class ListFunctions implements LongFunction> { private final int size; @Example({ - "ListFunctions(NumberNameToString(),NumberNameToString(),NumberNameToString())", - "Create a list of object values of each function output. ListFunctions output ['one','one','one']" + "ListFunctions(NumberNameToString(),NumberNameToString(),NumberNameToString())", + "Create a list of object values of each function output. Produces values like ['one','one','one']" }) public ListFunctions(LongFunction... funcs) { this.valueFuncs = Arrays.asList(funcs); @@ -43,9 +46,9 @@ public class ListFunctions implements LongFunction> { this.size = building.size(); } - public ListFunctions(Function... funcs) { + public ListFunctions(Function... funcs) { List> building = new ArrayList<>(funcs.length); - for (Function func : funcs) { + for (Function func : funcs) { building.add(func::apply); } this.valueFuncs = building; diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListHashed.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListHashed.java index 6b172bb64..b516c6958 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListHashed.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListHashed.java @@ -15,10 +15,12 @@ import java.util.function.LongToIntFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on pseudo-randomly hash list of functions without any size boundaries, - * each function in the list functions populate the hash list with - * object value. + * Create a List from a long input based on a set of provided functions. + * + * As a 'Pair-wise' function, the size of the resulting collection is determined directly by the + * number of provided element functions. + * + * As a 'Hashed' function, the input value is hashed again before being used by each element function. */ @Categories({Category.collections}) @ThreadSafeMapper @@ -29,8 +31,8 @@ public class ListHashed implements LongFunction> { private final Hash hasher = new Hash(); @Example({ - "ListHashed(long->ToString(), long->WeightedStrings('text:1'))", - "Create a hash list of object values of each function output. ListHashed output ['2945182322382062539','text']" + "ListHashed(ToString(), WeightedStrings('text:1'))", + "Create a hash list of object values of each function output. ListHashed output ['2945182322382062539','text']" }) public ListHashed(LongFunction... funcs) { this.valueFuncs = Arrays.asList(funcs); @@ -46,9 +48,9 @@ public class ListHashed implements LongFunction> { this.size = building.size(); } - public ListHashed(Function... funcs) { + public ListHashed(Function... funcs) { List> building = new ArrayList<>(funcs.length); - for (Function func : funcs) { + for (Function func : funcs) { building.add(func::apply); } this.valueFuncs = building; diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSized.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSized.java index 236c7e190..509865b3f 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSized.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSized.java @@ -14,10 +14,14 @@ import java.util.function.LongToIntFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on at least two functions, the first function to - * determine the list functions size, and the remaining functions onwards to populate - * the list with object values till the end of the list size. + * Create a List from a long input based on a set of provided functions. + * + * As a 'Sized' function, the first argument is a function which determines the size of the resulting list. + * Additional functions provided are used to generate the elements to add to the collection. If the size + * is larger than the number of provided functions, the last provided function is used repeatedly as needed. + * + * As neither a 'Stepped' nor a 'Hashed' function, the input value used by each element function is the same + * as that provided to the outer function. */ @Categories({Category.collections}) @ThreadSafeMapper @@ -27,10 +31,10 @@ public class ListSized implements LongFunction> { private final LongToIntFunction sizeFunc; @Example({ - "ListSized(FixedValue(5), NumberNameToString(),NumberNameToString(), WeightedStrings('text:1'))", - "Create a sized list of object values of each function output. List size function will recursively call the last function till" + - "end of the list size functions", - "ListSized output ['one','one','text','text','text']" + "ListSized(FixedValue(5), NumberNameToString(),NumberNameToString(), WeightedStrings('text:1'))", + "Create a sized list of object values of each function output. List size function will recursively call the last function till" + + "end of the list size functions", + "ListSized output ['one','one','text','text','text']" }) public ListSized(LongToIntFunction sizeFunc, LongFunction... funcs) { this.sizeFunc = sizeFunc; @@ -46,9 +50,9 @@ public class ListSized implements LongFunction> { this.valueFuncs = building; } - public ListSized(LongToIntFunction sizeFunc, Function... funcs) { + public ListSized(LongToIntFunction sizeFunc, Function... funcs) { List> building = new ArrayList<>(funcs.length); - for (Function func : funcs) { + for (Function func : funcs) { building.add(func::apply); } this.sizeFunc = sizeFunc; diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedHashed.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedHashed.java index e81408ab8..ffda7c224 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedHashed.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedHashed.java @@ -15,10 +15,13 @@ import java.util.function.LongToIntFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on at least two functions, the first function to - * determine the list functions size, and the remaining functions onwards to populate - * the list with object values till the end of the list size. + * Create a List from a long input based on a set of provided functions. + * + * As a 'Sized' function, the first argument is a function which determines the size of the resulting list. + * Additional functions provided are used to generate the elements to add to the collection. If the size + * is larger than the number of provided functions, the last provided function is used repeatedly as needed. + * + * As a 'Hashed' function, the input value is hashed again before being used by each element function. */ @Categories({Category.collections}) @ThreadSafeMapper diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedStepped.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedStepped.java index 696f1ebf9..d463567a9 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedStepped.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListSizedStepped.java @@ -15,14 +15,13 @@ import java.util.function.LongToIntFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on two functions, the first to - * determine the list size, and the second to populate the list with - * object values. The input fed to the second function is incremented - * between elements. + * Create a List from a long input based on a set of provided functions. * - * To directly create Lists of Strings from the String version of the same - * mapping functions, simply use {@link StringList} instead. + * As a 'Sized' function, the first argument is a function which determines the size of the resulting list. + * Additional functions provided are used to generate the elements to add to the collection. If the size + * is larger than the number of provided functions, the last provided function is used repeatedly as needed. + * + * As a 'Stepped' function, the input value is incremented before being used by each element function. */ @Categories({Category.collections}) @ThreadSafeMapper diff --git a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListStepped.java b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListStepped.java index a4058273f..11e4d7564 100644 --- a/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListStepped.java +++ b/virtdata-lib-basics/src/main/java/io/nosqlbench/virtdata/library/basics/shared/from_long/to_collection/ListStepped.java @@ -14,14 +14,12 @@ import java.util.function.LongToIntFunction; import java.util.function.LongUnaryOperator; /** - * Create a {@code List} from a long input - * based on two functions, the first to - * determine the list size, and the second to populate the list with - * object values. The input fed to the second function is incremented - * between elements. + * Create a List from a long input based on a set of provided functions. * - * To directly create Lists of Strings from the String version of the same - * mapping functions, simply use {@link StringList} instead. + * As a 'Pair-wise' function, the size of the resulting collection is determined directly by the + * number of provided element functions. + * + * As a 'Stepped' function, the input value is incremented before being used by each element function. */ @Categories({Category.collections}) @ThreadSafeMapper