use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class RevertOpTest method testRevertModifiedFeatureConflictSolveAndContinue.
@Test
public void testRevertModifiedFeatureConflictSolveAndContinue() throws Exception {
ObjectId oId1 = insertAndAdd(points1);
RevCommit c1 = geogig.command(CommitOp.class).setMessage("commit for " + idP1).call();
insertAndAdd(points1_modified);
RevCommit c2 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1).call();
Feature points1_modifiedB = feature(pointsType, idP1, "StringProp1_2", new Integer(2000), "POINT(1 1)");
insertAndAdd(points1_modifiedB);
RevCommit c3 = geogig.command(CommitOp.class).setMessage("commit for modified " + idP1 + " again").call();
try {
geogig.command(RevertOp.class).addCommit(Suppliers.ofInstance(c2.getId())).call();
fail();
} catch (RevertConflictsException e) {
assertTrue(e.getMessage().contains(idP1));
}
Optional<Ref> ref = geogig.command(RefParse.class).setName(Ref.ORIG_HEAD).call();
assertTrue(ref.isPresent());
assertEquals(c3.getId(), ref.get().getObjectId());
List<Conflict> conflicts = geogig.command(ConflictsReadOp.class).call();
assertEquals(1, conflicts.size());
String path = NodeRef.appendChild(pointsName, idP1);
assertEquals(conflicts.get(0).getPath(), path);
assertEquals(conflicts.get(0).getOurs(), RevFeatureBuilder.build(points1_modifiedB).getId());
assertEquals(conflicts.get(0).getTheirs(), RevFeatureBuilder.build(points1).getId());
// solve, and continue
insert(points1);
geogig.command(AddOp.class).call();
geogig.command(RevertOp.class).setContinue(true).call();
Iterator<RevCommit> log = geogig.command(LogOp.class).call();
RevCommit logCommit = log.next();
assertEquals(c2.getAuthor().getName(), logCommit.getAuthor().getName());
assertEquals(c2.getCommitter().getName(), logCommit.getCommitter().getName());
assertEquals("Revert '" + c2.getMessage() + "'\nThis reverts " + c2.getId().toString(), logCommit.getMessage());
assertNotSame(c2.getCommitter().getTimestamp(), logCommit.getCommitter().getTimestamp());
assertNotSame(c2.getTreeId(), logCommit.getTreeId());
final Optional<Ref> currHead = geogig.command(RefParse.class).setName(Ref.HEAD).call();
final Optional<ObjectId> headTreeId = geogig.command(ResolveTreeish.class).setTreeish(currHead.get().getObjectId()).call();
RevTree headTree = repo.getTree(headTreeId.get());
Optional<NodeRef> points1Node = geogig.command(FindTreeChild.class).setChildPath(NodeRef.appendChild(pointsName, idP1)).setParent(headTree).call();
assertTrue(points1Node.isPresent());
assertEquals(oId1, points1Node.get().getNode().getObjectId());
assertEquals(c3.getId(), log.next().getId());
assertEquals(c2.getId(), log.next().getId());
assertEquals(c1.getId(), log.next().getId());
assertFalse(log.hasNext());
}
use of org.locationtech.geogig.api.NodeRef 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);
}
use of org.locationtech.geogig.api.NodeRef 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");
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class RevTreeBuilderTest method testResultingTreeSize.
private void testResultingTreeSize(int numEntries) {
RevTreeBuilder builder = createTree(numEntries, true);
RevTree tree = builder.build();
final long declaredSize = tree.size();
Iterator<NodeRef> it = new DepthTreeIterator("", ObjectId.NULL, tree, odb, Strategy.RECURSIVE_FEATURES_ONLY);
long itSize = 0;
while (it.hasNext()) {
it.next();
itSize++;
}
assertEquals(numEntries, itSize);
assertEquals(numEntries, declaredSize);
}
use of org.locationtech.geogig.api.NodeRef in project GeoGig by boundlessgeo.
the class WorkingTreeTest method testCreateTypeTree.
@Test
public void testCreateTypeTree() throws Exception {
NodeRef treeRef = workTree.createTypeTree("points2", pointsType);
assertNotNull(treeRef);
assertEquals("points2", treeRef.path());
assertEquals("", treeRef.getParentPath());
assertTrue(treeRef.getNode().getMetadataId().isPresent());
assertSame(treeRef.getMetadataId(), treeRef.getNode().getMetadataId().get());
RevFeatureType featureType = repo.stagingDatabase().getFeatureType(treeRef.getMetadataId());
assertEquals(pointsType, featureType.type());
}
Aggregations