Search in sources :

Example 21 with RevTreeBuilder

use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.

the class DepthTreeIteratorTest method testTrees.

@Test
public void testTrees() {
    assertEquals(0, list(emptyTree, Strategy.TREES_ONLY).size());
    assertEquals(0, list(featuresLeafTree, Strategy.TREES_ONLY).size());
    assertEquals(100, list(treesLeafTree, Strategy.TREES_ONLY).size());
    assertEquals(10, list(mixedLeafTree, Strategy.TREES_ONLY).size());
    assertEquals(0, list(featuresBucketsTree, Strategy.TREES_ONLY).size());
    int numSubTrees = RevTree.NORMALIZED_SIZE_LIMIT + 1;
    int featuresPerTree = RevTree.NORMALIZED_SIZE_LIMIT + 1;
    RevTreeBuilder builder = createTreesTree(source, numSubTrees, featuresPerTree, metadataId);
    for (int i = 0; i < 25000; i++) {
        builder.put(featureNode("f", i));
    }
    RevTree mixedBucketsTree = builder.build();
    assertEquals(numSubTrees, list(mixedBucketsTree, Strategy.TREES_ONLY).size());
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 22 with RevTreeBuilder

use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.

the class RevTreeBuilderTest method testNodeOrderPassSplitThreshold.

@Test
public void testNodeOrderPassSplitThreshold() {
    final int splitThreshold = RevTree.NORMALIZED_SIZE_LIMIT;
    List<Node> expectedOrder = nodes(splitThreshold + 1);
    Collections.sort(expectedOrder, new NodeStorageOrder());
    final List<Node> flat = expectedOrder.subList(0, splitThreshold);
    RevTreeBuilder flatTreeBuilder = new RevTreeBuilder(odb);
    RevTreeBuilder bucketTreeBuilder = new RevTreeBuilder(odb);
    for (Node n : flat) {
        flatTreeBuilder.put(n);
        bucketTreeBuilder.put(n);
    }
    bucketTreeBuilder.put(expectedOrder.get(expectedOrder.size() - 1));
    RevTree flatTree = flatTreeBuilder.build();
    RevTree bucketTree = bucketTreeBuilder.build();
    assertFalse(flatTree.buckets().isPresent());
    assertTrue(bucketTree.buckets().isPresent());
    odb.put(flatTree);
    odb.put(bucketTree);
    List<Node> flatNodes = lstree(flatTree);
    assertEquals(flat, flatNodes);
    List<Node> splitNodes = lstree(bucketTree);
    assertEquals(expectedOrder, splitNodes);
}
Also used : Node(org.locationtech.geogig.api.Node) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 23 with RevTreeBuilder

use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.

the class DepthSearchTest method setUp.

@Before
public void setUp() throws IOException {
    File envHome = tempFolder.getRoot();
    Platform testPlatform = new TestPlatform(envHome);
    Context injector = Guice.createInjector(Modules.override(new GeogigModule()).with(new MemoryModule(testPlatform))).getInstance(Context.class);
    fakeGeogig = new GeoGIG(injector);
    Repository fakeRepo = fakeGeogig.getOrCreateRepository();
    odb = fakeRepo.objectDatabase();
    search = new DepthSearch(odb);
    RevTreeBuilder root = new RevTreeBuilder(odb);
    root = addTree(root, "path/to/tree1", "node11", "node12", "node13");
    root = addTree(root, "path/to/tree2", "node21", "node22", "node23");
    root = addTree(root, "tree3", "node31", "node32", "node33");
    RevTree rootTree = root.build();
    odb.put(rootTree);
    rootTreeId = rootTree.getId();
}
Also used : Context(org.locationtech.geogig.api.Context) TestPlatform(org.locationtech.geogig.api.TestPlatform) Platform(org.locationtech.geogig.api.Platform) TestPlatform(org.locationtech.geogig.api.TestPlatform) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) File(java.io.File) GeogigModule(org.locationtech.geogig.di.GeogigModule) MemoryModule(org.locationtech.geogig.api.MemoryModule) GeoGIG(org.locationtech.geogig.api.GeoGIG) RevTree(org.locationtech.geogig.api.RevTree) Before(org.junit.Before)

Example 24 with RevTreeBuilder

use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.

the class RevTreeBuilderPerformanceTest method testInsertUnordered.

@Test
public void testInsertUnordered() {
    System.err.println("testInsertUnordered...");
    createTree(nodes, new RevTreeBuilder(odb), true);
// createTree(nodes, new RevTreeBuilder(odb), true);
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) Test(org.junit.Test)

Example 25 with RevTreeBuilder

use of org.locationtech.geogig.api.RevTreeBuilder in project GeoGig by boundlessgeo.

the class RevTreeBuilderPerformanceTest method testInsertPartitioned.

private void testInsertPartitioned(int partitionSize) {
    UnmodifiableIterator<List<Node>> partitions = Iterators.partition(nodes.iterator(), partitionSize);
    RevTreeBuilder builder = new RevTreeBuilder(odb);
    Stopwatch sw = Stopwatch.createStarted();
    while (partitions.hasNext()) {
        List<Node> partition = new ArrayList<Node>(partitions.next());
        Collections.sort(partition, new NodeStorageOrder());
        createTree(partition, builder, false);
    }
    System.err.println("Calling RevTreeBuilder.build()...");
    builder.build();
    sw.stop();
    System.err.printf("-- Created tree with %d sorted partitioned size in %s\n", partitionSize, sw);
}
Also used : Node(org.locationtech.geogig.api.Node) Stopwatch(com.google.common.base.Stopwatch) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) NodeStorageOrder(org.locationtech.geogig.storage.NodeStorageOrder)

Aggregations

RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)58 RevTree (org.locationtech.geogig.api.RevTree)47 ObjectId (org.locationtech.geogig.api.ObjectId)27 Test (org.junit.Test)25 NodeRef (org.locationtech.geogig.api.NodeRef)24 Node (org.locationtech.geogig.api.Node)14 DepthSearch (org.locationtech.geogig.repository.DepthSearch)6 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)5 Stopwatch (com.google.common.base.Stopwatch)4 Envelope (com.vividsolutions.jts.geom.Envelope)4 Map (java.util.Map)4 Context (org.locationtech.geogig.api.Context)4 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)4 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)4 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)4 Before (org.junit.Before)3 FindOrCreateSubtree (org.locationtech.geogig.api.plumbing.FindOrCreateSubtree)3 WriteBack (org.locationtech.geogig.api.plumbing.WriteBack)3 DepthTreeIterator (org.locationtech.geogig.api.plumbing.diff.DepthTreeIterator)3 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)3