Search in sources :

Example 46 with ObjectId

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

the class AddOpTest method testAddNewPathUsingPathFilter.

@Test
public void testAddNewPathUsingPathFilter() throws Exception {
    insert(points1);
    insert(points2);
    geogig.command(AddOp.class).addPattern("Points/Points.1").call();
    List<DiffEntry> unstaged = toList(repo.index().getStaged(null));
    assertEquals(unstaged.toString(), 2, unstaged.size());
    assertEquals(ChangeType.ADDED, unstaged.get(0).changeType());
    assertEquals(RevObject.TYPE.TREE, unstaged.get(0).getNewObject().getType());
    assertEquals("Points", unstaged.get(0).newName());
    RevFeatureType ft = RevFeatureTypeImpl.build(pointsType);
    ObjectId expectedTreeMdId = ft.getId();
    assertEquals(expectedTreeMdId, unstaged.get(0).getNewObject().getMetadataId());
    assertEquals(ChangeType.ADDED, unstaged.get(1).changeType());
    assertEquals(RevObject.TYPE.FEATURE, unstaged.get(1).getNewObject().getType());
    assertEquals("Points.1", unstaged.get(1).newName());
    assertFalse("feature node's metadata id should not be set, as it uses the parent tree one", unstaged.get(1).getNewObject().getNode().getMetadataId().isPresent());
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) RevFeatureType(org.locationtech.geogig.api.RevFeatureType) DiffEntry(org.locationtech.geogig.api.plumbing.diff.DiffEntry) Test(org.junit.Test)

Example 47 with ObjectId

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

the class RevTreeSerializationTest method testRoundTripBucketsFull.

@Test
public void testRoundTripBucketsFull() {
    ObjectId id = ObjectId.forString("fake");
    long size = 100000000;
    int childTreeCount = 0;
    Map<Integer, Bucket> bucketTrees = createBuckets(32);
    final RevTreeImpl tree = RevTreeImpl.createNodeTree(id, size, childTreeCount, bucketTrees);
    RevTree roundTripped = read(tree.getId(), write(tree));
    assertTreesAreEqual(tree, roundTripped);
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Bucket(org.locationtech.geogig.api.Bucket) RevTreeImpl(org.locationtech.geogig.api.RevTreeImpl) RevTree(org.locationtech.geogig.api.RevTree) Test(org.junit.Test)

Example 48 with ObjectId

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

the class SQLiteGraphDatabase method put.

@Override
public boolean put(ObjectId commitId, ImmutableList<ObjectId> parentIds) {
    String node = commitId.toString();
    boolean added = put(node, cx);
    // TODO: if node was node added should we severe existing parent relationships?
    for (ObjectId p : parentIds) {
        relate(node, p.toString(), cx);
    }
    return added;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId)

Example 49 with ObjectId

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

the class MongoObjectDatabase method putAll.

@Override
public void putAll(Iterator<? extends RevObject> objects, BulkOpListener listener) {
    Preconditions.checkNotNull(executor, "executor service not set");
    if (!objects.hasNext()) {
        return;
    }
    final int bulkSize = 1000;
    final int maxRunningTasks = 10;
    final AtomicBoolean cancelCondition = new AtomicBoolean();
    List<ObjectId> ids = Lists.newArrayListWithCapacity(bulkSize);
    List<Future<?>> runningTasks = new ArrayList<Future<?>>(maxRunningTasks);
    BulkWriteOperation bulkOperation = collection.initializeOrderedBulkOperation();
    try {
        while (objects.hasNext()) {
            RevObject object = objects.next();
            bulkOperation.insert(toDocument(object));
            ids.add(object.getId());
            if (ids.size() == bulkSize || !objects.hasNext()) {
                InsertTask task = new InsertTask(bulkOperation, listener, ids, cancelCondition);
                runningTasks.add(executor.submit(task));
                if (objects.hasNext()) {
                    bulkOperation = collection.initializeOrderedBulkOperation();
                    ids = Lists.newArrayListWithCapacity(bulkSize);
                }
            }
            if (runningTasks.size() == maxRunningTasks) {
                waitForTasks(runningTasks);
            }
        }
        waitForTasks(runningTasks);
    } catch (RuntimeException e) {
        cancelCondition.set(true);
        throw e;
    }
}
Also used : BulkWriteOperation(com.mongodb.BulkWriteOperation) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ObjectId(org.locationtech.geogig.api.ObjectId) RevObject(org.locationtech.geogig.api.RevObject) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future)

Example 50 with ObjectId

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

the class MongoStagingDatabase method getConflict.

@Override
public Optional<Conflict> getConflict(@Nullable String namespace, String path) {
    DBObject query = new BasicDBObject();
    query.put("path", path);
    if (namespace != null) {
        query.put("namespace", namespace);
    }
    DBObject result = conflicts.findOne(query);
    if (result == null) {
        return Optional.absent();
    } else {
        ObjectId ancestor = ObjectId.valueOf((String) result.get("ancestor"));
        ObjectId ours = ObjectId.valueOf((String) result.get("ours"));
        ObjectId theirs = ObjectId.valueOf((String) result.get("theirs"));
        return Optional.of(new Conflict(path, ancestor, ours, theirs));
    }
}
Also used : BasicDBObject(com.mongodb.BasicDBObject) ObjectId(org.locationtech.geogig.api.ObjectId) Conflict(org.locationtech.geogig.api.plumbing.merge.Conflict) BasicDBObject(com.mongodb.BasicDBObject) DBObject(com.mongodb.DBObject)

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