Search in sources :

Example 46 with RevObject

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

the class JEObjectDatabaseTest method testReadOnlyHint2.

@Test
public void testReadOnlyHint2() {
    hints.set(Hints.OBJECTS_READ_ONLY, Boolean.TRUE);
    db = createDb();
    RevObject obj = RevTree.EMPTY;
    try {
        db.put(obj);
        fail("Expected UOE on read only hint");
    } catch (UnsupportedOperationException e) {
        assertTrue(true);
    }
    db.close();
    hints.set(Hints.OBJECTS_READ_ONLY, Boolean.FALSE);
    db = createDb();
    Assert.assertTrue(db.put(obj));
}
Also used : RevObject(org.locationtech.geogig.api.RevObject) Test(org.junit.Test)

Example 47 with RevObject

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

the class JEObjectDatabaseTest method testMultipleInstances.

public void testMultipleInstances() {
    ObjectDatabase db1 = createDb();
    ObjectDatabase db2 = createDb();
    RevObject obj = RevTree.EMPTY;
    assertTrue(db1.put(obj));
    db1.close();
    assertFalse(db2.put(obj));
    db2.close();
    RevObject revObject = db.get(obj.getId());
    assertEquals(obj, revObject);
}
Also used : ObjectDatabase(org.locationtech.geogig.storage.ObjectDatabase) RevObject(org.locationtech.geogig.api.RevObject)

Example 48 with RevObject

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

the class JEObjectDatabaseTest method testReadOnlyHintPreservedOnReopen.

@Test
public void testReadOnlyHintPreservedOnReopen() {
    hints.set(Hints.OBJECTS_READ_ONLY, Boolean.TRUE);
    db = createDb();
    RevObject obj = RevTree.EMPTY;
    try {
        db.put(obj);
        fail("Expected UOE on read only hint");
    } catch (UnsupportedOperationException e) {
        assertTrue(true);
    }
    db.close();
    db.open();
    try {
        db.put(obj);
        fail("Expected UOE on read only hint");
    } catch (UnsupportedOperationException e) {
        assertTrue(true);
    }
}
Also used : RevObject(org.locationtech.geogig.api.RevObject) Test(org.junit.Test)

Example 49 with RevObject

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

the class MongoObjectDatabase method getAll.

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

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

        @Override
        protected RevObject computeNext() {
            RevObject obj = null;
            while (obj == null) {
                if (!queryIds.hasNext()) {
                    return endOfData();
                }
                ObjectId id = queryIds.next();
                obj = getIfPresent(id);
                if (obj == null) {
                    listener.notFound(id);
                } else {
                    listener.found(obj.getId(), null);
                }
            }
            return obj == null ? endOfData() : obj;
        }
    };
}
Also used : RevObject(org.locationtech.geogig.api.RevObject) ObjectId(org.locationtech.geogig.api.ObjectId) Iterator(java.util.Iterator) AbstractIterator(com.google.common.collect.AbstractIterator) AbstractIterator(com.google.common.collect.AbstractIterator)

Example 50 with RevObject

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

the class MongoObjectDatabase method toBytes.

private byte[] toBytes(RevObject object) {
    ObjectWriter<RevObject> writer = serializers.createObjectWriter(object.getType());
    ByteArrayOutputStream byteStream = new ByteArrayOutputStream();
    LZFOutputStream cOut = new LZFOutputStream(byteStream);
    try {
        writer.write(object, cOut);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    try {
        cOut.close();
    } catch (IOException e) {
        throw Throwables.propagate(e);
    }
    return byteStream.toByteArray();
}
Also used : RevObject(org.locationtech.geogig.api.RevObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) IOException(java.io.IOException) LZFOutputStream(com.ning.compress.lzf.LZFOutputStream)

Aggregations

RevObject (org.locationtech.geogig.api.RevObject)84 ObjectId (org.locationtech.geogig.api.ObjectId)51 RevCommit (org.locationtech.geogig.api.RevCommit)30 NodeRef (org.locationtech.geogig.api.NodeRef)22 RevFeatureType (org.locationtech.geogig.api.RevFeatureType)22 RevTree (org.locationtech.geogig.api.RevTree)21 Test (org.junit.Test)18 ArrayList (java.util.ArrayList)17 RevFeature (org.locationtech.geogig.api.RevFeature)17 RevObjectParse (org.locationtech.geogig.api.plumbing.RevObjectParse)16 Feature (org.opengis.feature.Feature)16 IOException (java.io.IOException)15 LinkedList (java.util.LinkedList)15 LogOp (org.locationtech.geogig.api.porcelain.LogOp)14 GeoGIG (org.locationtech.geogig.api.GeoGIG)13 DiffEntry (org.locationtech.geogig.api.plumbing.diff.DiffEntry)11 HashMap (java.util.HashMap)10 PropertyDescriptor (org.opengis.feature.type.PropertyDescriptor)10 Optional (com.google.common.base.Optional)8 ObjectDatabase (org.locationtech.geogig.storage.ObjectDatabase)8