Ticket #250: lazy_positionmods.patch
File lazy_positionmods.patch, 3.0 KB (added by , 15 years ago) |
---|
-
common/document.h
59 59 bool data_here; 60 60 mutable bool values_here; // FIXME mutable is a hack 61 61 mutable bool terms_here; 62 bool positions_touched; 62 63 63 64 /// The (user defined) data associated with this document. 64 65 string data; … … 174 175 return terms_here; 175 176 } 176 177 178 /** Return true if the positions in the document may have been modified. 179 */ 180 bool positions_modified() const { 181 return positions_touched; 182 } 183 177 184 /** Get the docid which is associated with this document (if any). 178 185 * 179 186 * NB If multiple databases are being searched together, then this … … 196 203 Internal(Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> database_, 197 204 Xapian::docid did_) 198 205 : database(database_), data_here(false), values_here(false), 199 terms_here(false), did(did_) { }206 terms_here(false), positions_touched(false), did(did_) { } 200 207 201 208 Internal() 202 209 : database(0), data_here(false), values_here(false), 203 terms_here(false) { }210 terms_here(false), positions_touched(false) { } 204 211 205 212 /** Destructor. 206 213 * -
api/omdocument.cc
359 359 i->second.add_position(tpos); 360 360 if (wdfinc) i->second.inc_wdf(wdfinc); 361 361 } 362 positions_touched = true; 362 363 } 363 364 364 365 void … … 391 392 "Xapian::Document::Internal::remove_posting()"); 392 393 } 393 394 i->second.remove_position(tpos); 395 positions_touched = true; 394 396 if (wdfdec) i->second.dec_wdf(wdfdec); 395 397 } 396 398 … … 405 407 "' is not present in document, in " 406 408 "Xapian::Document::Internal::remove_term()"); 407 409 } 410 if (!(i->second.positions.empty())) { 411 positions_touched = true; 412 } 408 413 terms.erase(i); 409 414 } 410 415 … … 413 418 { 414 419 terms.clear(); 415 420 terms_here = true; 421 positions_touched = true; 416 422 } 417 423 418 424 Xapian::termcount -
backends/flint/flint_database.cc
1361 1361 j->second.insert(make_pair(did, make_pair('A', wdf))); 1362 1362 } 1363 1363 1364 PositionIterator it = term.positionlist_begin(); 1365 PositionIterator it_end = term.positionlist_end(); 1366 if (it != it_end) { 1367 position_table.set_positionlist( 1368 did, tname, it, it_end); 1369 } else { 1370 position_table.delete_positionlist(did, tname); 1364 if (!modifying || document.internal->positions_modified()) { 1365 PositionIterator it = term.positionlist_begin(); 1366 PositionIterator it_end = term.positionlist_end(); 1367 if (it != it_end) { 1368 position_table.set_positionlist(did, tname, it, it_end); 1369 } else { 1370 position_table.delete_positionlist(did, tname); 1371 } 1371 1372 } 1372 1373 } 1373 1374 LOGLINE(DB, "Calculated doclen for replacement document " << did << " as " << new_doclen);