Search in sources :

Example 26 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry in project crawler4j by yasserg.

the class InProcessPagesDB method removeURL.

public boolean removeURL(WebURL webUrl) {
    synchronized (mutex) {
        DatabaseEntry key = getDatabaseEntryKey(webUrl);
        DatabaseEntry value = new DatabaseEntry();
        Transaction txn = beginTransaction();
        try (Cursor cursor = openCursor(txn)) {
            OperationStatus result = cursor.getSearchKey(key, value, null);
            if (result == OperationStatus.SUCCESS) {
                result = cursor.delete();
                if (result == OperationStatus.SUCCESS) {
                    return true;
                }
            }
        } finally {
            commit(txn);
        }
    }
    return false;
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) Cursor(com.sleepycat.je.Cursor)

Example 27 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry in project crawler4j by yasserg.

the class WorkQueues method put.

public void put(WebURL url) {
    DatabaseEntry value = new DatabaseEntry();
    webURLBinding.objectToEntry(url, value);
    Transaction txn = beginTransaction();
    urlsDB.put(txn, getDatabaseEntryKey(url), value);
    commit(txn);
}
Also used : Transaction(com.sleepycat.je.Transaction) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 28 with DatabaseEntry

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

the class JEObjectDatabase method lookUpInternal.

@Override
protected List<ObjectId> lookUpInternal(final byte[] partialId) {
    checkOpen();
    DatabaseEntry key;
    {
        byte[] keyData = partialId.clone();
        key = new DatabaseEntry(keyData);
    }
    DatabaseEntry data = new DatabaseEntry();
    // do not retrieve data
    data.setPartial(0, 0, true);
    List<ObjectId> matches;
    CursorConfig cursorConfig = new CursorConfig();
    cursorConfig.setReadUncommitted(true);
    Transaction transaction = null;
    Cursor cursor = objectDb.openCursor(transaction, cursorConfig);
    try {
        // position cursor at the first closest key to the one looked up
        OperationStatus status = cursor.getSearchKeyRange(key, data, LockMode.READ_UNCOMMITTED);
        if (SUCCESS.equals(status)) {
            matches = new ArrayList<ObjectId>(2);
            final byte[] compKey = new byte[partialId.length];
            while (SUCCESS.equals(status)) {
                byte[] keyData = key.getData();
                System.arraycopy(keyData, 0, compKey, 0, compKey.length);
                if (Arrays.equals(partialId, compKey)) {
                    matches.add(new ObjectId(keyData));
                } else {
                    break;
                }
                status = cursor.getNext(key, data, LockMode.READ_UNCOMMITTED);
            }
        } else {
            matches = Collections.emptyList();
        }
        return matches;
    } finally {
        cursor.close();
    }
}
Also used : Transaction(com.sleepycat.je.Transaction) ObjectId(org.locationtech.geogig.api.ObjectId) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry) CursorConfig(com.sleepycat.je.CursorConfig) Cursor(com.sleepycat.je.Cursor)

Example 29 with DatabaseEntry

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

the class JEObjectDatabase method delete.

@Override
public boolean delete(final ObjectId id) {
    checkWritable();
    final byte[] rawKey = id.getRawValue();
    final DatabaseEntry key = new DatabaseEntry(rawKey);
    final Transaction transaction = newTransaction();
    final OperationStatus status;
    try {
        status = objectDb.delete(transaction, key);
        commit(transaction);
    } catch (RuntimeException e) {
        abort(transaction);
        throw e;
    }
    return SUCCESS.equals(status);
}
Also used : Transaction(com.sleepycat.je.Transaction) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 30 with DatabaseEntry

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

the class BDBJEPointCache method put.

@Override
public void put(Long nodeId, OSMCoordinateSequence coord) {
    Preconditions.checkNotNull(nodeId, "id is null");
    Preconditions.checkNotNull(coord, "coord is null");
    Preconditions.checkArgument(1 == coord.size(), "coord list size is not 1");
    DatabaseEntry key = new DatabaseEntry();
    LongBinding.longToEntry(nodeId.longValue(), key);
    int[] c = coord.ordinates();
    DatabaseEntry data = CoordinateBinding.objectToEntry(c);
    database.put(null, key, data);
}
Also used : DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Aggregations

DatabaseEntry (com.sleepycat.je.DatabaseEntry)30 OperationStatus (com.sleepycat.je.OperationStatus)23 Transaction (com.sleepycat.je.Transaction)14 DatabaseException (com.sleepycat.je.DatabaseException)9 Versioned (voldemort.versioning.Versioned)9 Cursor (com.sleepycat.je.Cursor)5 ArrayList (java.util.ArrayList)5 AsyncOperationStatus (voldemort.server.protocol.admin.AsyncOperationStatus)5 PersistenceFailureException (voldemort.store.PersistenceFailureException)5 CursorConfig (com.sleepycat.je.CursorConfig)2 LockMode (com.sleepycat.je.LockMode)2 ObjectId (org.locationtech.geogig.api.ObjectId)2 IdentitySerializer (voldemort.serialization.IdentitySerializer)2 VersionedSerializer (voldemort.serialization.VersionedSerializer)2 FnvHashFunction (voldemort.utils.FnvHashFunction)2 HashFunction (voldemort.utils.HashFunction)2 VectorClock (voldemort.versioning.VectorClock)2 CheckpointConfig (com.sleepycat.je.CheckpointConfig)1 Database (com.sleepycat.je.Database)1 DatabaseConfig (com.sleepycat.je.DatabaseConfig)1