Search in sources :

Example 56 with ObjectId

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

the class HeapGraphDatabase method put.

@Override
public boolean put(ObjectId commitId, ImmutableList<ObjectId> parentIds) {
    Node n = graph.getOrAdd(commitId);
    if (parentIds.isEmpty()) {
        // the root node, only update on first addition
        if (!n.isRoot()) {
            n.setRoot(true);
            return true;
        }
    }
    // has the node been attached to graph?
    if (Iterables.isEmpty(n.to())) {
        // nope, attach it
        for (ObjectId parent : parentIds) {
            Node p = graph.getOrAdd(parent);
            graph.newEdge(n, p);
        }
        // only mark as updated if it is actually attached
        boolean added = !Iterables.isEmpty(n.to());
        return added;
    }
    return false;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId)

Example 57 with ObjectId

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

the class HeapObjectDatabse method deleteAll.

@Override
public long deleteAll(Iterator<ObjectId> ids, final BulkOpListener listener) {
    long count = 0;
    while (ids.hasNext()) {
        ObjectId id = ids.next();
        byte[] removed = this.objects.remove(id);
        if (removed != null) {
            count++;
            listener.deleted(id);
        } else {
            listener.notFound(id);
        }
    }
    return count;
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId)

Example 58 with ObjectId

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

the class HeapObjectDatabse method getAll.

@Override
public Iterator<RevObject> getAll(final Iterable<ObjectId> ids, final BulkOpListener listener) {
    return new AbstractIterator<RevObject>() {

        final Iterator<ObjectId> iterator = ids.iterator();

        @Override
        protected RevObject computeNext() {
            RevObject found = null;
            ObjectId id;
            byte[] raw;
            while (iterator.hasNext() && found == null) {
                id = iterator.next();
                raw = objects.get(id);
                if (raw != null) {
                    try {
                        found = serializationFactory.createObjectReader().read(id, new LZFInputStream(new ByteArrayInputStream(raw)));
                    } catch (IOException e) {
                        throw Throwables.propagate(e);
                    }
                    listener.found(found.getId(), raw.length);
                } else {
                    listener.notFound(id);
                }
            }
            return found == null ? endOfData() : found;
        }
    };
}
Also used : RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) ByteArrayInputStream(java.io.ByteArrayInputStream) Iterator(java.util.Iterator) AbstractIterator(com.google.common.collect.AbstractIterator) LZFInputStream(com.ning.compress.lzf.LZFInputStream) AbstractIterator(com.google.common.collect.AbstractIterator) IOException(java.io.IOException)

Example 59 with ObjectId

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

the class HashObjectTest method testHashCommits.

@Test
public void testHashCommits() throws Exception {
    ObjectId commit1Id = hashCommand.setObject(commit1).call();
    ObjectId commit2Id = hashCommand.setObject(commit2).call();
    ObjectId commit1DuplicateId = hashCommand.setObject(commit1Duplicate).call();
    assertNotNull(commit1Id);
    assertNotNull(commit2Id);
    assertNotNull(commit1DuplicateId);
    assertFalse(commit1Id.equals(commit2Id));
    assertTrue(commit1Id.equals(commit1DuplicateId));
}
Also used : ObjectId(org.locationtech.geogig.api.ObjectId) Test(org.junit.Test)

Example 60 with ObjectId

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

the class HashObjectTest method testHashTags.

@Test
public void testHashTags() throws Exception {
    RevPerson tagger = new RevPersonImpl("volaya", "volaya@boundlessgeo.com", -1000, -1);
    RevPerson tagger2 = new RevPersonImpl("groldan", "groldan@boundlessgeo.com", 10000, 0);
    RevTag tag = new RevTagImpl(null, "tag1", ObjectId.forString("fake commit id"), "message", tagger);
    RevTag tag2 = new RevTagImpl(null, "tag2", ObjectId.forString("another fake commit id"), "another message", tagger2);
    ObjectId tagId = hashCommand.setObject(tag).call();
    ObjectId tagId2 = hashCommand.setObject(tag2).call();
    assertNotNull(tagId);
    assertNotNull(tagId2);
    assertNotSame(tagId, tagId2);
}
Also used : RevPersonImpl(org.locationtech.geogig.api.RevPersonImpl) RevPerson(org.locationtech.geogig.api.RevPerson) RevTag(org.locationtech.geogig.api.RevTag) ObjectId(org.locationtech.geogig.api.ObjectId) RevTagImpl(org.locationtech.geogig.api.RevTagImpl) 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