Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Fix the generation of sqlite3_rtree_query_info.iRowid and add test cases to verify that it is fixed. |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | rtree-enhancements |
Files: | files | file ages | folders |
SHA1: |
eba95ead49f8f8ce45d400186562ff00 |
User & Date: | drh 2014-04-21 18:13:37.363 |
Context
2014-04-25
| ||
16:29 | Enhance the sqlite3_rtree_query_info object to report on the number of elements in the priority queue at each level. (Closed-Leaf check-in: f7dad408dd user: drh tags: rtree-enhancements) | |
2014-04-21
| ||
18:13 | Fix the generation of sqlite3_rtree_query_info.iRowid and add test cases to verify that it is fixed. (check-in: eba95ead49 user: drh tags: rtree-enhancements) | |
15:53 | Be sure to initialize the sqlite3_rtree_query_info.iRowid field for the leaves of the R-Tree when doing a query callback search. (check-in: 4394693882 user: drh tags: rtree-enhancements) | |
Changes
Changes to ext/rtree/rtree.c.
︙ | ︙ | |||
958 959 960 961 962 963 964 | int nCoord = pInfo->nCoord; /* No. of coordinates */ int rc; /* Callback return code */ sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2]; /* Decoded coordinates */ assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY ); assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 ); | | | 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 | int nCoord = pInfo->nCoord; /* No. of coordinates */ int rc; /* Callback return code */ sqlite3_rtree_dbl aCoord[RTREE_MAX_DIMENSIONS*2]; /* Decoded coordinates */ assert( pConstraint->op==RTREE_MATCH || pConstraint->op==RTREE_QUERY ); assert( nCoord==2 || nCoord==4 || nCoord==6 || nCoord==8 || nCoord==10 ); if( pConstraint->op==RTREE_QUERY && pSearch->iLevel==1 ){ pInfo->iRowid = readInt64(pCellData); } pCellData += 8; for(i=0; i<nCoord; i++, pCellData += 4){ RTREE_DECODE_COORD(eInt, pCellData, aCoord[i]); } if( pConstraint->op==RTREE_MATCH ){ |
︙ | ︙ |
Changes to ext/rtree/rtreeE.test.
︙ | ︙ | |||
63 64 65 66 67 68 69 70 71 72 73 74 75 76 | # This causes the 200s to sort before the 100s and the 0s to sort before # last. # do_execsql_test rtreeE-1.4 { SELECT id FROM rt1 WHERE id MATCH Qcircle(0,0,1000,3) AND id%100==0 } {200 100 0} # Construct a large 2-D RTree with thousands of random entries. # do_test rtreeE-2.1 { db eval { CREATE TABLE t2(id,x0,x1,y0,y1); CREATE VIRTUAL TABLE rt2 USING rtree(id,x0,x1,y0,y1); BEGIN; | > > > > > > > > > > | 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 | # This causes the 200s to sort before the 100s and the 0s to sort before # last. # do_execsql_test rtreeE-1.4 { SELECT id FROM rt1 WHERE id MATCH Qcircle(0,0,1000,3) AND id%100==0 } {200 100 0} # Exclude odd rowids on a depth-first search do_execsql_test rtreeE-1.5 { SELECT id FROM rt1 WHERE id MATCH Qcircle(0,0,1000,4) ORDER BY +id } {0 2 4 6 8 10 12 14 16 18 20 22 24 100 102 104 106 108 110 112 114 116 118 120 122 124 200 202 204 206 208 210 212 214 216 218 220 222 224} # Exclude odd rowids on a breadth-first search. do_execsql_test rtreeE-1.6 { SELECT id FROM rt1 WHERE id MATCH Qcircle(0,0,1000,5) ORDER BY +id } {0 2 4 6 8 10 12 14 16 18 20 22 24 100 102 104 106 108 110 112 114 116 118 120 122 124 200 202 204 206 208 210 212 214 216 218 220 222 224} # Construct a large 2-D RTree with thousands of random entries. # do_test rtreeE-2.1 { db eval { CREATE TABLE t2(id,x0,x1,y0,y1); CREATE VIRTUAL TABLE rt2 USING rtree(id,x0,x1,y0,y1); BEGIN; |
︙ | ︙ |
Changes to src/test_rtree.c.
︙ | ︙ | |||
251 252 253 254 255 256 257 | if( pCircle->eScoreType==1 ){ /* Depth first search */ p->rScore = p->iLevel; }else if( pCircle->eScoreType==2 ){ /* Breadth first search */ p->rScore = 100 - p->iLevel; | | > > > > > > > > | 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 | if( pCircle->eScoreType==1 ){ /* Depth first search */ p->rScore = p->iLevel; }else if( pCircle->eScoreType==2 ){ /* Breadth first search */ p->rScore = 100 - p->iLevel; }else if( pCircle->eScoreType==3 ){ /* Depth-first search, except sort the leaf nodes by area with ** the largest area first */ if( p->iLevel==1 ){ p->rScore = 1.0 - (xmax-xmin)*(ymax-ymin)/pCircle->mxArea; if( p->rScore<0.01 ) p->rScore = 0.01; }else{ p->rScore = 0.0; } }else if( pCircle->eScoreType==4 ){ /* Depth-first search, except exclude odd rowids */ p->rScore = p->iLevel; if( p->iRowid&1 ) nWithin = 0; }else{ /* Breadth-first search, except exclude odd rowids */ p->rScore = 100 - p->iLevel; if( p->iRowid&1 ) nWithin = 0; } if( nWithin==0 ){ p->eWithin = NOT_WITHIN; }else if( nWithin>=4 ){ p->eWithin = FULLY_WITHIN; }else{ p->eWithin = PARTLY_WITHIN; |
︙ | ︙ |