mirror of
https://github.com/nosqlbench/nosqlbench.git
synced 2025-02-25 18:55:28 -06:00
Incremental name changes; use of builder; fix in normalize
This commit is contained in:
@@ -29,7 +29,7 @@ import java.util.function.Function;
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories(Category.experimental)
|
||||
public class NormalizeDoubleVectorList implements Function<List<Double>,List<Double>> {
|
||||
public class NormalizeDoubleListVector implements Function<List<Double>,List<Double>> {
|
||||
@Override
|
||||
public List<Double> apply(List<Double> doubles) {
|
||||
ArrayList<Double> unit = new ArrayList<>(doubles.size());
|
||||
@@ -29,7 +29,7 @@ import java.util.function.Function;
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories(Category.experimental)
|
||||
public class NormalizeFloatVectorList implements Function<List<Float>,List<Float>> {
|
||||
public class NormalizeFloatListVector implements Function<List<Float>,List<Float>> {
|
||||
@Override
|
||||
public List<Float> apply(List<Float> floats) {
|
||||
ArrayList<Float> unit = new ArrayList<>(floats.size());
|
||||
@@ -29,9 +29,9 @@ import java.util.function.Function;
|
||||
*/
|
||||
@ThreadSafeMapper
|
||||
@Categories(Category.experimental)
|
||||
public class NormalizeVector implements Function<List,List> {
|
||||
private final NormalizeDoubleVectorList ndv = new NormalizeDoubleVectorList();
|
||||
private final NormalizeFloatVectorList nfv = new NormalizeFloatVectorList();
|
||||
public class NormalizeListVector implements Function<List,List> {
|
||||
private final NormalizeDoubleListVector ndv = new NormalizeDoubleListVector();
|
||||
private final NormalizeFloatListVector nfv = new NormalizeFloatListVector();
|
||||
|
||||
@Override
|
||||
public List apply(List list) {
|
||||
@@ -39,7 +39,7 @@ public class NormalizeVector implements Function<List,List> {
|
||||
return List.of();
|
||||
} else if (list.get(0) instanceof Float) {
|
||||
return nfv.apply(list);
|
||||
} else if (list.get(1) instanceof Double) {
|
||||
} else if (list.get(0) instanceof Double) {
|
||||
return ndv.apply(list);
|
||||
} else {
|
||||
throw new RuntimeException("Only Doubles and Floats are recognized.");
|
||||
@@ -27,7 +27,7 @@ public class ToNormalizedVectorTest {
|
||||
|
||||
@Test
|
||||
public void testNormalizeBasic() {
|
||||
NormalizeDoubleVectorList normalize = new NormalizeDoubleVectorList();
|
||||
NormalizeDoubleListVector normalize = new NormalizeDoubleListVector();
|
||||
List<Double> normalized = normalize.apply(List.of(1.0d));
|
||||
for (int i = 0; i < normalized.size(); i++) {
|
||||
assertThat(normalized.get(i)).isCloseTo(1.0d, Offset.offset(0.00001d));
|
||||
|
||||
Reference in New Issue
Block a user