use of com.sleepycat.je.DatabaseEntry in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method getDuplicates.
@Override
public List<byte[]> getDuplicates(String tableName, byte[] keyBytes, DatabaseSession databaseSession) throws BimserverDatabaseException {
DatabaseEntry key = new DatabaseEntry(keyBytes);
DatabaseEntry value = new DatabaseEntry();
try {
TableWrapper tableWrapper = getTableWrapper(tableName);
Cursor cursor = tableWrapper.getDatabase().openCursor(getTransaction(databaseSession, tableWrapper), getCursorConfig(tableWrapper));
try {
OperationStatus operationStatus = cursor.getSearchKey(key, value, LockMode.DEFAULT);
List<byte[]> result = new ArrayList<byte[]>();
while (operationStatus == OperationStatus.SUCCESS) {
result.add(value.getData());
operationStatus = cursor.getNextDup(key, value, LockMode.DEFAULT);
}
return result;
} finally {
cursor.close();
}
} catch (DatabaseException e) {
LOGGER.error("", e);
}
return null;
}
use of com.sleepycat.je.DatabaseEntry in project BIMserver by opensourceBIM.
the class BerkeleyKeyValueStore method store.
@Override
public void store(String tableName, byte[] key, byte[] value, int offset, int length, DatabaseSession databaseSession) throws BimserverDatabaseException, BimserverLockConflictException {
DatabaseEntry dbKey = new DatabaseEntry(key);
DatabaseEntry dbValue = new DatabaseEntry(value, offset, length);
try {
TableWrapper tableWrapper = getTableWrapper(tableName);
tableWrapper.getDatabase().put(getTransaction(databaseSession, tableWrapper), dbKey, dbValue);
} catch (LockConflictException e) {
throw new BimserverLockConflictException(e);
} catch (DatabaseException e) {
throw new BimserverDatabaseException("", e);
}
}
use of com.sleepycat.je.DatabaseEntry in project crawler4j by yasserg.
the class DocIDServer method addUrlAndDocId.
public void addUrlAndDocId(String url, int docId) {
synchronized (mutex) {
if (docId <= lastDocID) {
throw new IllegalArgumentException("Requested doc id: " + docId + " is not larger than: " + lastDocID);
}
// Make sure that we have not already assigned a docid for this URL
int prevDocid = getDocId(url);
if (prevDocid > 0) {
if (prevDocid == docId) {
return;
}
throw new IllegalArgumentException("Doc id: " + prevDocid + " is already assigned to URL: " + url);
}
docIDsDB.put(null, new DatabaseEntry(url.getBytes()), new DatabaseEntry(Util.int2ByteArray(docId)));
lastDocID = docId;
}
}
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;
}
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);
}
Aggregations