Changeset 67
- Timestamp:
- 01/25/08 12:43:36
- Files:
-
- spatialindex/trunk/include/MVRTree.h (modified) (1 diff)
- spatialindex/trunk/include/RTree.h (modified) (1 diff)
- spatialindex/trunk/include/SpatialIndex.h (modified) (2 diffs)
- spatialindex/trunk/include/tools/Tools.h (modified) (5 diffs)
- spatialindex/trunk/include/TPRTree.h (modified) (1 diff)
- spatialindex/trunk/makefile.vc (modified) (5 diffs)
- spatialindex/trunk/src/mvrtree/Index.cc (modified) (1 diff)
- spatialindex/trunk/src/mvrtree/Leaf.cc (modified) (1 diff)
- spatialindex/trunk/src/mvrtree/Node.cc (modified) (2 diffs)
- spatialindex/trunk/src/rtree/BulkLoader.cc (modified) (4 diffs)
- spatialindex/trunk/src/rtree/Index.cc (modified) (1 diff)
- spatialindex/trunk/src/rtree/Leaf.cc (modified) (1 diff)
- spatialindex/trunk/src/rtree/Node.cc (modified) (1 diff)
- spatialindex/trunk/src/spatialindex/LineSegment.cc (modified) (2 diffs)
- spatialindex/trunk/src/spatialindex/MovingRegion.cc (modified) (1 diff)
- spatialindex/trunk/src/storagemanager/Buffer.cc (modified) (1 diff)
- spatialindex/trunk/src/storagemanager/DiskStorageManager.cc (modified) (1 diff)
- spatialindex/trunk/src/storagemanager/RandomEvictionsBuffer.cc (modified) (3 diffs)
- spatialindex/trunk/src/tools/ExternalSort.cc (modified) (11 diffs)
- spatialindex/trunk/src/tools/ExternalSort.h (modified) (1 diff)
- spatialindex/trunk/src/tools/TemporaryFile.cc (modified) (4 diffs)
- spatialindex/trunk/src/tools/Tools.cc (modified) (1 diff)
- spatialindex/trunk/src/tprtree/Index.cc (modified) (1 diff)
- spatialindex/trunk/src/tprtree/Leaf.cc (modified) (1 diff)
- spatialindex/trunk/src/tprtree/Node.cc (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spatialindex/trunk/include/MVRTree.h
r2 r67 66 66 }; // Data 67 67 68 extern ISpatialIndex* returnMVRTree(IStorageManager& in , Tools::PropertySet& in);68 extern ISpatialIndex* returnMVRTree(IStorageManager& ind, Tools::PropertySet& in); 69 69 extern ISpatialIndex* createNewMVRTree( 70 70 IStorageManager& in, spatialindex/trunk/include/RTree.h
r2 r67 71 71 }; // Data 72 72 73 extern ISpatialIndex* returnRTree(IStorageManager& in , Tools::PropertySet& in);73 extern ISpatialIndex* returnRTree(IStorageManager& ind, Tools::PropertySet& in); 74 74 extern ISpatialIndex* createNewRTree( 75 75 IStorageManager& sm, spatialindex/trunk/include/SpatialIndex.h
r33 r67 25 25 #include "tools/Tools.h" 26 26 using namespace Tools; 27 28 # if !HAVE_MEMCPY29 # define memcpy(d, s, n) bcopy ((s), (d), (n))30 # define memmove(d, s, n) bcopy ((s), (d), (n))31 # endif32 27 // 28 //# if !HAVE_MEMCPY 29 //# define memcpy(d, s, n) bcopy ((s), (d), (n)) 30 //# define memmove(d, s, n) bcopy ((s), (d), (n)) 31 //# endif 32 // 33 33 # if !HAVE_BZERO 34 34 # define bzero(d, n) memset((d), 0, (n)) 35 35 # endif 36 37 #ifndef M_PI_2 38 #define M_PI_2 1.57079632679489661922 39 #endif 40 36 41 37 42 namespace SpatialIndex … … 217 222 extern IStorageManager* loadDiskStorageManager(std::string& baseName); 218 223 219 extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& in , Tools::PropertySet& in);224 extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& ind, Tools::PropertySet& in); 220 225 extern IBuffer* createNewRandomEvictionsBuffer(IStorageManager& in, size_t capacity, bool bWriteThrough); 221 226 } spatialindex/trunk/include/tools/Tools.h
r33 r67 23 23 #define __tools_h 24 24 25 #include <stdint.h> 25 #ifdef _MSC_VER 26 typedef signed char int8_t; 27 typedef short int int16_t; 28 typedef int int32_t; 29 typedef __int64 int64_t; 30 typedef unsigned char uint8_t; 31 typedef unsigned short int uint16_t; 32 typedef unsigned int uint32_t; 33 typedef unsigned __int64 uint64_t; 34 #else 35 #include <stdint.h> 36 #endif 37 38 //#include <stdint.h> 26 39 #include <assert.h> 27 40 #include <iostream> … … 183 196 virtual void setBounds(double, double) = 0; 184 197 virtual bool intersectsInterval(const IInterval&) const = 0; 185 virtual bool intersectsInterval(IntervalType type, double start,double end) const = 0;198 virtual bool intersectsInterval(IntervalType type, const double start, const double end) const = 0; 186 199 virtual bool containsInterval(const IInterval&) const = 0; 187 200 virtual IntervalType getIntervalType() const = 0; … … 276 289 } m_val; 277 290 }; // Variant 278 291 292 class PropertySet; 293 std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p); 294 279 295 class PropertySet : public ISerializable 280 296 { … … 301 317 }; // PropertySet 302 318 303 std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p); 319 304 320 305 321 // does not support degenerate intervals. … … 319 335 virtual void setBounds(double, double); 320 336 virtual bool intersectsInterval(const IInterval&) const; 321 virtual bool intersectsInterval(IntervalType type, double start,double end) const;337 virtual bool intersectsInterval(IntervalType type, const double start, const double end) const; 322 338 virtual bool containsInterval(const IInterval&) const; 323 339 virtual IntervalType getIntervalType() const; spatialindex/trunk/include/TPRTree.h
r2 r67 64 64 }; // Data 65 65 66 extern ISpatialIndex* returnTPRTree(IStorageManager& in , Tools::PropertySet& in);66 extern ISpatialIndex* returnTPRTree(IStorageManager& ind, Tools::PropertySet& in); 67 67 extern ISpatialIndex* createNewTPRTree( 68 68 IStorageManager& sm, spatialindex/trunk/makefile.vc
r64 r67 22 22 #CFLAGS = -Iheaders /GX /MD /GR /Zi /nologo 23 23 #CFLAGS = -Iheaders /GX /MD /GR /O1 /D "NDEBUG" /nologo 24 CFLAGS = -Iinclude /MD /GR /O2 /D "NDEBUG" /nologo $(MSVC_CPPFLAGS)24 CFLAGS = -Iinclude /MD /GR /O2 /D "NDEBUG" /D "PACKAGE_BUGREPORT=\"hobu.inc@gmail.com\"" /nologo $(MSVC_CPPFLAGS) 25 25 26 26 … … 29 29 DLLNAME = spatialindex$(VERSION).dll 30 30 31 LAS_DIRLIST = src\mvrtree \ 32 src\rtree \ 33 src\spatialindex \ 34 src\storagemanager \ 35 src\tools \ 36 src\tprtree 37 31 38 OBJ = src\mvrtree\Index.obj \ 32 39 src\mvrtree\Leaf.obj \ 33 40 src\mvrtree\MVRtree.obj \ 34 41 src\mvrtree\Node.obj \ 35 src\mvrtree\PointerPoolNode.obj \36 42 src\mvrtree\Statistics.obj \ 37 43 src\rtree\BulkLoader.obj \ … … 39 45 src\rtree\Leaf.obj \ 40 46 src\rtree\Node.obj \ 41 src\rtree\PointerPoolNode.obj \42 47 src\rtree\RTree.obj \ 43 48 src\rtree\Statistics.obj \ … … 51 56 src\spatialindex\TimeRegion.obj \ 52 57 src\storagemanager\Buffer.obj \ 53 src\storagemanager\DiskStorageManager.obj \58 # src\storagemanager\DiskStorageManager.obj \ 54 59 src\storagemanager\MemoryStorageManager.obj \ 55 60 src\storagemanager\RandomEvictionsBuffer.obj \ 56 61 src\tools\ExternalSort.obj \ 57 62 src\tools\TemporaryFile.obj \ 63 src\tools\rand48.obj \ 58 64 src\tools\Tools.obj \ 59 65 src\tprtree\Index.obj \ 60 66 src\tprtree\Leaf.obj \ 61 67 src\tprtree\Node.obj \ 62 src\tprtree\PointerPoolNode.obj \63 68 src\tprtree\Statistics.obj \ 64 69 src\tprtree\TPRTree.obj … … 93 98 $(RM) *.obj 94 99 $(RM) *.pdb 95 100 for %d in ( $(LAS_DIRLIST) ) do \ 101 del %d\*.obj 96 102 spatialindex/trunk/src/mvrtree/Index.cc
r33 r67 27 27 28 28 using namespace SpatialIndex::MVRTree; 29 29 typedef SpatialIndex::id_type id_type; 30 typedef SpatialIndex::TimeRegion TimeRegion; 31 30 32 Index::~Index() 31 33 { spatialindex/trunk/src/mvrtree/Leaf.cc
r33 r67 26 26 #include "Leaf.h" 27 27 28 typedef SpatialIndex::id_type id_type; 29 typedef SpatialIndex::TimeRegion TimeRegion; 28 30 using namespace SpatialIndex::MVRTree; 29 31 spatialindex/trunk/src/mvrtree/Node.cc
r33 r67 27 27 28 28 using namespace SpatialIndex::MVRTree; 29 typedef SpatialIndex::IShape IShape; 30 typedef SpatialIndex::id_type id_type; 31 typedef SpatialIndex::TimeRegion TimeRegion; 29 32 30 33 // … … 792 795 } 793 796 // duplicate entries have been removed and the set is sorted 794 size_t SiCounts[Si.size() - 1]; 795 bzero(SiCounts, (Si.size() - 1) * sizeof(size_t)); 796 797 // size_t SiCounts[Si.size() - 1]; 798 // bzero(SiCounts, (Si.size() - 1) * sizeof(size_t)); 799 size_t *SiCounts; 800 SiCounts = (size_t*) malloc((Si.size()-1)*sizeof(size_t)); 801 797 802 for (size_t cSiblingChild = 0; cSiblingChild < sibling->m_children; cSiblingChild++) 798 803 { spatialindex/trunk/src/rtree/BulkLoader.cc
r33 r67 21 21 22 22 #include <stdio.h> 23 24 #ifndef _MSC_VER 23 25 #include <unistd.h> 26 #endif 24 27 25 28 #include "../spatialindex/SpatialIndexImpl.h" … … 223 226 224 227 void BulkLoader::bulkLoadUsingSTR( 225 RTree* pTree,228 SpatialIndex::RTree::RTree* pTree, 226 229 IDataStream& stream, 227 230 size_t bindex, … … 276 279 277 280 void BulkLoader::createLevel( 278 RTree* pTree,281 SpatialIndex::RTree::RTree* pTree, 279 282 Tools::IObjectStream& stream, 280 283 size_t dimension, … … 339 342 } 340 343 341 Node* BulkLoader::createNode( RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, size_t level)344 Node* BulkLoader::createNode(SpatialIndex::RTree::RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, size_t level) 342 345 { 343 346 Node* n; spatialindex/trunk/src/rtree/Index.cc
r33 r67 32 32 } 33 33 34 Index::Index( RTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity)34 Index::Index(SpatialIndex::RTree::RTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 35 35 { 36 36 } spatialindex/trunk/src/rtree/Leaf.cc
r33 r67 32 32 } 33 33 34 Leaf::Leaf( RTree* pTree, id_type id): Node(pTree, id, 0, pTree->m_leafCapacity)34 Leaf::Leaf(SpatialIndex::RTree::RTree* pTree, id_type id): Node(pTree, id, 0, pTree->m_leafCapacity) 35 35 { 36 36 } spatialindex/trunk/src/rtree/Node.cc
r33 r67 215 215 } 216 216 217 Node::Node( RTree* pTree, id_type id, size_t level, size_t capacity) :217 Node::Node(SpatialIndex::RTree::RTree* pTree, id_type id, size_t level, size_t capacity) : 218 218 m_pTree(pTree), 219 219 m_level(level), spatialindex/trunk/src/spatialindex/LineSegment.cc
r34 r67 173 173 void LineSegment::getCenter(Point& out) const 174 174 { 175 double coords[m_dimension]; 176 175 // double coords[m_dimension]; 176 double *coords; 177 coords = (double*) malloc(m_dimension * sizeof(double)); 177 178 for (size_t cDim = 0; cDim < m_dimension; cDim++) 178 179 { … … 192 193 void LineSegment::getMBR(Region& out) const 193 194 { 194 double low[m_dimension]; 195 double high[m_dimension]; 196 195 //double low[m_dimension]; 196 //double high[m_dimension]; 197 double *low; 198 double *high; 199 low = (double*) malloc(m_dimension * sizeof(double)); 200 high = (double*) malloc(m_dimension * sizeof(double)); 197 201 for (size_t cDim = 0; cDim < m_dimension; cDim++) 198 202 { spatialindex/trunk/src/spatialindex/MovingRegion.cc
r33 r67 581 581 double H = tmax - tmin; 582 582 583 double dx[m_dimension], dv[m_dimension]; 583 // double dx[m_dimension], dv[m_dimension]; 584 double *dx; 585 double *dv; 586 dx = (double*) malloc(m_dimension * sizeof(double)); 587 dv = (double*) malloc(m_dimension * sizeof(double)); 584 588 double a = 0.0, b = 0.0, c = 0.0, f = 0.0, l = 0.0, m = 0.0, n = 0.0; 585 589 spatialindex/trunk/src/storagemanager/Buffer.cc
r33 r67 25 25 using namespace SpatialIndex::StorageManager; 26 26 using std::map; 27 27 typedef SpatialIndex::id_type id_type; 28 typedef SpatialIndex::TimeRegion TimeRegion; 29 28 30 Buffer::Buffer(IStorageManager& sm, Tools::PropertySet& ps) : 29 31 m_capacity(10), spatialindex/trunk/src/storagemanager/DiskStorageManager.cc
r33 r67 20 20 // mhadji@gmail.com 21 21 22 #ifndef _MSC_VER 22 23 #include <unistd.h> 24 #endif 25 23 26 #include <fcntl.h> 24 27 #include <sys/types.h> spatialindex/trunk/src/storagemanager/RandomEvictionsBuffer.cc
r33 r67 22 22 #include <time.h> 23 23 #include <stdlib.h> 24 #include "../include/tools/rand48.hpp" 24 25 25 26 #include "../spatialindex/SpatialIndexImpl.h" … … 53 54 RandomEvictionsBuffer::RandomEvictionsBuffer(IStorageManager& sm, Tools::PropertySet& ps) : Buffer(sm, ps) 54 55 { 56 55 57 srand48(time(NULL)); 56 58 } … … 73 75 if (m_buffer.size() == 0) return; 74 76 75 size_t entry = static_cast<size_t>(floor(((double) m_buffer.size()) * drand48())); 77 double random; 78 79 random = drand48(); 80 81 size_t entry = static_cast<size_t>(floor(((double) m_buffer.size()) * random)); 76 82 77 83 std::map<id_type, Entry*>::iterator it = m_buffer.begin(); spatialindex/trunk/src/tools/ExternalSort.cc
r34 r67 1 // Spatial Index Library 1 2 // Tools Library 2 3 // 3 4 // Copyright (C) 2004 Navel Ltd. … … 21 22 22 23 #include <stdio.h> 23 #include <unistd.h> 24 25 #include "../../include/tools/Tools.h" 24 25 #include "../include/tools/Tools.h" 26 26 27 #include "ExternalSort.h" 27 28 … … 75 76 size_t bufferSize 76 77 ) 77 : m_cMaxBufferSize(bufferSize),78 m_bFitsInBuffer(false),79 m_cNumberOfSortedRecords(0),80 m_cNumberOfReturnedRecords(0),81 m_pExternalSource(&source),82 m_pTemplateRecord(0),83 m_pComparator(0)78 : m_cMaxBufferSize(bufferSize), 79 m_bFitsInBuffer(false), 80 m_cNumberOfSortedRecords(0), 81 m_cNumberOfReturnedRecords(0), 82 m_pExternalSource(&source), 83 m_pTemplateRecord(0), 84 m_pComparator(0) 84 85 { 85 86 mergeRuns(); … … 91 92 size_t bufferSize 92 93 ) 93 : m_cMaxBufferSize(bufferSize),94 m_bFitsInBuffer(false),95 m_cNumberOfSortedRecords(0),96 m_cNumberOfReturnedRecords(0),97 m_pExternalSource(&source),98 m_pTemplateRecord(0),99 m_pComparator(&comp)94 : m_cMaxBufferSize(bufferSize), 95 m_bFitsInBuffer(false), 96 m_cNumberOfSortedRecords(0), 97 m_cNumberOfReturnedRecords(0), 98 m_pExternalSource(&source), 99 m_pTemplateRecord(0), 100 m_pComparator(&comp) 100 101 { 101 102 mergeRuns(); … … 137 138 m_cNumberOfSortedRecords++; 138 139 139 //if (m_cNumberOfSortedRecords % 1000000 == 0) 140 // std::cerr 141 // << "Tools::ExternalSort::initializeRuns: loaded " 142 // << m_cNumberOfSortedRecords << " objects." << std::endl; 140 #ifdef DEBUG 141 if (m_cNumberOfSortedRecords % 1000000 == 0) 142 std::cerr 143 << "Tools::ExternalSort::initializeRuns: loaded " 144 << m_cNumberOfSortedRecords << std::endl; 145 #endif 143 146 144 147 if (m_pTemplateRecord == 0) … … 177 180 while (runs.size() > 1) 178 181 { 179 TemporaryFile* output = 0; 180 output = new TemporaryFile(); 182 TemporaryFile* output = new TemporaryFile(); 181 183 182 184 priority_queue< … … 185 187 PQEntry::ascendingComparator> buffer; 186 188 187 uint32_t cRun = 0, cMaxRun = 0;189 size_t cRun = 0, cMaxRun = 0; 188 190 size_t len; 189 191 byte* data; … … 201 203 buffer.push(new PQEntry(pS, m_pComparator, runs[cRun])); 202 204 } 203 catch (EndOfStreamException & e)205 catch (EndOfStreamException) 204 206 { 205 207 // if there are no more records in the file, do nothing. … … 221 223 buffer.push(pqe); 222 224 } 223 catch (EndOfStreamException & e)225 catch (EndOfStreamException) 224 226 { 225 227 // if there are no more records in the file, do nothing. … … 229 231 { 230 232 delete pqe; 231 delete output;232 233 throw; 233 234 } … … 296 297 } 297 298 } 298 spatialindex/trunk/src/tools/ExternalSort.h
r34 r67 1 // Spatial IndexLibrary1 // Tools Library 2 2 // 3 3 // Copyright (C) 2004 Navel Ltd. spatialindex/trunk/src/tools/TemporaryFile.cc
r34 r67 1 // Spatial IndexLibrary1 // Tools Library 2 2 // 3 3 // Copyright (C) 2004 Navel Ltd. … … 20 20 // mhadji@gmail.com 21 21 22 #include <stdio.h> 23 #include <unistd.h> 24 25 #include "../../include/tools/Tools.h" 22 #include <io.h> 23 24 #include "../include/tools/Tools.h" 26 25 27 26 Tools::TemporaryFile::TemporaryFile() 28 : m_currentFile(0),29 m_fileSize(0),30 m_bEOF(false)27 : m_currentFile(0), 28 m_fileSize(0), 29 m_bEOF(false) 31 30 { 32 31 char p[5 + 6] = "tmpfXXXXXX"; 33 int fd = mkstemp(p); 34 if (fd == -1) 32 if (_mktemp(p) != 0) 35 33 throw IllegalStateException( 36 34 "Tools::TemporaryFile::TemporaryFile: Cannot create tmp file." 37 35 ); 38 close(fd);39 36 40 37 m_file.open(p, std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary); … … 70 67 { 71 68 char p[5 + 6] = "tmpfXXXXXX"; 72 int fd = mkstemp(p); 73 if (fd == -1) 69 if (_mktemp(p) != 0) 74 70 throw IllegalStateException( 75 71 "Tools::TemporaryFile::storeNextObject: Cannot create tmp file." 76 72 ); 77 close(fd);78 73 79 74 m_file.close(); … … 237 232 m_bEOF = false; 238 233 } 239 spatialindex/trunk/src/tools/Tools.cc
r34 r67 21 21 22 22 #include "../../include/tools/Tools.h" 23 #include "../../include/tools/rand48.hpp" 24 23 25 #include "ExternalSort.h" 24 26 spatialindex/trunk/src/tprtree/Index.cc
r33 r67 32 32 } 33 33 34 Index::Index( TPRTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity)34 Index::Index(SpatialIndex::TPRTree::TPRTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 35 35 { 36 36 } spatialindex/trunk/src/tprtree/Leaf.cc
r33 r67 32 32 } 33 33 34 Leaf::Leaf( TPRTree* pTree, id_type id)34 Leaf::Leaf(SpatialIndex::TPRTree::TPRTree* pTree, id_type id) 35 35 : Node(pTree, id, 0, pTree->m_leafCapacity) 36 36 { spatialindex/trunk/src/tprtree/Node.cc
r33 r67 248 248 } 249 249 250 Node::Node( TPRTree* pTree, id_type id, size_t level, size_t capacity) :250 Node::Node(SpatialIndex::TPRTree::TPRTree* pTree, id_type id, size_t level, size_t capacity) : 251 251 m_pTree(pTree), 252 252 m_level(level),
