From 3fd11e11173cec58672f4b254e10ed2ea5611f61 Mon Sep 17 00:00:00 2001 From: Ethereal Date: Mon, 21 Feb 2011 02:46:04 -0700 Subject: [PATCH] Fixed two bugs in the RTree insertion implementation. --- include/storage/RTree.h | 8 +++++++- modules/informer/src/collector/Informer.c | 2 +- src/monitor/Aesalon.cpp | 21 +++++++++------------ 3 files changed, 17 insertions(+), 14 deletions(-) diff --git a/include/storage/RTree.h b/include/storage/RTree.h index aeb8a83..a1e19b3 100644 --- a/include/storage/RTree.h +++ b/include/storage/RTree.h @@ -232,6 +232,8 @@ void RTree::insert( newRoot->branch(0).node = m_root; newRoot->branch(1).bound = result->bound(); newRoot->branch(1).node = result; + m_root->setParent(newRoot); + result->setParent(newRoot); m_root = newRoot; } @@ -284,12 +286,16 @@ typename RTree::Node * Node *node = m_root; while(!node->isLeaf()) { + Message(Debug, "Node is not leaf node, continuing downwards . . ."); Node *smallestNode = NULL; Key smallestVolume = 0; for(int i = 0; i < node->branchCount(); i ++) { Key volume = bound.enlargementToCover(node->branch(i).bound); - if(volume < smallestVolume || smallestNode == NULL) smallestNode = node, smallestVolume = volume; + if(volume < smallestVolume || smallestNode == NULL) { + smallestNode = node->branch(i).node; + smallestVolume = volume; + } else if(volume == smallestVolume) { /* TODO: implement tiebreaker. */ Message(Debug, "RTree: smallestVolume tie-breaker not implemented!"); diff --git a/modules/informer/src/collector/Informer.c b/modules/informer/src/collector/Informer.c index e474c4a..c807ccb 100644 --- a/modules/informer/src/collector/Informer.c +++ b/modules/informer/src/collector/Informer.c @@ -124,7 +124,7 @@ static void *AI_SetupZone() { /* Just temporarily use recursion to fix the problem. Note: don't try this at home . . . */ AI_SetupZone(); } - AI_InformerData.zoneUseData[i/i] |= (0x01 << (i%8)); + AI_InformerData.zoneUseData[i/8] |= (0x01 << (i%8)); AI_Zone = AI_MapSHM( AI_InformerData.shmHeader->zonePageOffset + (i*AI_InformerData.shmHeader->zoneSize), diff --git a/src/monitor/Aesalon.cpp b/src/monitor/Aesalon.cpp index 328f6db..a655ff2 100644 --- a/src/monitor/Aesalon.cpp +++ b/src/monitor/Aesalon.cpp @@ -6,12 +6,13 @@ @file src/monitor/Aesalon.cpp */ +#include #include "monitor/Coordinator.h" #include "storage/RTree.h" -#if 1 +#if 0 int main(int argc, char *argv[]) { Monitor::Coordinator coordinator(argv); coordinator.run(); @@ -26,17 +27,13 @@ int main(int argc, char *argv[]) { RTree rt; RTree::Bound b; - b.setRange(RTree::Range(-2.0, 2.0), 0); - rt.insert(b, 0); - b.setRange(RTree::Range(-1.0, 1.0), 0); - rt.insert(b, 1); - b.setRange(RTree::Range(-1.5, 1.0), 0); - rt.insert(b, 2); - - b.setRange(RTree::Range(3.5, 6.0), 0); - rt.insert(b, 3); - b.setRange(RTree::Range(-6.0, -3.5), 0); - rt.insert(b, 4); + + for(int i = 0; i < 900; i ++) { + double start = (rand()%1000)/10.0; + double size = (rand()%100)/10.0; + b.setRange(RTree::Range(start, start+size), 0); + rt.insert(b, i); + } class Processor : public RTree::SearchProcessor { public: -- 2.11.4.GIT