8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 06:03:02 +01:00

Implement improvement CORE-1070 : Optimize sparse bitmap operations (set, test and clear) with mostly consecutive values

This commit is contained in:
hvlad 2006-12-27 21:30:04 +00:00
parent fe1ec3ccba
commit 2b771cc6eb
2 changed files with 12 additions and 5 deletions

View File

@ -119,7 +119,7 @@ public:
const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
if (tree.locate(val_aligned)) {
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
tree.current().bits |= bit_mask;
}
else {
@ -142,7 +142,7 @@ public:
}
const T val_aligned = value & ~(T)(BUNCH_BITS - 1);
if (tree.locate(val_aligned)) {
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
Bucket *current_bucket = &tree.current();
if (current_bucket->bits & bit_mask) {
@ -162,10 +162,9 @@ public:
}
const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
BitmapTreeAccessor i(&tree); // Use accessor to be const-correct
if (i.locate(val_aligned)) {
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
return i.current().bits & bit_mask;
return tree.current().bits & bit_mask;
}
return false;
}

View File

@ -178,6 +178,8 @@ public:
// Remove item. Current position moves to next item after this call.
// If next item doesn't exist method returns false
bool fastRemove() { return defaultAccessor.fastRemove(); }
bool found(const Key& key) const { return defaultAccessor.found(key); }
bool locate(const Key& key) { return defaultAccessor.locate(locEqual, key); }
@ -399,6 +401,12 @@ public:
return true;
}
bool found(const Key& key) const
{
return (curr && curPos < curr->getCount() &&
KeyOfValue::generate(this, current()) == key);
}
bool locate(const Key& key) {
return locate(locEqual, key);
}