diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbContextIdIterator.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbContextIdIterator.java index 5dd7c82a95..1e81df6fd9 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbContextIdIterator.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbContextIdIterator.java @@ -104,12 +104,12 @@ public long[] next() { Varint.writeUnsigned(minKeyBuf, record[0]); minKeyBuf.flip(); keyData.mv_data(minKeyBuf); - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET)); - if (lastResult != 0) { + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET); + if (lastResult != MDB_SUCCESS) { // use MDB_SET_RANGE if key was deleted - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); } - if (lastResult != 0) { + if (lastResult != MDB_SUCCESS) { closeInternal(false); return null; } @@ -119,16 +119,16 @@ public long[] next() { } if (fetchNext) { - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); fetchNext = false; } else { if (minKeyBuf != null) { // set cursor to min key keyData.mv_data(minKeyBuf); - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); } else { // set cursor to first item - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); } } diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbRecordIterator.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbRecordIterator.java index 1bcd6938d3..dbdb69479f 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbRecordIterator.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbRecordIterator.java @@ -138,12 +138,12 @@ public long[] next() { index.toKey(minKeyBuf, quad[0], quad[1], quad[2], quad[3]); minKeyBuf.flip(); keyData.mv_data(minKeyBuf); - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET)); - if (lastResult != 0) { + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET); + if (lastResult != MDB_SUCCESS) { // use MDB_SET_RANGE if key was deleted - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); } - if (lastResult != 0) { + if (lastResult != MDB_SUCCESS) { closeInternal(false); return null; } @@ -153,16 +153,16 @@ public long[] next() { } if (fetchNext) { - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); fetchNext = false; } else { if (minKeyBuf != null) { // set cursor to min key keyData.mv_data(minKeyBuf); - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); } else { // set cursor to first item - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); } } @@ -172,7 +172,7 @@ public long[] next() { lastResult = MDB_NOTFOUND; } else if (groupMatcher != null && !groupMatcher.matches(keyData.mv_data())) { // value doesn't match search key/mask, fetch next value - lastResult = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + lastResult = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); } else { // Matching value found index.keyToQuad(keyData.mv_data(), quad); @@ -183,8 +183,6 @@ public long[] next() { } closeInternal(false); return null; - } catch (IOException e) { - throw new SailException(e); } finally { txnLock.unlockRead(stamp); } diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java index 76f72f415e..02e7d71bf5 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbSailStore.java @@ -572,12 +572,14 @@ public void approve(Resource subj, IRI pred, Value obj, Resource ctx) throws Sai @Override public void approveAll(Set approved, Set approvedContexts) { + Statement last = null; sinkStoreAccessLock.lock(); try { startTransaction(true); for (Statement statement : approved) { + last = statement; Resource subj = statement.getSubject(); IRI pred = statement.getPredicate(); Value obj = statement.getObject(); @@ -604,13 +606,20 @@ public void approveAll(Set approved, Set approvedContexts) } } - } catch (IOException e) { + } catch (IOException | RuntimeException e) { rollback(); + if (multiThreadingActive) { + logger.error("Encountered an unexpected problem while trying to add a statement.", e); + } else { + logger.error( + "Encountered an unexpected problem while trying to add a statement. Last statement that was attempted to be added: [ {} ]", + last, e); + } + + if (e instanceof RuntimeException) { + throw (RuntimeException) e; + } throw new SailException(e); - } catch (RuntimeException e) { - rollback(); - logger.error("Encountered an unexpected problem while trying to add a statement", e); - throw e; } finally { sinkStoreAccessLock.unlock(); } diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbUtil.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbUtil.java index 89e1650686..9a2c68f708 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbUtil.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/LmdbUtil.java @@ -16,6 +16,7 @@ import static org.lwjgl.system.MemoryStack.stackPush; import static org.lwjgl.system.MemoryUtil.NULL; +import static org.lwjgl.util.lmdb.LMDB.MDB_DBS_FULL; import static org.lwjgl.util.lmdb.LMDB.MDB_KEYEXIST; import static org.lwjgl.util.lmdb.LMDB.MDB_NOTFOUND; import static org.lwjgl.util.lmdb.LMDB.MDB_RDONLY; @@ -39,12 +40,16 @@ import org.lwjgl.system.Pointer; import org.lwjgl.util.lmdb.MDBCmpFuncI; import org.lwjgl.util.lmdb.MDBVal; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Utility class for working with LMDB. */ final class LmdbUtil { + private static final Logger logger = LoggerFactory.getLogger(LmdbUtil.class); + /** * Minimum free space in an LMDB db before automatically resizing the map. */ @@ -61,7 +66,9 @@ private LmdbUtil() { static int E(int rc) throws IOException { if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND && rc != MDB_KEYEXIST) { - throw new IOException(mdb_strerror(rc)); + IOException ioException = new IOException(mdb_strerror(rc)); + logger.info("Possible LMDB error: {}", mdb_strerror(rc), ioException); + throw ioException; } return rc; } @@ -105,7 +112,7 @@ static T transaction(long env, Transaction transaction) throws IOExceptio int err; try { ret = transaction.exec(stack, txn); - err = E(mdb_txn_commit(txn)); + err = mdb_txn_commit(txn); } catch (Throwable t) { mdb_txn_abort(txn); throw t; diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/PersistentSet.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/PersistentSet.java index b0bbd20aa3..79d27cf4b7 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/PersistentSet.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/PersistentSet.java @@ -12,6 +12,7 @@ import static org.eclipse.rdf4j.sail.lmdb.LmdbUtil.E; import static org.lwjgl.system.MemoryUtil.NULL; +import static org.lwjgl.util.lmdb.LMDB.MDB_MAP_FULL; import static org.lwjgl.util.lmdb.LMDB.MDB_NEXT; import static org.lwjgl.util.lmdb.LMDB.MDB_NOOVERWRITE; import static org.lwjgl.util.lmdb.LMDB.MDB_SET; @@ -24,6 +25,7 @@ import static org.lwjgl.util.lmdb.LMDB.mdb_del; import static org.lwjgl.util.lmdb.LMDB.mdb_drop; import static org.lwjgl.util.lmdb.LMDB.mdb_put; +import static org.lwjgl.util.lmdb.LMDB.mdb_strerror; import static org.lwjgl.util.lmdb.LMDB.mdb_txn_abort; import static org.lwjgl.util.lmdb.LMDB.mdb_txn_begin; @@ -43,12 +45,16 @@ import org.lwjgl.PointerBuffer; import org.lwjgl.system.MemoryStack; import org.lwjgl.util.lmdb.MDBVal; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * A LMDB-based persistent set. */ class PersistentSet extends AbstractSet { + private static final Logger logger = LoggerFactory.getLogger(PersistentSet.class); + private PersistentSetFactory factory; private final int dbi; private int size; @@ -126,15 +132,35 @@ private synchronized boolean update(Object element, boolean add) throws IOExcept keyVal.mv_data(keyBuf); if (add) { - if (E(mdb_put(factory.writeTxn, dbi, keyVal, dataVal, MDB_NOOVERWRITE)) == MDB_SUCCESS) { + int rc = mdb_put(factory.writeTxn, dbi, keyVal, dataVal, MDB_NOOVERWRITE); + if (rc == MDB_SUCCESS) { size++; return true; + } else if (rc == MDB_MAP_FULL) { + factory.ensureResize(); + if (mdb_put(factory.writeTxn, dbi, keyVal, dataVal, MDB_NOOVERWRITE) == MDB_SUCCESS) { + size++; + return true; + } + return false; + } else { + logger.debug("Failed to add element due to error {}: {}", mdb_strerror(rc), element); } } else { // delete element - if (mdb_del(factory.writeTxn, dbi, keyVal, dataVal) == MDB_SUCCESS) { + int rc = mdb_del(factory.writeTxn, dbi, keyVal, dataVal); + if (rc == MDB_SUCCESS) { size--; return true; + } else if (rc == MDB_MAP_FULL) { + factory.ensureResize(); + if (mdb_del(factory.writeTxn, dbi, keyVal, dataVal) == MDB_SUCCESS) { + size--; + return true; + } + return false; + } else { + logger.debug("Failed to remove element due to error {}: {}", mdb_strerror(rc), element); } } return false; diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TripleStore.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TripleStore.java index 7c0c79c744..d848d30dd5 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TripleStore.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TripleStore.java @@ -561,7 +561,7 @@ protected void filterUsedIds(Collection ids) throws IOException { keyBuf.clear(); Varint.writeUnsigned(keyBuf, id); keyData.mv_data(keyBuf.flip()); - if (E(mdb_get(txn, contextsDbi, keyData, valueData)) == MDB_SUCCESS) { + if (mdb_get(txn, contextsDbi, keyData, valueData) == MDB_SUCCESS) { it.remove(); } } @@ -587,7 +587,7 @@ protected void filterUsedIds(Collection ids) throws IOException { if (fullScan) { long[] quad = new long[4]; - int rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_FIRST)); + int rc = mdb_cursor_get(cursor, keyData, valueData, MDB_FIRST); while (rc == MDB_SUCCESS && !ids.isEmpty()) { index.keyToQuad(keyData.mv_data(), quad); ids.remove(quad[0]); @@ -595,7 +595,7 @@ protected void filterUsedIds(Collection ids) throws IOException { ids.remove(quad[2]); ids.remove(quad[3]); - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); } } else { for (Iterator it = ids.iterator(); it.hasNext();) { @@ -625,15 +625,15 @@ protected void filterUsedIds(Collection ids) throws IOException { // set cursor to min key keyData.mv_data(keyBuf); - int rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + int rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); boolean exists = false; - while (!exists && rc == 0) { + while (!exists && rc == MDB_SUCCESS) { if (mdb_cmp(txn, dbi, keyData, maxKey) > 0) { // id was not found break; } else if (!matcher.matches(keyData.mv_data())) { // value doesn't match search key/mask, fetch next value - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); } else { exists = true; } @@ -708,8 +708,8 @@ protected double cardinality(long subj, long pred, long obj, long context) throw // set cursor to min key keyData.mv_data(keyBuf); - int rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); - if (rc != 0 || mdb_cmp(txn, dbi, keyData, maxKey) >= 0) { + int rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); + if (rc != MDB_SUCCESS || mdb_cmp(txn, dbi, keyData, maxKey) >= 0) { break; } else { Varint.readListUnsigned(keyData.mv_data(), s.minValues); @@ -717,15 +717,15 @@ protected double cardinality(long subj, long pred, long obj, long context) throw // set cursor to max key keyData.mv_data(maxKeyBuf); - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); - if (rc != 0) { + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); + if (rc != MDB_SUCCESS) { // directly go to last value - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_LAST)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_LAST); } else { // go to previous value of selected key - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_PREV)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_PREV); } - if (rc == 0) { + if (rc == MDB_SUCCESS) { Varint.readListUnsigned(keyData.mv_data(), s.maxValues); // this is required to correctly estimate the range size at a later point s.startValues[s.MAX_BUCKETS] = s.maxValues; @@ -747,7 +747,7 @@ protected double cardinality(long subj, long pred, long obj, long context) throw keyData.mv_data(keyBuf); int currentSamplesCount = 0; - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); while (rc == MDB_SUCCESS && currentSamplesCount < s.MAX_SAMPLES_PER_BUCKET) { if (mdb_cmp(txn, dbi, keyData, maxKey) >= 0) { endOfRange = true; @@ -776,8 +776,8 @@ protected double cardinality(long subj, long pred, long obj, long context) throw } } } - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)); - if (rc != 0) { + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT); + if (rc != MDB_SUCCESS) { // no more elements are available endOfRange = true; } @@ -873,14 +873,14 @@ public boolean storeTriple(long subj, long pred, long obj, long context, boolean return recordCache.storeRecord(quad, explicit); } - int rc = E(mdb_put(writeTxn, mainIndex.getDB(explicit), keyVal, dataVal, MDB_NOOVERWRITE)); + int rc = mdb_put(writeTxn, mainIndex.getDB(explicit), keyVal, dataVal, MDB_NOOVERWRITE); if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) { throw new IOException(mdb_strerror(rc)); } stAdded = rc == MDB_SUCCESS; boolean foundImplicit = false; if (explicit && stAdded) { - foundImplicit = E(mdb_del(writeTxn, mainIndex.getDB(false), keyVal, dataVal)) == MDB_SUCCESS; + foundImplicit = mdb_del(writeTxn, mainIndex.getDB(false), keyVal, dataVal) == MDB_SUCCESS; } if (stAdded) { @@ -920,7 +920,7 @@ private void incrementContext(MemoryStack stack, long context) throws IOExceptio idVal.mv_data(bb); MDBVal dataVal = MDBVal.calloc(stack); long newCount = 1; - if (E(mdb_get(writeTxn, contextsDbi, idVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(writeTxn, contextsDbi, idVal, dataVal) == MDB_SUCCESS) { // update count newCount = Varint.readUnsigned(dataVal.mv_data()) + 1; } @@ -944,7 +944,7 @@ private boolean decrementContext(MemoryStack stack, long context) throws IOExcep bb.flip(); idVal.mv_data(bb); MDBVal dataVal = MDBVal.calloc(stack); - if (E(mdb_get(writeTxn, contextsDbi, idVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(writeTxn, contextsDbi, idVal, dataVal) == MDB_SUCCESS) { // update count long newCount = Varint.readUnsigned(dataVal.mv_data()) - 1; if (newCount <= 0) { diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TxnRecordCache.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TxnRecordCache.java index 27aa38d67a..73dff3fb1a 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TxnRecordCache.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/TxnRecordCache.java @@ -135,9 +135,9 @@ protected boolean update(long[] quad, boolean explicit, boolean add) throws IOEx keyBuf.flip(); keyVal.mv_data(keyBuf); - boolean foundExplicit = E(mdb_get(writeTxn, dbiExplicit, keyVal, dataVal)) == MDB_SUCCESS && + boolean foundExplicit = mdb_get(writeTxn, dbiExplicit, keyVal, dataVal) == MDB_SUCCESS && (dataVal.mv_data().get(0) & 0b1) != 0; - boolean foundImplicit = !foundExplicit && E(mdb_get(writeTxn, dbiInferred, keyVal, dataVal)) == MDB_SUCCESS + boolean foundImplicit = !foundExplicit && mdb_get(writeTxn, dbiInferred, keyVal, dataVal) == MDB_SUCCESS && (dataVal.mv_data().get(0) & 0b1) != 0; @@ -197,17 +197,13 @@ protected RecordCacheIterator(int dbi) throws IOException { } public Record next() { - try { - if (E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)) == MDB_SUCCESS) { - Varint.readListUnsigned(keyData.mv_data(), quad); - byte op = valueData.mv_data().get(0); - Record r = new Record(); - r.quad = quad; - r.add = op == 1; - return r; - } - } catch (IOException e) { - throw new SailException(e); + if (mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT) == MDB_SUCCESS) { + Varint.readListUnsigned(keyData.mv_data(), quad); + byte op = valueData.mv_data().get(0); + Record r = new Record(); + r.quad = quad; + r.add = op == 1; + return r; } close(); return null; diff --git a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStore.java b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStore.java index 9242309f42..a0ef94ce12 100644 --- a/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStore.java +++ b/core/sail/lmdb/src/main/java/org/eclipse/rdf4j/sail/lmdb/ValueStore.java @@ -214,13 +214,13 @@ class ValueStore extends AbstractValueFactory { // set cursor after max ID keyData.mv_data(stack.bytes(new byte[] { ID_KEY, (byte) 0xFF })); MDBVal valueData = MDBVal.calloc(stack); - int rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); - if (rc != 0) { + int rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); + if (rc != MDB_SUCCESS) { // directly go to last value - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_LAST)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_LAST); } else { // go to previous value of selected key - rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_PREV)); + rc = mdb_cursor_get(cursor, keyData, valueData, MDB_PREV); } if (rc == MDB_SUCCESS && keyData.mv_data().get(0) == ID_KEY) { // remove lower 2 type bits @@ -257,7 +257,7 @@ private void logValues() throws IOException { // set cursor to min key keyData.mv_data(stack.bytes(new byte[] { ID_KEY })); MDBVal valueData = MDBVal.calloc(stack); - int rc = E(mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE)); + int rc = mdb_cursor_get(cursor, keyData, valueData, MDB_SET_RANGE); while (rc == MDB_SUCCESS && keyData.mv_data().get(0) == ID_KEY) { long id = data2id(keyData.mv_data()); try { @@ -373,7 +373,7 @@ private long nextId(byte type) throws IOException { E(mdb_cursor_del(cursor, 0)); return value; } - freeIdsAvailable = E(mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT)) == MDB_SUCCESS; + freeIdsAvailable = mdb_cursor_get(cursor, keyData, valueData, MDB_NEXT) == MDB_SUCCESS; return null; } finally { if (cursor != 0) { @@ -429,7 +429,7 @@ protected byte[] getData(long id) throws IOException { MDBVal keyData = MDBVal.calloc(stack); keyData.mv_data(id2data(idBuffer(stack), id).flip()); MDBVal valueData = MDBVal.calloc(stack); - if (E(mdb_get(txn, dbi, keyData, valueData)) == MDB_SUCCESS) { + if (mdb_get(txn, dbi, keyData, valueData) == MDB_SUCCESS) { byte[] valueBytes = new byte[valueData.mv_data().remaining()]; valueData.mv_data().get(valueBytes); return valueBytes; @@ -616,7 +616,7 @@ private void incrementRefCount(MemoryStack stack, long writeTxn, byte[] data) th MDBVal dataVal = MDBVal.calloc(stack); idVal.mv_data(idBuffer(stack).put(ID_KEY).put(data, 1, idLength).flip()); long newCount = 1; - if (E(mdb_get(writeTxn, refCountsDbi, idVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(writeTxn, refCountsDbi, idVal, dataVal) == MDB_SUCCESS) { // update count newCount = Varint.readUnsigned(dataVal.mv_data()) + 1; } @@ -638,7 +638,7 @@ private boolean decrementRefCount(MemoryStack stack, long writeTxn, ByteBuffer i MDBVal idVal = MDBVal.calloc(stack); idVal.mv_data(idBb); MDBVal dataVal = MDBVal.calloc(stack); - if (E(mdb_get(writeTxn, refCountsDbi, idVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(writeTxn, refCountsDbi, idVal, dataVal) == MDB_SUCCESS) { // update count long newCount = Varint.readUnsigned(dataVal.mv_data()) - 1; if (newCount <= 0) { @@ -664,7 +664,7 @@ private long findId(byte[] data, boolean create) throws IOException { MDBVal dataVal = MDBVal.calloc(stack); dataVal.mv_data(stack.bytes(data)); MDBVal idVal = MDBVal.calloc(stack); - if (E(mdb_get(txn, dbi, dataVal, idVal)) == MDB_SUCCESS) { + if (mdb_get(txn, dbi, dataVal, idVal) == MDB_SUCCESS) { return data2id(idVal.mv_data()); } if (!create) { @@ -702,10 +702,9 @@ private long findId(byte[] data, boolean create) throws IOException { MDBVal dataVal = MDBVal.calloc(stack); // ID of first value is directly stored with hash as key - if (E(mdb_get(txn, dbi, hashVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(txn, dbi, hashVal, dataVal) == MDB_SUCCESS) { idVal.mv_data(dataVal.mv_data()); - if (E(mdb_get(txn, dbi, idVal, dataVal)) == MDB_SUCCESS && - dataVal.mv_data().compareTo(dataBb) == 0) { + if (mdb_get(txn, dbi, idVal, dataVal) == MDB_SUCCESS && dataVal.mv_data().compareTo(dataBb) == 0) { return data2id(idVal.mv_data()); } } else { @@ -745,7 +744,7 @@ private long findId(byte[] data, boolean create) throws IOException { cursor = pp.get(0); // iterate all entries for hash value - if (E(mdb_cursor_get(cursor, hashVal, dataVal, MDB_SET_RANGE)) == MDB_SUCCESS) { + if (mdb_cursor_get(cursor, hashVal, dataVal, MDB_SET_RANGE) == MDB_SUCCESS) { do { if (compareRegion(hashVal.mv_data(), 0, hashBb, 0, hashLength) != 0) { break; @@ -755,12 +754,12 @@ private long findId(byte[] data, boolean create) throws IOException { ByteBuffer hashIdBb = hashVal.mv_data(); hashIdBb.position(hashLength); idVal.mv_data(hashIdBb); - if (E(mdb_get(txn, dbi, idVal, dataVal)) == MDB_SUCCESS + if (mdb_get(txn, dbi, idVal, dataVal) == MDB_SUCCESS && dataVal.mv_data().compareTo(dataBb) == 0) { // id was found if stored value is equal to requested value return data2id(hashIdBb); } - } while (E(mdb_cursor_get(cursor, hashVal, dataVal, MDB_NEXT)) == MDB_SUCCESS); + } while (mdb_cursor_get(cursor, hashVal, dataVal, MDB_NEXT) == MDB_SUCCESS); } } finally { if (cursor != 0) { @@ -959,7 +958,7 @@ public void gcIds(Collection ids, Collection nextIds) throws IOExcep revIdVal.mv_data(id2data(revIdBb, id).flip()); // check if id has internal references and therefore cannot be deleted idVal.mv_data(revIdBb.slice().position(revLength)); - if (E(mdb_get(writeTxn, refCountsDbi, idVal, dataVal)) == MDB_SUCCESS) { + if (mdb_get(writeTxn, refCountsDbi, idVal, dataVal) == MDB_SUCCESS) { continue; } // mark id as unused @@ -998,10 +997,9 @@ protected void deleteValueToIdMappings(MemoryStack stack, long txn, Collection