Skip to content

Commit 3765c20

Browse files
authored
version is 3.6.0 (#378)
* version is 3.6 * version is 3.6.0-SNAPSHOT * lazy check argument * fix and cleanup * issue 381 * javadocs
1 parent cffd221 commit 3765c20

24 files changed

+812
-766
lines changed

Java/benchmark/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>software.amazon.randomcutforest</groupId>
88
<artifactId>randomcutforest-parent</artifactId>
9-
<version>3.5.1</version>
9+
<version>3.6.0</version>
1010
</parent>
1111

1212
<artifactId>randomcutforest-benchmark</artifactId>

Java/benchmark/src/main/java/com/amazon/randomcutforest/RandomCutForestBenchmark.java

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919
import java.util.Random;
2020

21-
import org.github.jamm.MemoryMeter;
2221
import org.openjdk.jmh.annotations.Benchmark;
2322
import org.openjdk.jmh.annotations.Fork;
2423
import org.openjdk.jmh.annotations.Level;
@@ -131,10 +130,6 @@ public RandomCutForest scoreAndUpdate(BenchmarkState state, Blackhole blackhole)
131130
}
132131

133132
blackhole.consume(score);
134-
if (!forest.parallelExecutionEnabled) {
135-
MemoryMeter meter = new MemoryMeter();
136-
System.out.println(" forest size " + meter.measureDeep(forest));
137-
}
138133
return forest;
139134
}
140135

Java/benchmark/src/main/java/com/amazon/randomcutforest/RandomCutForestShingledBenchmark.java

-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import java.util.List;
1919
import java.util.Random;
2020

21-
import org.github.jamm.MemoryMeter;
2221
import org.openjdk.jmh.annotations.Benchmark;
2322
import org.openjdk.jmh.annotations.Fork;
2423
import org.openjdk.jmh.annotations.Level;
@@ -130,10 +129,6 @@ public RandomCutForest scoreAndUpdate(BenchmarkState state, Blackhole blackhole)
130129
}
131130

132131
blackhole.consume(score);
133-
if (!forest.parallelExecutionEnabled) {
134-
MemoryMeter meter = new MemoryMeter();
135-
System.out.println(" forest size " + meter.measureDeep(forest));
136-
}
137132
return forest;
138133
}
139134

Java/core/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<parent>
77
<groupId>software.amazon.randomcutforest</groupId>
88
<artifactId>randomcutforest-parent</artifactId>
9-
<version>3.5.1</version>
9+
<version>3.6.0</version>
1010
</parent>
1111

1212
<artifactId>randomcutforest-core</artifactId>

Java/core/src/main/java/com/amazon/randomcutforest/CommonUtils.java

+9
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package com.amazon.randomcutforest;
1717

1818
import java.util.Objects;
19+
import java.util.function.Supplier;
1920

2021
import com.amazon.randomcutforest.tree.IBoundingBoxView;
2122

@@ -38,11 +39,19 @@ private CommonUtils() {
3839
* @throws IllegalArgumentException if {@code condition} is false.
3940
*/
4041
public static void checkArgument(boolean condition, String message) {
42+
4143
if (!condition) {
4244
throw new IllegalArgumentException(message);
4345
}
4446
}
4547

48+
// a lazy equivalent of the above, which avoids parameter evaluation
49+
public static void checkArgument(boolean condition, Supplier<String> messageSupplier) {
50+
if (!condition) {
51+
throw new IllegalArgumentException(messageSupplier.get());
52+
}
53+
}
54+
4655
/**
4756
* Throws an {@link IllegalStateException} with the specified message if the
4857
* specified input is false.

Java/core/src/main/java/com/amazon/randomcutforest/state/RandomCutForestMapper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -336,8 +336,9 @@ public RandomCutForest singlePrecisionForest(RandomCutForest.Builder<?> builder,
336336
tree = extTrees.get(i);
337337
} else if (treeStates != null) {
338338
tree = treeMapper.toModel(treeStates.get(i), context, random.nextLong());
339-
sampler.getSample().forEach(s -> tree.addPoint(s.getValue(), s.getSequenceIndex()));
339+
sampler.getSample().forEach(s -> tree.addPointToPartialTree(s.getValue(), s.getSequenceIndex()));
340340
tree.setConfig(Config.BOUNDING_BOX_CACHE_FRACTION, treeStates.get(i).getBoundingBoxCacheFraction());
341+
tree.validateAndReconstruct();
341342
} else {
342343
// using boundingBoxCahce for the new tree
343344
tree = new RandomCutTree.Builder().capacity(state.getSampleSize()).randomSeed(random.nextLong())

Java/core/src/main/java/com/amazon/randomcutforest/state/tree/AbstractNodeStoreMapper.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,8 @@ public AbstractNodeStore toModel(NodeStoreState state, CompactRandomCutTreeConte
5959
}
6060
// note boundingBoxCache is not set deliberately
6161
return AbstractNodeStore.builder().capacity(capacity).useRoot(root).leftIndex(leftIndex).rightIndex(rightIndex)
62-
.cutDimension(cutDimension).cutValues(cutValue)
63-
.dimensions(compactRandomCutTreeContext.getPointStore().getDimensions())
64-
.pointStoreView(compactRandomCutTreeContext.getPointStore()).build();
62+
.cutDimension(cutDimension).cutValues(cutValue).dimension(compactRandomCutTreeContext.getDimension())
63+
.build();
6564
}
6665

6766
@Override

Java/core/src/main/java/com/amazon/randomcutforest/state/tree/CompactRandomCutTreeContext.java

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
@Data
2424
public class CompactRandomCutTreeContext {
2525
private int maxSize;
26+
private int dimension;
2627
private IPointStore<?> pointStore;
2728
private Precision precision;
2829
}

Java/core/src/main/java/com/amazon/randomcutforest/state/tree/RandomCutTreeMapper.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,12 @@ public class RandomCutTreeMapper
3333
@Override
3434
public RandomCutTree toModel(CompactRandomCutTreeState state, CompactRandomCutTreeContext context, long seed) {
3535

36+
int dimension = (state.getDimensions() != 0) ? state.getDimensions() : context.getPointStore().getDimensions();
37+
context.setDimension(dimension);
3638
AbstractNodeStoreMapper nodeStoreMapper = new AbstractNodeStoreMapper();
3739
nodeStoreMapper.setRoot(state.getRoot());
3840
AbstractNodeStore nodeStore = nodeStoreMapper.toModel(state.getNodeStoreState(), context);
3941

40-
int dimension = (state.getDimensions() != 0) ? state.getDimensions() : context.getPointStore().getDimensions();
4142
// boundingBoxcache is not set deliberately;
4243
// it should be set after the partial tree is complete
4344
// likewise all the leaves, including the root, should be set to

0 commit comments

Comments
 (0)