Search in sources :

Example 21 with RevTree

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

the class PreOrderDiffWalkTest method testLeafBucketSimple.

@Test
public void testLeafBucketSimple() {
    final int rightsize = 1 + RevTree.NORMALIZED_SIZE_LIMIT;
    RevTree left = createFeaturesTree(leftSource, "f", 1).build();
    RevTree right = createFeaturesTree(rightSource, "f", rightsize).build();
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    // consume all
    when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
    when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
    visitor.walk(consumer);
    // there's only the root tree
    verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
    // there's only one feature on the right tree, so all right trees features fall on a single
    // bucket
    final int leftBucketCount = right.buckets().get().size();
    final int expectedBucketCalls = leftBucketCount - 1;
    verify(consumer, times(expectedBucketCalls)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(rightsize - 1)).feature((Node) isNull(), any(Node.class));
    verify(consumer, times(expectedBucketCalls)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
    verifyNoMoreInteractions(consumer);
}
Also used : Bucket(org.locationtech.geogig.api.Bucket) Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 22 with RevTree

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

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

the class PreOrderDiffWalkTest method testBucketLeafSeveral.

@Test
public void testBucketLeafSeveral() {
    final int leftsize = 1 + RevTree.NORMALIZED_SIZE_LIMIT;
    RevTree left = createFeaturesTree(leftSource, "f", leftsize).build();
    RevTree right = createFeaturesTree(rightSource, "f", 1).build();
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    // consume all
    when(consumer.tree(any(Node.class), any(Node.class))).thenReturn(true);
    when(consumer.bucket(anyInt(), anyInt(), any(Bucket.class), any(Bucket.class))).thenReturn(true);
    visitor.walk(consumer);
    // there's only the root tree
    verify(consumer, times(1)).tree(any(Node.class), any(Node.class));
    // there's only one feature on the right tree, so all right trees features fall on a single
    // bucket
    final int leftBucketCount = left.buckets().get().size();
    final int expectedBucketCalls = leftBucketCount - 1;
    verify(consumer, times(expectedBucketCalls)).bucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(leftsize - 1)).feature(any(Node.class), (Node) isNull());
    verify(consumer, times(expectedBucketCalls)).endBucket(anyInt(), eq(0), any(Bucket.class), any(Bucket.class));
    verify(consumer, times(1)).endTree(any(Node.class), any(Node.class));
    verifyNoMoreInteractions(consumer);
}
Also used : Bucket(org.locationtech.geogig.api.Bucket) Node(org.locationtech.geogig.api.Node) TreeTestSupport.featureNode(org.locationtech.geogig.api.plumbing.diff.TreeTestSupport.featureNode) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 24 with RevTree

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

the class PreOrderDiffWalkTest method testLeafBucketOneLevelDepth.

@Test
public void testLeafBucketOneLevelDepth() {
    final int leftsize = RevTree.NORMALIZED_SIZE_LIMIT;
    final int rightsize = 2 * RevTree.NORMALIZED_SIZE_LIMIT;
    final int overlapCount = 100;
    RevTree right = createFeaturesTree(rightSource, "f", rightsize).build();
    assertDepth(right, rightSource, 1);
    testLeafBucketDeeper(leftsize, right, overlapCount);
}
Also used : RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 25 with RevTree

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

the class PreOrderDiffWalkTest method testSameRootTree.

@Test
public void testSameRootTree() {
    RevTree left = createFeaturesTree(leftSource, "f", 10).build();
    RevTree right = left;
    PreOrderDiffWalk visitor = new PreOrderDiffWalk(left, right, leftSource, rightSource);
    visitor.walk(consumer);
    verifyNoMoreInteractions(consumer);
}
Also used : 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