Search in sources :

Example 86 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry in project qpid-broker-j by apache.

the class BDBLinkStore method updateVersion.

private void updateVersion(final Transaction txn, final String currentVersion) {
    Database linksVersionDb = getEnvironmentFacade().openDatabase(LINKS_VERSION_DB_NAME, DEFAULT_DATABASE_CONFIG);
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry value = new DatabaseEntry();
    StringBinding.stringToEntry(currentVersion, key);
    LongBinding.longToEntry(System.currentTimeMillis(), value);
    linksVersionDb.put(txn, key, value);
}
Also used : Database(com.sleepycat.je.Database) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 87 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 88 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 89 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)

Example 90 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry in project sirix by sirixdb.

the class BerkeleyStorage method exists.

@Override
public boolean exists() throws SirixIOException {
    final DatabaseEntry valueEntry = new DatabaseEntry();
    final DatabaseEntry keyEntry = new DatabaseEntry();
    boolean returnVal = false;
    try {
        final Reader reader = new BerkeleyReader(mEnv, mDatabase, mByteHandler);
        TupleBinding.getPrimitiveBinding(Long.class).objectToEntry(-1l, keyEntry);
        final OperationStatus status = mDatabase.get(null, keyEntry, valueEntry, LockMode.DEFAULT);
        if (status == OperationStatus.SUCCESS) {
            returnVal = true;
        }
        reader.close();
    } catch (final DatabaseException exc) {
        throw new SirixIOException(exc);
    }
    return returnVal;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) Reader(org.sirix.io.Reader) DatabaseEntry(com.sleepycat.je.DatabaseEntry) DatabaseException(com.sleepycat.je.DatabaseException) SirixIOException(org.sirix.exception.SirixIOException)

Aggregations

DatabaseEntry (com.sleepycat.je.DatabaseEntry)153 OperationStatus (com.sleepycat.je.OperationStatus)70 Transaction (com.sleepycat.je.Transaction)58 Database (com.sleepycat.je.Database)46 Cursor (com.sleepycat.je.Cursor)31 DatabaseException (com.sleepycat.je.DatabaseException)26 StoreException (org.apache.qpid.server.store.StoreException)20 UUID (java.util.UUID)17 ArrayList (java.util.ArrayList)13 AMQShortString (org.apache.qpid.server.protocol.v0_8.AMQShortString)12 DatabaseConfig (com.sleepycat.je.DatabaseConfig)11 ConnectionScopedRuntimeException (org.apache.qpid.server.util.ConnectionScopedRuntimeException)11 LockConflictException (com.sleepycat.je.LockConflictException)9 HashMap (java.util.HashMap)9 Versioned (voldemort.versioning.Versioned)9 HashSet (java.util.HashSet)8 UUIDTupleBinding (org.apache.qpid.server.store.berkeleydb.tuple.UUIDTupleBinding)8 TupleOutput (com.sleepycat.bind.tuple.TupleOutput)6 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)6 SirixIOException (org.sirix.exception.SirixIOException)6