Search in sources :

Example 1 with SequentialForestTraversalExecutor

use of com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor in project random-cut-forest-by-aws by aws.

the class RandomCutForest method initExecutors.

protected <PointReference, Point> void initExecutors(IStateCoordinator<PointReference, Point> updateCoordinator, ComponentList<PointReference, Point> components) {
    if (parallelExecutionEnabled) {
        traversalExecutor = new ParallelForestTraversalExecutor(components, threadPoolSize);
        updateExecutor = new ParallelForestUpdateExecutor<>(updateCoordinator, components, threadPoolSize);
    } else {
        traversalExecutor = new SequentialForestTraversalExecutor(components);
        updateExecutor = new SequentialForestUpdateExecutor<>(updateCoordinator, components);
    }
}
Also used : ParallelForestTraversalExecutor(com.amazon.randomcutforest.executor.ParallelForestTraversalExecutor) SequentialForestTraversalExecutor(com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor)

Example 2 with SequentialForestTraversalExecutor

use of com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor in project random-cut-forest-by-aws by aws.

the class RandomCutForestTest method setUp.

@BeforeEach
public void setUp() {
    dimensions = 2;
    sampleSize = 256;
    numberOfTrees = 10;
    components = new ComponentList<>();
    for (int i = 0; i < numberOfTrees; i++) {
        CompactSampler sampler = mock(CompactSampler.class);
        when(sampler.getCapacity()).thenReturn(sampleSize);
        RandomCutTree tree = mock(RandomCutTree.class);
        components.add(spy(new SamplerPlusTree<>(sampler, tree)));
    }
    updateCoordinator = spy(new PointStoreCoordinator<>(new PointStore.Builder().dimensions(2).capacity(1).build()));
    traversalExecutor = spy(new SequentialForestTraversalExecutor(components));
    updateExecutor = spy(new SequentialForestUpdateExecutor<>(updateCoordinator, components));
    RandomCutForest.Builder<?> builder = RandomCutForest.builder().dimensions(dimensions).numberOfTrees(numberOfTrees).sampleSize(sampleSize);
    forest = spy(new RandomCutForest(builder, updateCoordinator, components, builder.getRandom()));
    Whitebox.setInternalState(forest, "traversalExecutor", traversalExecutor);
    Whitebox.setInternalState(forest, "updateExecutor", updateExecutor);
}
Also used : RandomCutTree(com.amazon.randomcutforest.tree.RandomCutTree) SequentialForestUpdateExecutor(com.amazon.randomcutforest.executor.SequentialForestUpdateExecutor) CompactSampler(com.amazon.randomcutforest.sampler.CompactSampler) SequentialForestTraversalExecutor(com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor) ShingleBuilder(com.amazon.randomcutforest.util.ShingleBuilder) SamplerPlusTree(com.amazon.randomcutforest.executor.SamplerPlusTree) PointStoreCoordinator(com.amazon.randomcutforest.executor.PointStoreCoordinator) BeforeEach(org.junit.jupiter.api.BeforeEach)

Aggregations

SequentialForestTraversalExecutor (com.amazon.randomcutforest.executor.SequentialForestTraversalExecutor)2 ParallelForestTraversalExecutor (com.amazon.randomcutforest.executor.ParallelForestTraversalExecutor)1 PointStoreCoordinator (com.amazon.randomcutforest.executor.PointStoreCoordinator)1 SamplerPlusTree (com.amazon.randomcutforest.executor.SamplerPlusTree)1 SequentialForestUpdateExecutor (com.amazon.randomcutforest.executor.SequentialForestUpdateExecutor)1 CompactSampler (com.amazon.randomcutforest.sampler.CompactSampler)1 RandomCutTree (com.amazon.randomcutforest.tree.RandomCutTree)1 ShingleBuilder (com.amazon.randomcutforest.util.ShingleBuilder)1 BeforeEach (org.junit.jupiter.api.BeforeEach)1