Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

version is 3.6.0 #378

Merged
merged 6 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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-SNAPSHOT</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) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you remove the code?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-SNAPSHOT</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 @@ -31,18 +32,26 @@ private CommonUtils() {
* Throws an {@link IllegalArgumentException} with the specified message if the
* specified input is false.
*
* @param condition A condition to test.
* @param message The error message to include in the
* {@code IllegalArgumentException} if {@code condition} is
* false.
* @param condition A condition to test.
* @param messageSupplier The error message to include in the
* {@code IllegalArgumentException} if {@code condition}
* is false.
* @throws IllegalArgumentException if {@code condition} is false.
*/
public static void checkArgument(boolean condition, String message) {

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor: with the new overloaded checkArgument definition, we could change this implementation to:

public static void checkArgument(boolean condition, String message) {
    checkArgument(condition, () => 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