#include #include #include #include #include #include #include "RTree.h" //compile //mpic++ -O3 range_query_rtree_movie_example.cpp -lm -o range_query_rtree_movie_example //To run //mpirun -np 1 -hostfile myhostfile.txt ./range_query_rtree_movie_example struct dataStruct { double x; double y; }; struct queryStruct { double x_min; double y_min; double x_max; double y_max; }; /////////////////////// //For R-tree bool MySearchCallback(int id, void* arg) { // printf("Hit data rect %d\n", id); return true; } struct Rect { Rect() {} Rect(double a_minX, double a_minY, double a_maxX, double a_maxY) { min[0] = a_minX; min[1] = a_minY; max[0] = a_maxX; max[1] = a_maxY; } double min[2]; double max[2]; }; /////////////////////// void populateSampleData(struct dataStruct * data); int main(int argc, char **argv) { int my_rank, nprocs; const int N=100; MPI_Init(&argc,&argv); MPI_Comm_rank(MPI_COMM_WORLD,&my_rank); MPI_Comm_size(MPI_COMM_WORLD,&nprocs); if (nprocs!=1) { printf("Please run this R-tree example program with 1 rank."); MPI_Finalize(); return 0; } //Import sample movie database data struct dataStruct * data=(struct dataStruct *)malloc(sizeof(struct dataStruct)*N); populateSampleData(data); //Construct tree: //R-tree parameters: //DATATYPE-- referenced data, e.g., integer (object 1, 2, 3, etc.) //ELEMTYPE-- data type of the coordinates (e.g., movie rating) //NUMDIMS-- data dimensionality (here, 2) //ELEMTYPEREAL-- data type used in volume calculations, use double to minimize FP error RTree tree; for (int i=0; i