Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Performance improvement by caching prepared statements when computing ancestors and descendents of a check-in. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
dcc68b46b29a096b6a01976bbdc902bb |
| User & Date: | drh 2011-05-12 01:08:32.631 |
Context
|
2011-05-12
| ||
| 12:02 | Change fossil_malloc() so that it does not report "out of memory" when allocating zero bytes. check-in: 6b382b0818 user: drh tags: trunk | |
| 01:08 | Performance improvement by caching prepared statements when computing ancestors and descendents of a check-in. check-in: dcc68b46b2 user: drh tags: trunk | |
| 00:40 | Futher improments to the display of individual file timeline graphs. check-in: 64aa186ae4 user: drh tags: trunk | |
Changes
Changes to src/descendants.c.
| ︙ | ︙ | |||
157 158 159 160 161 162 163 164 165 166 167 |
/*
** Load the record ID rid and up to N-1 closest ancestors into
** the "ok" table.
*/
void compute_ancestors(int rid, int N){
Bag seen;
PQueue queue;
bag_init(&seen);
pqueue_init(&queue);
bag_insert(&seen, rid);
pqueue_insert(&queue, rid, 0.0, 0);
| > > < < | | | | | > > > > > | > > > > > > > > | > | < | > > | 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
/*
** Load the record ID rid and up to N-1 closest ancestors into
** the "ok" table.
*/
void compute_ancestors(int rid, int N){
Bag seen;
PQueue queue;
Stmt ins;
Stmt q;
bag_init(&seen);
pqueue_init(&queue);
bag_insert(&seen, rid);
pqueue_insert(&queue, rid, 0.0, 0);
db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
db_prepare(&q,
"SELECT a.pid, b.mtime FROM plink a LEFT JOIN plink b ON b.cid=a.pid"
" WHERE a.cid=:rid"
);
while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
db_bind_int(&ins, ":rid", rid);
db_step(&ins);
db_reset(&ins);
db_bind_int(&q, ":rid", rid);
while( db_step(&q)==SQLITE_ROW ){
int pid = db_column_int(&q, 0);
double mtime = db_column_double(&q, 1);
if( bag_insert(&seen, pid) ){
pqueue_insert(&queue, pid, -mtime, 0);
}
}
db_reset(&q);
}
bag_clear(&seen);
pqueue_clear(&queue);
db_finalize(&ins);
db_finalize(&q);
}
/*
** Load the record ID rid and up to N-1 closest descendants into
** the "ok" table.
*/
void compute_descendants(int rid, int N){
Bag seen;
PQueue queue;
Stmt ins;
Stmt q;
bag_init(&seen);
pqueue_init(&queue);
bag_insert(&seen, rid);
pqueue_insert(&queue, rid, 0.0, 0);
db_prepare(&ins, "INSERT OR IGNORE INTO ok VALUES(:rid)");
db_prepare(&q, "SELECT cid, mtime FROM plink WHERE pid=:rid");
while( (N--)>0 && (rid = pqueue_extract(&queue, 0))!=0 ){
db_bind_int(&ins, ":rid", rid);
db_step(&ins);
db_reset(&ins);
db_bind_int(&q, ":rid", rid);
while( db_step(&q)==SQLITE_ROW ){
int pid = db_column_int(&q, 0);
double mtime = db_column_double(&q, 1);
if( bag_insert(&seen, pid) ){
pqueue_insert(&queue, pid, mtime, 0);
}
}
db_reset(&q);
}
bag_clear(&seen);
pqueue_clear(&queue);
db_finalize(&ins);
db_finalize(&q);
}
/*
** COMMAND: descendants
**
** Usage: %fossil descendants ?BASELINE-ID?
**
|
| ︙ | ︙ |