Created
March 13, 2017 20:38
-
-
Save markpapadakis/c10c10ab9d84825d699b6dc27953cfc1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bool Trinity::updated_documents_scanner::test(const uint32_t id) noexcept | |
{ | |
if (id >= curBankRange.start()) | |
{ | |
if (id < curBankRange.stop()) | |
{ | |
return SwitchBitOps::Bitmap<uint64_t>::IsSet((uint64_t *)curBank, id - curBankRange.offset); | |
} | |
else if (skiplistBase == end) | |
{ | |
reset(); | |
return false; | |
} | |
else | |
{ | |
// skip ahead using binary search | |
const auto it = std::lower_bound(skiplistBase + 1, end, id); | |
if (it == end) | |
{ | |
reset(); | |
return false; | |
} | |
else | |
{ | |
skiplistBase = it; | |
curBankRange.Set(*skiplistBase, bankSize); | |
curBank = udBanks + ((skiplistBase - udSkipList) * (bankSize / 8)); | |
if (curBankRange.Contains(id)) | |
{ | |
// this is is important | |
// imagine if cur bank range is [1, 65) and second bank is [150, 215) | |
// and id is 68 | |
// then we 'd skip to [150, 215) bank but | |
// that's ahead of our target(68) | |
return SwitchBitOps::Bitmap<uint64_t>::IsSet((uint64_t *)curBank, id - curBankRange.offset); | |
} | |
else | |
{ | |
return false; | |
} | |
} | |
} | |
} | |
else | |
{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment