Search in sources :

Example 66 with ObjectId

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

the class SquashOpTest method testSquashWithMergeCommit.

@Test
public void testSquashWithMergeCommit() throws Exception {
    // Try to squash the commits marked (*) in this history
    // o
    // |
    // o - Points 1 added
    // |\
    // | o - branch1 - Points 2 added
    // | |
    // o | - Points 3 added*
    // | |
    // o | - Lines 1 added*
    // |/
    // o - master - HEAD - Merge commit*
    insertAndAdd(points1);
    final RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
    geogig.command(BranchCreateOp.class).setAutoCheckout(true).setName("branch1").call();
    insertAndAdd(points2);
    final RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for " + idP2).call();
    geogig.command(CheckoutOp.class).setSource("master").call();
    insertAndAdd(points3);
    final RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for " + idP3).call();
    insertAndAdd(lines1);
    @SuppressWarnings("unused") final RevCommit c4 = geogig.command(CommitOp.class).setMessage("commit for " + idL1).call();
    Ref branch1 = geogig.command(RefParse.class).setName("branch1").call().get();
    MergeReport mergeReport = geogig.command(MergeOp.class).addCommit(Suppliers.ofInstance(branch1.getObjectId())).setMessage("My merge message.").call();
    geogig.command(SquashOp.class).setSince(c3).setUntil(mergeReport.getMergeCommit()).setMessage("Squashed").call();
    ArrayList<RevCommit> log = Lists.newArrayList(geogig.command(LogOp.class).setFirstParentOnly(true).call());
    assertEquals(2, log.size());
    ImmutableList<ObjectId> parents = log.get(0).getParentIds();
    assertEquals(c1.getId(), parents.get(0));
    assertEquals(c2.getId(), parents.get(1));
}
Also used : MergeReport(org.locationtech.geogig.api.porcelain.MergeOp.MergeReport) Ref(org.locationtech.geogig.api.Ref) BranchCreateOp(org.locationtech.geogig.api.porcelain.BranchCreateOp) ObjectId(org.locationtech.geogig.api.ObjectId) LogOp(org.locationtech.geogig.api.porcelain.LogOp) RefParse(org.locationtech.geogig.api.plumbing.RefParse) MergeOp(org.locationtech.geogig.api.porcelain.MergeOp) RevCommit(org.locationtech.geogig.api.RevCommit) Test(org.junit.Test)

Example 67 with ObjectId

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

the class RevTreeBuilderTest method testPutIterate.

@Test
public void testPutIterate() throws Exception {
    final int numEntries = 1000 * 100;
    ObjectId treeId;
    Stopwatch sw;
    sw = Stopwatch.createStarted();
    treeId = createAndSaveTree(numEntries, true);
    sw.stop();
    System.err.println("Stored " + numEntries + " tree entries in " + sw + " (" + Math.round(numEntries / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)");
    sw = Stopwatch.createStarted();
    treeId = createAndSaveTree(numEntries, true);
    sw.stop();
    System.err.println("Stored " + numEntries + " tree entries in " + sw + " (" + Math.round(numEntries / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)");
    sw.reset().start();
    final RevTree tree = odb.getTree(treeId);
    sw.stop();
    System.err.println("Retrieved tree in " + sw);
    System.err.println("traversing with DepthTreeIterator...");
    sw.reset().start();
    int counted = 0;
    for (DepthTreeIterator it = new DepthTreeIterator("", ObjectId.NULL, tree, odb, Strategy.CHILDREN); it.hasNext(); counted++) {
        NodeRef ref = it.next();
        if ((counted + 1) % (numEntries / 10) == 0) {
            System.err.print("#" + (counted + 1));
        } else if ((counted + 1) % (numEntries / 100) == 0) {
            System.err.print('.');
        }
    }
    sw.stop();
    System.err.println("\nTraversed " + counted + " in " + sw + " (" + Math.round(counted / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)\n");
    System.err.println("traversing with DepthTreeIterator...");
    sw.reset().start();
    counted = 0;
    for (DepthTreeIterator it = new DepthTreeIterator("", ObjectId.NULL, tree, odb, Strategy.CHILDREN); it.hasNext(); counted++) {
        NodeRef ref = it.next();
        if ((counted + 1) % (numEntries / 10) == 0) {
            System.err.print("#" + (counted + 1));
        } else if ((counted + 1) % (numEntries / 100) == 0) {
            System.err.print('.');
        }
    }
    sw.stop();
    System.err.println("\nTraversed " + counted + " in " + sw + " (" + Math.round(counted / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)\n");
    assertEquals(numEntries, counted);
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) ObjectId(org.locationtech.geogig.api.ObjectId) Stopwatch(com.google.common.base.Stopwatch) DepthTreeIterator(org.locationtech.geogig.api.plumbing.diff.DepthTreeIterator) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 68 with ObjectId

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

the class RevTreeBuilderTest method node.

/**
     * @return a feature node named {@code i}, with
     *         {@code id = ObjectId.forString(String.valueOf(i))}, null metadata id, and
     *         {@code bounds = [i, i+1, i, i+1]}
     */
private static Node node(int i) {
    String key = String.valueOf(i);
    ObjectId oid = ObjectId.forString(key);
    Envelope bounds = new Envelope(i, i + 1, i, i + 1);
    Node node = Node.create(key, oid, ObjectId.NULL, TYPE.FEATURE, bounds);
    return node;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Envelope(com.vividsolutions.jts.geom.Envelope)

Example 69 with ObjectId

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

the class RevTreeBuilderTest method testPutRandomGet.

@Test
public void testPutRandomGet() throws Exception {
    final int numEntries = 2 * RevTree.NORMALIZED_SIZE_LIMIT + 1500;
    final ObjectId treeId;
    Stopwatch sw;
    sw = Stopwatch.createStarted();
    treeId = createAndSaveTree(numEntries, true);
    sw.stop();
    System.err.println("Stored " + numEntries + " tree entries in " + sw + " (" + Math.round(numEntries / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)");
    sw.reset().start();
    final RevTree tree = odb.getTree(treeId);
    sw.stop();
    System.err.println("Retrieved tree in " + sw);
    {
        Map<Integer, Node> randomEdits = Maps.newHashMap();
        Random randGen = new Random();
        for (int i = 0; i < tree.size() / 2; i++) {
            int random;
            while (randomEdits.containsKey(random = randGen.nextInt(numEntries))) {
                // $codepro.audit.disable extraSemicolon
                ;
            }
            String name = "Feature." + random;
            ObjectId newid = ObjectId.forString(name + "changed");
            Node ref = Node.create(name, newid, ObjectId.NULL, TYPE.FEATURE, null);
            randomEdits.put(random, ref);
        }
        RevTreeBuilder mutable = tree.builder(odb);
        sw.reset().start();
        for (Node ref : randomEdits.values()) {
            mutable.put(ref);
        }
        mutable.build();
        sw.stop();
        System.err.println(randomEdits.size() + " random modifications in " + sw);
    }
    // CharSequence treeStr =
    // repo.command(CatObject.class).setObject(Suppliers.ofInstance(tree))
    // .call();
    // System.out.println(treeStr);
    final FindTreeChild childFinder = repo.command(FindTreeChild.class).setParent(tree);
    sw.reset().start();
    System.err.println("Reading " + numEntries + " entries....");
    for (int i = 0; i < numEntries; i++) {
        if ((i + 1) % (numEntries / 10) == 0) {
            System.err.print("#" + (i + 1));
        } else if ((i + 1) % (numEntries / 100) == 0) {
            System.err.print('.');
        }
        String key = "Feature." + i;
        // ObjectId oid = ObjectId.forString(key);
        Optional<NodeRef> ref = childFinder.setChildPath(key).call();
        assertTrue(key, ref.isPresent());
    // assertEquals(key, ref.get().getPath());
    // assertEquals(key, oid, ref.get().getObjectId());
    }
    sw.stop();
    System.err.println("\nGot " + numEntries + " in " + sw.elapsed(TimeUnit.MILLISECONDS) + "ms (" + Math.round(numEntries / (sw.elapsed(TimeUnit.MILLISECONDS) / 1000D)) + "/s)\n");
}
Also used : NodeRef(org.locationtech.geogig.api.NodeRef) Random(java.util.Random) ObjectId(org.locationtech.geogig.api.ObjectId) Node(org.locationtech.geogig.api.Node) Stopwatch(com.google.common.base.Stopwatch) RevTreeBuilder(org.locationtech.geogig.api.RevTreeBuilder) FindTreeChild(org.locationtech.geogig.api.plumbing.FindTreeChild) Map(java.util.Map) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 70 with ObjectId

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

the class WorkingTreeTest method testUpdateFeaturesNullCollectionSize.

@Test
public void testUpdateFeaturesNullCollectionSize() throws Exception {
    List<Feature> featureList = new LinkedList<Feature>();
    featureList.add(points1);
    featureList.add(points2);
    featureList.add(points3);
    workTree.insert(pointsName, featureList.iterator(), LISTENER, null, 3);
    ObjectId oID1 = workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId();
    List<Feature> modifiedFeatures = new LinkedList<Feature>();
    modifiedFeatures.add(points1_modified);
    workTree.update(pointsName, modifiedFeatures.iterator(), LISTENER, null);
    assertFalse(workTree.findUnstaged(appendChild(pointsName, idP1)).get().getObjectId().equals(oID1));
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) SimpleFeature(org.opengis.feature.simple.SimpleFeature) Feature(org.opengis.feature.Feature) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Aggregations

ObjectId (org.locationtech.geogig.api.ObjectId)361 Test (org.junit.Test)133 RevCommit (org.locationtech.geogig.api.RevCommit)109 NodeRef (org.locationtech.geogig.api.NodeRef)98 RevTree (org.locationtech.geogig.api.RevTree)91 RevObject (org.locationtech.geogig.api.RevObject)53 Ref (org.locationtech.geogig.api.Ref)46 Node (org.locationtech.geogig.api.Node)44 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)38 Feature (org.opengis.feature.Feature)35 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)34 LogOp (org.locationtech.geogig.api.porcelain.LogOp)28 RevTreeBuilder (org.locationtech.geogig.api.RevTreeBuilder)27 LinkedList (java.util.LinkedList)26 ArrayList (java.util.ArrayList)25 RevFeature (org.locationtech.geogig.api.RevFeature)25 IOException (java.io.IOException)23 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)23 UpdateRef (org.locationtech.geogig.api.plumbing.UpdateRef)23 SymRef (org.locationtech.geogig.api.SymRef)22