Changeset 67

Show
Ignore:
Timestamp:
01/25/08 12:43:36
Author:
hobu
Message:

Initial push of windows patches

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spatialindex/trunk/include/MVRTree.h

    r2 r67  
    6666                }; // Data 
    6767 
    68                 extern ISpatialIndex* returnMVRTree(IStorageManager& in, Tools::PropertySet& in); 
     68                extern ISpatialIndex* returnMVRTree(IStorageManager& ind, Tools::PropertySet& in); 
    6969                extern ISpatialIndex* createNewMVRTree( 
    7070                        IStorageManager& in, 
  • spatialindex/trunk/include/RTree.h

    r2 r67  
    7171                }; // Data 
    7272 
    73                 extern ISpatialIndex* returnRTree(IStorageManager& in, Tools::PropertySet& in); 
     73                extern ISpatialIndex* returnRTree(IStorageManager& ind, Tools::PropertySet& in); 
    7474                extern ISpatialIndex* createNewRTree( 
    7575                        IStorageManager& sm, 
  • spatialindex/trunk/include/SpatialIndex.h

    r33 r67  
    2525#include "tools/Tools.h" 
    2626using namespace Tools; 
    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  
     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// 
    3333# if !HAVE_BZERO 
    3434#  define bzero(d, n) memset((d), 0, (n)) 
    3535# endif 
     36 
     37#ifndef M_PI_2 
     38        #define M_PI_2 1.57079632679489661922 
     39#endif 
     40 
    3641 
    3742namespace SpatialIndex 
     
    217222                extern IStorageManager* loadDiskStorageManager(std::string& baseName); 
    218223 
    219                 extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& in, Tools::PropertySet& in); 
     224                extern IBuffer* returnRandomEvictionsBuffer(IStorageManager& ind, Tools::PropertySet& in); 
    220225                extern IBuffer* createNewRandomEvictionsBuffer(IStorageManager& in, size_t capacity, bool bWriteThrough); 
    221226        } 
  • spatialindex/trunk/include/tools/Tools.h

    r33 r67  
    2323#define __tools_h 
    2424 
    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> 
    2639#include <assert.h> 
    2740#include <iostream> 
     
    183196                virtual void setBounds(double, double) = 0; 
    184197                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; 
    186199                virtual bool containsInterval(const IInterval&) const = 0; 
    187200                virtual IntervalType getIntervalType() const = 0; 
     
    276289                } m_val; 
    277290        }; // Variant 
    278  
     291         
     292        class PropertySet; 
     293        std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p); 
     294             
    279295        class PropertySet : public ISerializable 
    280296        { 
     
    301317        }; // PropertySet 
    302318 
    303         std::ostream& operator<<(std::ostream& os, const Tools::PropertySet& p); 
     319 
    304320 
    305321        // does not support degenerate intervals. 
     
    319335                virtual void setBounds(double, double); 
    320336                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; 
    322338                virtual bool containsInterval(const IInterval&) const; 
    323339                virtual IntervalType getIntervalType() const; 
  • spatialindex/trunk/include/TPRTree.h

    r2 r67  
    6464                }; // Data 
    6565 
    66                 extern ISpatialIndex* returnTPRTree(IStorageManager& in, Tools::PropertySet& in); 
     66                extern ISpatialIndex* returnTPRTree(IStorageManager& ind, Tools::PropertySet& in); 
    6767                extern ISpatialIndex* createNewTPRTree( 
    6868                        IStorageManager& sm, 
  • spatialindex/trunk/makefile.vc

    r64 r67  
    2222#CFLAGS = -Iheaders /GX /MD /GR /Zi /nologo 
    2323#CFLAGS = -Iheaders /GX /MD /GR /O1 /D "NDEBUG" /nologo 
    24 CFLAGS = -Iinclude /MD /GR /O2 /D "NDEBUG" /nologo $(MSVC_CPPFLAGS) 
     24CFLAGS = -Iinclude /MD /GR /O2 /D "NDEBUG" /D "PACKAGE_BUGREPORT=\"hobu.inc@gmail.com\"" /nologo $(MSVC_CPPFLAGS) 
    2525 
    2626 
     
    2929DLLNAME =       spatialindex$(VERSION).dll 
    3030 
     31LAS_DIRLIST =  src\mvrtree \ 
     32                src\rtree \ 
     33                src\spatialindex \ 
     34                src\storagemanager \ 
     35                src\tools \ 
     36                src\tprtree 
     37 
    3138OBJ =   src\mvrtree\Index.obj \ 
    3239        src\mvrtree\Leaf.obj \ 
    3340        src\mvrtree\MVRtree.obj \ 
    3441        src\mvrtree\Node.obj \ 
    35         src\mvrtree\PointerPoolNode.obj \ 
    3642        src\mvrtree\Statistics.obj \ 
    3743        src\rtree\BulkLoader.obj \ 
     
    3945        src\rtree\Leaf.obj \ 
    4046        src\rtree\Node.obj \ 
    41         src\rtree\PointerPoolNode.obj \ 
    4247        src\rtree\RTree.obj \ 
    4348        src\rtree\Statistics.obj \ 
     
    5156        src\spatialindex\TimeRegion.obj \ 
    5257        src\storagemanager\Buffer.obj \ 
    53         src\storagemanager\DiskStorageManager.obj \ 
     58#        src\storagemanager\DiskStorageManager.obj \ 
    5459        src\storagemanager\MemoryStorageManager.obj \ 
    5560        src\storagemanager\RandomEvictionsBuffer.obj \ 
    5661        src\tools\ExternalSort.obj \ 
    5762        src\tools\TemporaryFile.obj \ 
     63        src\tools\rand48.obj \ 
    5864        src\tools\Tools.obj \ 
    5965        src\tprtree\Index.obj \ 
    6066        src\tprtree\Leaf.obj \ 
    6167        src\tprtree\Node.obj \ 
    62         src\tprtree\PointerPoolNode.obj \ 
    6368        src\tprtree\Statistics.obj \ 
    6469        src\tprtree\TPRTree.obj  
     
    9398        $(RM) *.obj 
    9499        $(RM) *.pdb 
    95          
     100        for %d in ( $(LAS_DIRLIST) ) do \ 
     101                del %d\*.obj     
    96102 
  • spatialindex/trunk/src/mvrtree/Index.cc

    r33 r67  
    2727 
    2828using namespace SpatialIndex::MVRTree; 
    29  
     29typedef SpatialIndex::id_type id_type; 
     30typedef SpatialIndex::TimeRegion TimeRegion; 
     31     
    3032Index::~Index() 
    3133{ 
  • spatialindex/trunk/src/mvrtree/Leaf.cc

    r33 r67  
    2626#include "Leaf.h" 
    2727 
     28typedef SpatialIndex::id_type id_type; 
     29typedef SpatialIndex::TimeRegion TimeRegion; 
    2830using namespace SpatialIndex::MVRTree; 
    2931 
  • spatialindex/trunk/src/mvrtree/Node.cc

    r33 r67  
    2727 
    2828using namespace SpatialIndex::MVRTree; 
     29typedef SpatialIndex::IShape IShape; 
     30typedef SpatialIndex::id_type id_type; 
     31typedef SpatialIndex::TimeRegion TimeRegion; 
    2932 
    3033// 
     
    792795                                        } 
    793796                                        // 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                     
    797802                                        for (size_t cSiblingChild = 0; cSiblingChild < sibling->m_children; cSiblingChild++) 
    798803                                        { 
  • spatialindex/trunk/src/rtree/BulkLoader.cc

    r33 r67  
    2121 
    2222#include <stdio.h> 
     23 
     24#ifndef _MSC_VER 
    2325#include <unistd.h> 
     26#endif 
    2427 
    2528#include "../spatialindex/SpatialIndexImpl.h" 
     
    223226 
    224227void BulkLoader::bulkLoadUsingSTR( 
    225         RTree* pTree, 
     228        SpatialIndex::RTree::RTree* pTree, 
    226229        IDataStream& stream, 
    227230        size_t bindex, 
     
    276279 
    277280void BulkLoader::createLevel( 
    278         RTree* pTree, 
     281        SpatialIndex::RTree::RTree* pTree, 
    279282        Tools::IObjectStream& stream, 
    280283        size_t dimension, 
     
    339342} 
    340343 
    341 Node* BulkLoader::createNode(RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, size_t level) 
     344Node* BulkLoader::createNode(SpatialIndex::RTree::RTree* pTree, std::vector<Tools::SmartPointer<IData> >& e, size_t level) 
    342345{ 
    343346        Node* n; 
  • spatialindex/trunk/src/rtree/Index.cc

    r33 r67  
    3232} 
    3333 
    34 Index::Index(RTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 
     34Index::Index(SpatialIndex::RTree::RTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 
    3535{ 
    3636} 
  • spatialindex/trunk/src/rtree/Leaf.cc

    r33 r67  
    3232} 
    3333 
    34 Leaf::Leaf(RTree* pTree, id_type id): Node(pTree, id, 0, pTree->m_leafCapacity) 
     34Leaf::Leaf(SpatialIndex::RTree::RTree* pTree, id_type id): Node(pTree, id, 0, pTree->m_leafCapacity) 
    3535{ 
    3636} 
  • spatialindex/trunk/src/rtree/Node.cc

    r33 r67  
    215215} 
    216216 
    217 Node::Node(RTree* pTree, id_type id, size_t level, size_t capacity) : 
     217Node::Node(SpatialIndex::RTree::RTree* pTree, id_type id, size_t level, size_t capacity) : 
    218218        m_pTree(pTree), 
    219219        m_level(level), 
  • spatialindex/trunk/src/spatialindex/LineSegment.cc

    r34 r67  
    173173void LineSegment::getCenter(Point& out) const 
    174174{ 
    175         double coords[m_dimension]; 
    176  
     175//      double coords[m_dimension]; 
     176    double *coords; 
     177    coords = (double*) malloc(m_dimension * sizeof(double)); 
    177178        for (size_t cDim = 0; cDim < m_dimension; cDim++) 
    178179        { 
     
    192193void LineSegment::getMBR(Region& out) const 
    193194{ 
    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)); 
    197201        for (size_t cDim = 0; cDim < m_dimension; cDim++) 
    198202        { 
  • spatialindex/trunk/src/spatialindex/MovingRegion.cc

    r33 r67  
    581581        double H = tmax - tmin; 
    582582 
    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)); 
    584588        double a = 0.0, b = 0.0, c = 0.0, f = 0.0, l = 0.0, m = 0.0, n = 0.0; 
    585589 
  • spatialindex/trunk/src/storagemanager/Buffer.cc

    r33 r67  
    2525using namespace SpatialIndex::StorageManager; 
    2626using std::map; 
    27  
     27typedef SpatialIndex::id_type id_type; 
     28typedef SpatialIndex::TimeRegion TimeRegion; 
     29     
    2830Buffer::Buffer(IStorageManager& sm, Tools::PropertySet& ps) : 
    2931        m_capacity(10), 
  • spatialindex/trunk/src/storagemanager/DiskStorageManager.cc

    r33 r67  
    2020//    mhadji@gmail.com 
    2121 
     22#ifndef _MSC_VER 
    2223#include <unistd.h> 
     24#endif 
     25 
    2326#include <fcntl.h> 
    2427#include <sys/types.h> 
  • spatialindex/trunk/src/storagemanager/RandomEvictionsBuffer.cc

    r33 r67  
    2222#include <time.h> 
    2323#include <stdlib.h> 
     24#include "../include/tools/rand48.hpp" 
    2425 
    2526#include "../spatialindex/SpatialIndexImpl.h" 
     
    5354RandomEvictionsBuffer::RandomEvictionsBuffer(IStorageManager& sm, Tools::PropertySet& ps) : Buffer(sm, ps) 
    5455{ 
     56 
    5557        srand48(time(NULL)); 
    5658} 
     
    7375        if (m_buffer.size() == 0) return; 
    7476 
    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)); 
    7682 
    7783        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 
    23// 
    34// Copyright (C) 2004  Navel Ltd. 
     
    2122 
    2223#include <stdio.h> 
    23 #include <unistd.h> 
    24  
    25 #include "../../include/tools/Tools.h" 
     24 
     25#include "../include/tools/Tools.h" 
     26 
    2627#include "ExternalSort.h" 
    2728 
     
    7576        size_t bufferSize 
    7677) 
    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) 
    8485{ 
    8586        mergeRuns(); 
     
    9192        size_t bufferSize 
    9293) 
    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) 
    100101{ 
    101102        mergeRuns(); 
     
    137138                        m_cNumberOfSortedRecords++; 
    138139 
    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 
    143146 
    144147                        if (m_pTemplateRecord == 0) 
     
    177180        while (runs.size() > 1) 
    178181        { 
    179                 TemporaryFile* output = 0; 
    180                 output = new TemporaryFile(); 
     182                TemporaryFile* output = new TemporaryFile(); 
    181183 
    182184                priority_queue< 
     
    185187                        PQEntry::ascendingComparator> buffer; 
    186188 
    187                 uint32_t cRun = 0, cMaxRun = 0; 
     189                size_t cRun = 0, cMaxRun = 0; 
    188190                size_t len; 
    189191                byte* data; 
     
    201203                                buffer.push(new PQEntry(pS, m_pComparator, runs[cRun])); 
    202204                        } 
    203                         catch (EndOfStreamException& e
     205                        catch (EndOfStreamException
    204206                        { 
    205207                                // if there are no more records in the file, do nothing. 
     
    221223                                buffer.push(pqe); 
    222224                        } 
    223                         catch (EndOfStreamException& e
     225                        catch (EndOfStreamException
    224226                        { 
    225227                                // if there are no more records in the file, do nothing. 
     
    229231                        { 
    230232                                delete pqe; 
    231                                 delete output; 
    232233                                throw; 
    233234                        } 
     
    296297        } 
    297298} 
    298  
  • spatialindex/trunk/src/tools/ExternalSort.h

    r34 r67  
    1 // Spatial Index Library 
     1// Tools Library 
    22// 
    33// Copyright (C) 2004  Navel Ltd. 
  • spatialindex/trunk/src/tools/TemporaryFile.cc

    r34 r67  
    1 // Spatial Index Library 
     1// Tools Library 
    22// 
    33// Copyright (C) 2004  Navel Ltd. 
     
    2020//    mhadji@gmail.com 
    2121 
    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" 
    2625 
    2726Tools::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) 
    3130{ 
    3231        char p[5 + 6] = "tmpfXXXXXX"; 
    33         int fd = mkstemp(p); 
    34         if (fd == -1) 
     32        if (_mktemp(p) != 0) 
    3533                throw IllegalStateException( 
    3634                        "Tools::TemporaryFile::TemporaryFile: Cannot create tmp file." 
    3735                ); 
    38         close(fd); 
    3936 
    4037        m_file.open(p, std::ios::in | std::ios::out | std::ios::trunc | std::ios::binary); 
     
    7067        { 
    7168                char p[5 + 6] = "tmpfXXXXXX"; 
    72                 int fd = mkstemp(p); 
    73                 if (fd == -1) 
     69                if (_mktemp(p) != 0) 
    7470                        throw IllegalStateException( 
    7571                                "Tools::TemporaryFile::storeNextObject: Cannot create tmp file." 
    7672                        ); 
    77                 close(fd); 
    7873 
    7974                m_file.close(); 
     
    237232        m_bEOF = false; 
    238233} 
    239  
  • spatialindex/trunk/src/tools/Tools.cc

    r34 r67  
    2121 
    2222#include "../../include/tools/Tools.h" 
     23#include "../../include/tools/rand48.hpp" 
     24 
    2325#include "ExternalSort.h" 
    2426 
  • spatialindex/trunk/src/tprtree/Index.cc

    r33 r67  
    3232} 
    3333 
    34 Index::Index(TPRTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 
     34Index::Index(SpatialIndex::TPRTree::TPRTree* pTree, id_type id, size_t level) : Node(pTree, id, level, pTree->m_indexCapacity) 
    3535{ 
    3636} 
  • spatialindex/trunk/src/tprtree/Leaf.cc

    r33 r67  
    3232} 
    3333 
    34 Leaf::Leaf(TPRTree* pTree, id_type id) 
     34Leaf::Leaf(SpatialIndex::TPRTree::TPRTree* pTree, id_type id) 
    3535        : Node(pTree, id, 0, pTree->m_leafCapacity) 
    3636{ 
  • spatialindex/trunk/src/tprtree/Node.cc

    r33 r67  
    248248} 
    249249 
    250 Node::Node(TPRTree* pTree, id_type id, size_t level, size_t capacity) : 
     250Node::Node(SpatialIndex::TPRTree::TPRTree* pTree, id_type id, size_t level, size_t capacity) : 
    251251        m_pTree(pTree), 
    252252        m_level(level),