Skip to content

Commit

Permalink
version is 3.6.0 (#378)
Browse files Browse the repository at this point in the history
* version is 3.6

* version is 3.6.0-SNAPSHOT

* lazy check argument

* fix and cleanup

* issue 381

* javadocs
  • Loading branch information
sudiptoguha authored Apr 4, 2023
1 parent cffd221 commit 3765c20
Show file tree
Hide file tree
Showing 24 changed files with 812 additions and 766 deletions.
2 changes: 1 addition & 1 deletion Java/benchmark/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>software.amazon.randomcutforest</groupId>
<artifactId>randomcutforest-parent</artifactId>
<version>3.5.1</version>
<version>3.6.0</version>
</parent>

<artifactId>randomcutforest-benchmark</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.List;
import java.util.Random;

import org.github.jamm.MemoryMeter;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
Expand Down Expand Up @@ -131,10 +130,6 @@ public RandomCutForest scoreAndUpdate(BenchmarkState state, Blackhole blackhole)
}

blackhole.consume(score);
if (!forest.parallelExecutionEnabled) {
MemoryMeter meter = new MemoryMeter();
System.out.println(" forest size " + meter.measureDeep(forest));
}
return forest;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import java.util.List;
import java.util.Random;

import org.github.jamm.MemoryMeter;
import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
Expand Down Expand Up @@ -130,10 +129,6 @@ public RandomCutForest scoreAndUpdate(BenchmarkState state, Blackhole blackhole)
}

blackhole.consume(score);
if (!forest.parallelExecutionEnabled) {
MemoryMeter meter = new MemoryMeter();
System.out.println(" forest size " + meter.measureDeep(forest));
}
return forest;
}

Expand Down
2 changes: 1 addition & 1 deletion Java/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>software.amazon.randomcutforest</groupId>
<artifactId>randomcutforest-parent</artifactId>
<version>3.5.1</version>
<version>3.6.0</version>
</parent>

<artifactId>randomcutforest-core</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.amazon.randomcutforest;

import java.util.Objects;
import java.util.function.Supplier;

import com.amazon.randomcutforest.tree.IBoundingBoxView;

Expand All @@ -38,11 +39,19 @@ private CommonUtils() {
* @throws IllegalArgumentException if {@code condition} is false.
*/
public static void checkArgument(boolean condition, String message) {

if (!condition) {
throw new IllegalArgumentException(message);
}
}

// a lazy equivalent of the above, which avoids parameter evaluation
public static void checkArgument(boolean condition, Supplier<String> messageSupplier) {
if (!condition) {
throw new IllegalArgumentException(messageSupplier.get());
}
}

/**
* Throws an {@link IllegalStateException} with the specified message if the
* specified input is false.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,9 @@ public RandomCutForest singlePrecisionForest(RandomCutForest.Builder<?> builder,
tree = extTrees.get(i);
} else if (treeStates != null) {
tree = treeMapper.toModel(treeStates.get(i), context, random.nextLong());
sampler.getSample().forEach(s -> tree.addPoint(s.getValue(), s.getSequenceIndex()));
sampler.getSample().forEach(s -> tree.addPointToPartialTree(s.getValue(), s.getSequenceIndex()));
tree.setConfig(Config.BOUNDING_BOX_CACHE_FRACTION, treeStates.get(i).getBoundingBoxCacheFraction());
tree.validateAndReconstruct();
} else {
// using boundingBoxCahce for the new tree
tree = new RandomCutTree.Builder().capacity(state.getSampleSize()).randomSeed(random.nextLong())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@ public AbstractNodeStore toModel(NodeStoreState state, CompactRandomCutTreeConte
}
// note boundingBoxCache is not set deliberately
return AbstractNodeStore.builder().capacity(capacity).useRoot(root).leftIndex(leftIndex).rightIndex(rightIndex)
.cutDimension(cutDimension).cutValues(cutValue)
.dimensions(compactRandomCutTreeContext.getPointStore().getDimensions())
.pointStoreView(compactRandomCutTreeContext.getPointStore()).build();
.cutDimension(cutDimension).cutValues(cutValue).dimension(compactRandomCutTreeContext.getDimension())
.build();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
@Data
public class CompactRandomCutTreeContext {
private int maxSize;
private int dimension;
private IPointStore<?> pointStore;
private Precision precision;
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,12 @@ public class RandomCutTreeMapper
@Override
public RandomCutTree toModel(CompactRandomCutTreeState state, CompactRandomCutTreeContext context, long seed) {

int dimension = (state.getDimensions() != 0) ? state.getDimensions() : context.getPointStore().getDimensions();
context.setDimension(dimension);
AbstractNodeStoreMapper nodeStoreMapper = new AbstractNodeStoreMapper();
nodeStoreMapper.setRoot(state.getRoot());
AbstractNodeStore nodeStore = nodeStoreMapper.toModel(state.getNodeStoreState(), context);

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

0 comments on commit 3765c20

Please sign in to comment.