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));
}
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);
}
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;
}
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");
}
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));
}
Aggregations