Search in sources :

Example 11 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry in project voldemort by voldemort.

the class BdbRevertPidScanToNewDup method transfer.

@Override
public void transfer() throws Exception {
    cursor = srcDB.openCursor(null, null);
    DatabaseEntry keyEntry = new DatabaseEntry();
    DatabaseEntry valueEntry = new DatabaseEntry();
    List<Versioned<byte[]>> vals;
    long startTime = System.currentTimeMillis();
    int scanCount = 0;
    int keyCount = 0;
    while (cursor.getNext(keyEntry, valueEntry, LockMode.READ_UNCOMMITTED) == OperationStatus.SUCCESS) {
        keyCount++;
        vals = StoreBinaryFormat.fromByteArray(valueEntry.getData());
        scanCount += vals.size();
        // pull out the real key
        byte[] stripedKey = StoreBinaryFormat.extractKey(keyEntry.getData());
        OperationStatus putStatus = dstDB.put(null, new DatabaseEntry(stripedKey), valueEntry);
        if (OperationStatus.SUCCESS != putStatus) {
            String errorStr = "Put failed with " + putStatus + " for key" + BdbConvertData.writeAsciiString(keyEntry.getData());
            logger.error(errorStr);
            throw new Exception(errorStr);
        }
        if (scanCount % 1000000 == 0)
            logger.info("Reverted " + scanCount + " entries in " + (System.currentTimeMillis() - startTime) / 1000 + " secs");
    }
    logger.info("Reverted " + scanCount + " entries and " + keyCount + " keys in " + (System.currentTimeMillis() - startTime) / 1000 + " secs");
}
Also used : Versioned(voldemort.versioning.Versioned) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 12 with DatabaseEntry

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

the class BDBJEPointCache method get.

@Override
public CoordinateSequence get(List<Long> ids) {
    Preconditions.checkNotNull(ids, "ids is null");
    OSMCoordinateSequence cs = CSFAC.create(ids.size());
    DatabaseEntry key = new DatabaseEntry();
    DatabaseEntry data = new DatabaseEntry();
    for (int index = 0; index < ids.size(); index++) {
        Long nodeID = ids.get(index);
        LongBinding.longToEntry(nodeID.longValue(), key);
        OperationStatus status = database.get(null, key, data, LockMode.DEFAULT);
        if (!OperationStatus.SUCCESS.equals(status)) {
            String msg = String.format("node id %s not found", nodeID);
            throw new IllegalArgumentException(msg);
        }
        int[] c = CoordinateBinding.entryToCoord(data);
        cs.setOrdinate(index, 0, c[0]);
        cs.setOrdinate(index, 1, c[1]);
    }
    return cs;
}
Also used : OSMCoordinateSequence(org.locationtech.geogig.osm.internal.OSMCoordinateSequence) OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 13 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry 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 14 with DatabaseEntry

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

the class JEObjectDatabase method putInternal.

private OperationStatus putInternal(final ObjectId id, final byte[] rawData, Transaction transaction) {
    OperationStatus status;
    final byte[] rawKey = id.getRawValue();
    DatabaseEntry key = new DatabaseEntry(rawKey);
    DatabaseEntry data = new DatabaseEntry(rawData);
    status = objectDb.putNoOverwrite(transaction, key, data);
    return status;
}
Also used : OperationStatus(com.sleepycat.je.OperationStatus) DatabaseEntry(com.sleepycat.je.DatabaseEntry)

Example 15 with DatabaseEntry

use of com.sleepycat.je.DatabaseEntry 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)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