Ticket #266: minmem.patch
File minmem.patch, 6.6 KB (added by , 13 years ago) |
---|
-
tests/api_transdb.cc
126 126 127 127 return true; 128 128 } 129 130 /// Test minimise_memory inside a simple transaction. 131 DEFINE_TESTCASE(minmemtransaction1, transactions) { 132 Xapian::WritableDatabase db(get_writable_database("apitest_simpledata")); 133 134 Xapian::doccount docs = db.get_doccount(); 135 db.begin_transaction(); 136 Xapian::Document doc; 137 doc.set_data("testing"); 138 doc.add_term("befuddlement"); 139 db.add_document(doc); 140 TEST_EXCEPTION(Xapian::InvalidOperationError, db.begin_transaction()); 141 db.minimise_memory(); 142 TEST_EQUAL(db.get_doccount(), docs + 1); 143 TEST_EQUAL(db.get_termfreq("befuddlement"), 1); 144 db.commit_transaction(); 145 TEST_EQUAL(db.get_doccount(), docs + 1); 146 TEST_EQUAL(db.get_termfreq("befuddlement"), 1); 147 148 return true; 149 } 150 151 /// Test cancelling a simple transaction after calling minimise_memory. 152 DEFINE_TESTCASE(minmemcanceltransaction1, transactions) { 153 Xapian::WritableDatabase db(get_writable_database("apitest_simpledata")); 154 155 Xapian::doccount docs = db.get_doccount(); 156 db.begin_transaction(); 157 Xapian::Document doc; 158 doc.set_data("testing"); 159 doc.add_term("befuddlement"); 160 db.add_document(doc); 161 TEST_EXCEPTION(Xapian::InvalidOperationError, db.begin_transaction()); 162 TEST_EQUAL(db.get_doccount(), docs + 1); 163 TEST_EQUAL(db.get_termfreq("befuddlement"), 1); 164 db.minimise_memory(); 165 db.cancel_transaction(); 166 TEST_EQUAL(db.get_doccount(), docs); 167 TEST_EQUAL(db.get_termfreq("befuddlement"), 0); 168 169 return true; 170 } -
include/xapian/database.h
5 5 * Copyright 2002 Ananova Ltd 6 6 * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts 7 7 * Copyright 2006,2008 Lemur Consulting Ltd 8 * Copyright 2011 Richard Boulton 8 9 * 9 10 * This program is free software; you can redistribute it and/or 10 11 * modify it under the terms of the GNU General Public License as … … 565 566 */ 566 567 void flush() { commit(); } 567 568 569 /** Reduce the amount of memory currently holding buffered changes. 570 * 571 * This may be used to control the amount of memory used when 572 * indexing, while still allowing large sets of changes to be applied 573 * atomically. Note that it will generally perform a similar amount 574 * of work to performing a commit(), so as with commit, calling 575 * mimimise_memory() too often will make indexing take much longer. 576 * 577 * This may be called whether a transaction is currently in progress 578 * or not. 579 * 580 * @exception Xapian::DatabaseError will be thrown if a problem occurs 581 * while modifying the database. 582 * 583 * @exception Xapian::DatabaseCorruptError will be thrown if the 584 * database is in a corrupt state. 585 */ 586 void minimise_memory(); 587 568 588 /** Begin a transaction. 569 589 * 570 590 * In Xapian a transaction is a group of modifications to the database -
common/database.h
412 412 /** Cancel pending modifications to the database. */ 413 413 virtual void cancel(); 414 414 415 /** Reduce the amount of memory currently holding buffered changes. 416 * 417 * See WritableDatabase::minimise_memory() for more information. 418 */ 419 virtual void minimise_memory(); 420 415 421 /** Begin a transaction. 416 422 * 417 423 * See WritableDatabase::begin_transaction() for more information. -
api/omdatabase.cc
785 785 } 786 786 787 787 void 788 WritableDatabase::minimise_memory() 789 { 790 LOGCALL_VOID(API, "WritableDatabase::minimise_memory", NO_ARGS); 791 if (internal.size() != 1) only_one_subdatabase_allowed(); 792 internal[0]->minimise_memory(); 793 } 794 795 void 788 796 WritableDatabase::begin_transaction(bool flushed) 789 797 { 790 798 LOGCALL_VOID(API, "WritableDatabase::begin_transaction", NO_ARGS); -
backends/database.cc
123 123 } 124 124 125 125 void 126 Database::Internal::minimise_memory() 127 { 128 // Writable databases may override this method. 129 } 130 131 void 126 132 Database::Internal::begin_transaction(bool flushed) 127 133 { 128 134 if (transaction_state != TRANSACTION_NONE) { -
backends/chert/chert_database.cc
1607 1607 } 1608 1608 1609 1609 void 1610 ChertWritableDatabase::minimise_memory() 1611 { 1612 flush_postlist_changes(); 1613 } 1614 1615 void 1610 1616 ChertWritableDatabase::add_spelling(const string & word, 1611 1617 Xapian::termcount freqinc) const 1612 1618 { -
backends/chert/chert_database.h
383 383 /** Cancel pending modifications to the database. */ 384 384 void cancel(); 385 385 386 /** Minimise buffered changes. */ 387 void minimise_memory(); 388 386 389 Xapian::docid add_document(const Xapian::Document & document); 387 390 Xapian::docid add_document_(Xapian::docid did, const Xapian::Document & document); 388 391 // Stop the default implementation of delete_document(term) and -
backends/brass/brass_database.cc
1532 1532 } 1533 1533 1534 1534 void 1535 BrassWritableDatabase::minimise_memory() 1536 { 1537 flush_postlist_changes(); 1538 } 1539 1540 void 1535 1541 BrassWritableDatabase::add_spelling(const string & word, 1536 1542 Xapian::termcount freqinc) const 1537 1543 { -
backends/brass/brass_database.h
340 340 /** Cancel pending modifications to the database. */ 341 341 void cancel(); 342 342 343 /** Minimise buffered changes. */ 344 void minimise_memory(); 345 343 346 Xapian::docid add_document(const Xapian::Document & document); 344 347 Xapian::docid add_document_(Xapian::docid did, const Xapian::Document & document); 345 348 // Stop the default implementation of delete_document(term) and