Search in sources :

Example 16 with RevTreeBuilder

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

the class WriteBackTest method testSiblingsNested.

@Test
public void testSiblingsNested() {
    RevTreeBuilder oldRoot = new RevTreeBuilder(odb);
    RevTree tree1 = new RevTreeBuilder(odb).put(blob("blob")).build();
    RevTree tree2 = new RevTreeBuilder(odb).put(blob("blob")).build();
    ObjectId newRootId1 = writeBack.setAncestor(oldRoot).setChildPath("subtree1/level2").setTree(tree1).call();
    ObjectId newRootId2 = writeBack.setAncestor(odb.getTree(newRootId1).builder(odb)).setChildPath("subtree2/level2/level3").setTree(tree2).call();
    // created the intermediate tree node?
    DepthSearch depthSearch = new DepthSearch(odb);
    assertTrue(depthSearch.find(newRootId2, "subtree1").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree1/level2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree1/level2/blob").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3").isPresent());
    assertTrue(depthSearch.find(newRootId2, "subtree2/level2/level3/blob").isPresent());
}
Also used : DepthSearch(org.locationtech.geogig.repository.DepthSearch) ObjectId(org.locationtech.geogig.api.ObjectId) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 17 with RevTreeBuilder

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

the class DiffCountConsumerTest method testChildrenChildrenNestedTrees.

@Test
public void testChildrenChildrenNestedTrees() {
    RevTreeBuilder rootBuilder = new RevTreeBuilder(odb, childrenFeatureTypesTree);
    childTree1.put(featureRef("tree1", 1000));
    createFeatureTypesTree(rootBuilder, "tree1", childTree1);
    RevTree newRoot = rootBuilder.build();
    assertEquals(1, count(childrenFeatureTypesTree, newRoot).featureCount());
    childTree2.remove("tree2/2");
    createFeatureTypesTree(rootBuilder, "tree2", childTree2);
    newRoot = rootBuilder.build();
    assertEquals(2, count(childrenFeatureTypesTree, newRoot).featureCount());
    childTree2.put(Node.create("tree2/1", FAKE_FEATURE_ID_CHANGED, ObjectId.NULL, TYPE.FEATURE, null));
    createFeatureTypesTree(rootBuilder, "tree2", childTree2);
    newRoot = rootBuilder.build();
    assertEquals(3, count(childrenFeatureTypesTree, newRoot).featureCount());
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 18 with RevTreeBuilder

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

the class DiffCountConsumerTest method testBucketChildrenDeeperBuckets.

@Test
public void testBucketChildrenDeeperBuckets() {
    final RevTree deepTree = createFeaturesTree("", 20000 + RevTree.NORMALIZED_SIZE_LIMIT).build();
    // sanity check
    assertTrue(deepTree.buckets().isPresent());
    {
        // sanity check to ensure we're testing with a tree with depth > 1 (i.e. at least two
        // levels of buckets)
        final int maxDepth = depth(deepTree, 0);
        assertTrue(maxDepth > 1);
    }
    RevTreeBuilder builder = new RevTreeBuilder(odb, deepTree);
    {
        final int count = (int) (deepTree.size() - RevTree.NORMALIZED_SIZE_LIMIT);
        for (int i = 0; i < count; i++) {
            String path = String.valueOf(i);
            builder.remove(path);
        }
    }
    RevTree changed = builder.build();
    assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, changed.size());
    // sanity check
    assertTrue(changed.features().isPresent());
    assertFalse(changed.buckets().isPresent());
    final long expected = deepTree.size() - changed.size();
    assertEquals(expected, count(deepTree, changed).featureCount());
    assertEquals(expected, count(changed, deepTree).featureCount());
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 19 with RevTreeBuilder

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

the class DiffCountConsumerTest method testBucketChildren.

@Test
public void testBucketChildren() {
    RevTreeBuilder builder = new RevTreeBuilder(odb, bucketsFeatureTree);
    RevTree changed;
    for (int i = 0; i < RevTree.NORMALIZED_SIZE_LIMIT; i++) {
        builder.remove(String.valueOf(i));
    }
    changed = builder.build();
    assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, changed.size());
    assertFalse(changed.buckets().isPresent());
    assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, count(bucketsFeatureTree, changed).featureCount());
    assertEquals(RevTree.NORMALIZED_SIZE_LIMIT, count(changed, bucketsFeatureTree).featureCount());
}
Also used : RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 20 with RevTreeBuilder

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

the class DepthTreeIteratorTest method testRecursiveTreesOnly.

@Test
public void testRecursiveTreesOnly() {
    assertEquals(0, list(emptyTree, Strategy.RECURSIVE_TREES_ONLY).size());
    assertEquals(0, list(featuresLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
    assertEquals(treesLeafTree.numTrees(), list(treesLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
    assertEquals(mixedLeafTree.numTrees(), list(mixedLeafTree, Strategy.RECURSIVE_TREES_ONLY).size());
    assertEquals(0, list(featuresBucketsTree, Strategy.RECURSIVE_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();
    Stopwatch sw = Stopwatch.createStarted();
    assertEquals(numSubTrees, list(mixedBucketsTree, Strategy.RECURSIVE_TREES_ONLY).size());
    sw.stop();
    System.err.println(sw);
}
Also used : Stopwatch(com.google.common.base.Stopwatch) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

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