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