Search in sources :

Example 76 with RevTree

use of org.locationtech.geogig.api.RevTree 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 77 with RevTree

use of org.locationtech.geogig.api.RevTree 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 78 with RevTree

use of org.locationtech.geogig.api.RevTree 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)

Example 79 with RevTree

use of org.locationtech.geogig.api.RevTree 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 80 with RevTree

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

the class PostOrderDiffWalkTest method testSameRootTree.

@Test
public void testSameRootTree() {
    RevTree left = createFeaturesTree(leftSource, "f", 10).build();
    RevTree right = left;
    PostOrderDiffWalk visitor = new PostOrderDiffWalk(left, right, leftSource, rightSource);
    Consumer consumer = mock(Consumer.class);
    visitor.walk(consumer);
    verifyNoMoreInteractions(consumer);
}
Also used : Consumer(org.locationtech.geogig.api.plumbing.diff.PostOrderDiffWalk.Consumer) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Aggregations

RevTree (org.locationtech.geogig.api.RevTree)214 Test (org.junit.Test)120 ObjectId (org.locationtech.geogig.api.ObjectId)91 NodeRef (org.locationtech.geogig.api.NodeRef)73 Node (org.locationtech.geogig.api.Node)56 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)47 RevCommit (org.locationtech.geogig.api.RevCommit)36 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)29 FindTreeChild (org.locationtech.geogig.api.plumbing.FindTreeChild)27 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)24 RevObject (org.locationtech.geogig.api.RevObject)21 RevFeature (org.locationtech.geogig.api.RevFeature)18 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)18 Bucket (org.locationtech.geogig.api.Bucket)17 TreeTestSupport.featureNode (org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode)17 File (java.io.File)16 Ref (org.locationtech.geogig.api.Ref)16 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)15 GeoGIG (org.locationtech.geogig.api.GeoGIG)14 OSMImportOp (org.locationtech.geogig.osm.internal.OSMImportOp)14