-
Notifications
You must be signed in to change notification settings - Fork 166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
GH-5059 remove calls to E(...) when the return value is already being checked #5066
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We could keep the checks for the put methods to detect any MDB_MAP_FULL errors. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have access to my computer for a good week. Feel free to modify the PR and merge when you're happy with it. Otherwise I'll look at it when I'm back. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -561,7 +561,7 @@ protected void filterUsedIds(Collection<Long> 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,15 +587,15 @@ protected void filterUsedIds(Collection<Long> 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]); | ||
ids.remove(quad[1]); | ||
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<Long> it = ids.iterator(); it.hasNext();) { | ||
|
@@ -625,15 +625,15 @@ protected void filterUsedIds(Collection<Long> 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,24 +708,24 @@ 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); | ||
} | ||
|
||
// 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)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. revert this to some degree There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is actually checked right below. |
||
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) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
revert this to some degree
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some simple retry logic to this one.