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

Sync with BV branch. Committed on behalf of George Sergeev.

This commit is contained in:
dimitr 2006-04-11 06:46:57 +00:00
parent 95f9f33ee3
commit 6e0263b0b7
2 changed files with 35 additions and 5 deletions

View File

@ -366,7 +366,7 @@ extern "C" {
#error For example, consider importing library from http://www.ijs.si/software/snprintf/
#error to Firebird src\extern repository
#endif
enum {tempsize = 256};
enum {tempsize = 4096};
char temp[tempsize];
int l = VSNPRINTF(temp, tempsize, format, params);
if (l < 0) {

View File

@ -107,11 +107,29 @@ template <typename Value, typename Key = Value, typename Allocator = MallocAlloc
int NodeCount = NODE_PAGE_SIZE / sizeof(void*)>
class BePlusTree {
public:
BePlusTree(Allocator *_pool) : pool(_pool), level(0), root(NULL), defaultAccessor(this) { }
BePlusTree(Allocator *_pool)
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
{ }
BePlusTree(Allocator *_pool, const BePlusTree& from)
: pool(_pool), level(0), root(NULL), defaultAccessor(this)
{
append(from);
}
BePlusTree& operator=(const BePlusTree& from) {
clear();
append(from);
}
void clear() {
// We delete tree which was not fully created
if (!root) return;
// Do not deallocate root page if tree is shallow
if (level == 0) {
if (root) {
((ItemList*) root)->clear();
}
return;
}
// Find first items page
void *temp = root;
@ -147,6 +165,7 @@ public:
~BePlusTree() {
clear();
pool->deallocate(root);
}
bool isEmpty() const {
@ -228,6 +247,17 @@ public:
return ((NodeList*)root)->getCount() * bytes_per_node;
}
void append(const BePlusTree& from) {
// This is slow approach especially when used for assignment.
// Optimize it when need arises.
Accessor accessor(&from);
if (accessor.getFirst()) {
do {
add(accessor.current());
} while (accessor.getNext());
}
}
private:
BePlusTree(Allocator *_pool, void *rootPage) : pool(_pool), level(0),
root(new(rootPage) ItemList()), defaultAccessor(this) {}