Search in sources :

Example 1 with LockMode

use of com.sleepycat.je.LockMode in project GeoGig by boundlessgeo.

the class JEObjectDatabase method getRawInternal.

@Override
protected InputStream getRawInternal(final ObjectId id, final boolean failIfNotFound) {
    checkOpen();
    Preconditions.checkNotNull(id, "id");
    DatabaseEntry key = new DatabaseEntry(id.getRawValue());
    DatabaseEntry data = new DatabaseEntry();
    final LockMode lockMode = LockMode.READ_UNCOMMITTED;
    Transaction transaction = null;
    OperationStatus operationStatus = objectDb.get(transaction, key, data, lockMode);
    if (NOTFOUND.equals(operationStatus)) {
        if (failIfNotFound) {
            throw new IllegalArgumentException("Object does not exist: " + id.toString() + " at " + env.getHome().getAbsolutePath());
        }
        return null;
    }
    final byte[] cData = data.getData();
    return new ByteArrayInputStream(cData);
}
Also used : Transaction(com.sleepycat.je.Transaction) ByteArrayInputStream(java.io.ByteArrayInputStream) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) LockMode(com.sleepycat.je.LockMode)

Example 2 with LockMode

use of com.sleepycat.je.LockMode in project GeoGig by boundlessgeo.

the class JEObjectDatabase method exists.

/**
     * @see org.locationtech.geogig.storage.ObjectDatabase#exists(org.locationtech.geogig.api.ObjectId)
     */
@Override
public boolean exists(final ObjectId id) {
    checkOpen();
    Preconditions.checkNotNull(id, "id");
    DatabaseEntry key = new DatabaseEntry(id.getRawValue());
    DatabaseEntry data = new DatabaseEntry();
    // tell db not to retrieve data
    data.setPartial(0, 0, true);
    final LockMode lockMode = LockMode.READ_UNCOMMITTED;
    Transaction transaction = null;
    OperationStatus status = objectDb.get(transaction, key, data, lockMode);
    return SUCCESS == status;
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) LockMode(com.sleepycat.je.LockMode)

Aggregations

DatabaseEntry (com.sleepycat.je.DatabaseEntry)2 LockMode (com.sleepycat.je.LockMode)2 OperationStatus (com.sleepycat.je.OperationStatus)2 Transaction (com.sleepycat.je.Transaction)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1