Skip to content
This repository has been archived by the owner on Nov 4, 2024. It is now read-only.

Commit

Permalink
Change method lower_bound by replacing compare function
Browse files Browse the repository at this point in the history
  • Loading branch information
anidzgor authored and jschmieg committed Oct 3, 2017
1 parent f4b381c commit b40d4ef
Showing 1 changed file with 7 additions and 15 deletions.
22 changes: 7 additions & 15 deletions src/pmse_index_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ bool PmseCursor::lower_bound(IndexKeyEntry entry, CursorObject& cursor, std::lis
}
locks.push_back(LocksPtr(&(current->_pmutex)));
i = 0;
while (i < current->num_keys && IndexKeyEntry_PM::compareEntries(entry, current->keys[i], _ordering) > 0) {
IndexEntryComparison c(Ordering::make(_ordering));

while (i < current->num_keys && c.compare(entry, IndexKeyEntry(current->keys[i].getBSON(), RecordId(current->keys[i].loc))) > 0) {
i++;
}
// Iterated to end of node without finding bigger value
Expand Down Expand Up @@ -367,35 +369,25 @@ boost::optional<IndexKeyEntry> PmseCursor::seek(const IndexSeekPoint& seekPoint,
RequestedInfo parts = kKeyAndLoc) {
if (!_tree->_root)
return {};

const BSONObj query = IndexEntryComparison::makeQueryObject(seekPoint, _forward);
auto discriminator = RecordId::min();
bool gt = false;
std::list<LocksPtr> locks;
BSONObjIterator lhsIt(query);
while (lhsIt.more()) {
const BSONElement l = lhsIt.next();
BehaviorIfFieldIsEqual lEqBehavior = BehaviorIfFieldIsEqual(l.fieldName()[0]);
if (lEqBehavior) {
if (lEqBehavior == greater) {
gt = true;
}
}
}
locate(query, _forward ? RecordId::min() : RecordId::max(), locks);

if (_isEOF) {
unlockTree(locks);
return {};
}
if (gt)
if (query.woCompare(_cursor.node->keys[_cursor.index].getBSON(), _ordering, false) == 0)
next(parts);

if (_cursor.node.raw_ptr()->off != 0) {
_cursorKey = _cursor.node->keys[_cursor.index].getBSON();
_cursorId = _cursor.node->keys[_cursor.index].loc;
// remember next value
} else {
_eofRestore = true;
}

unlockTree(locks);
return IndexKeyEntry((_cursor.node->keys[_cursor.index]).getBSON(),
RecordId((_cursor.node->keys[_cursor.index]).loc));
Expand Down

0 comments on commit b40d4ef

Please sign in to comment.