Ticket #59: xapian-faster-flint-add-document.patch
File xapian-faster-flint-add-document.patch, 5.7 KB (added by , 9 years ago) |
---|
-
backends/flint/flint_database.h
224 224 mutable map<Xapian::docid, Xapian::termcount> doclens; 225 225 226 226 /// Modifications to posting lists. 227 mutable map<string, map<Xapian::docid, 228 pair<char, Xapian::termcount> > > mod_plists; 227 mutable map<string, vector<pair<Xapian::docid, Xapian::termcount> > > mod_plists; 229 228 230 229 /** The readonly database encapsulated in the writable database. 231 230 */ -
backends/flint/flint_database.cc
623 623 } 624 624 625 625 // Add did to tname's postlist 626 map<string, map<docid, pair<char, termcount> > >::iterator j;626 map<string, vector<pair<docid, termcount> > >::iterator j; 627 627 j = mod_plists.find(tname); 628 628 if (j == mod_plists.end()) { 629 map<docid, pair<char, termcount> > m;629 vector<pair<docid, termcount> > m; 630 630 j = mod_plists.insert(make_pair(tname, m)).first; 631 631 } 632 Assert(j->second.find(did) == j->second.end()); 633 j->second.insert(make_pair(did, make_pair('A', wdf))); 632 j->second.push_back(make_pair(did, wdf)); 634 633 635 634 if (term.positionlist_begin() != term.positionlist_end()) { 636 635 database_ro.positionlist_table.set_positionlist( … … 679 678 DEBUGCALL(DB, void, "FlintWritableDatabase::delete_document", did); 680 679 Assert(did != 0); 681 680 681 did = did; 682 throw Xapian::UnimplementedError("delete_document not supported by this experimental patch"); 683 #if 0 682 684 try { 683 685 // Remove the record. 684 686 database_ro.record_table.delete_record(did); … … 742 744 743 745 if (++changes_made >= flush_threshold && !transaction_active()) 744 746 do_flush_const(); 747 #endif 745 748 } 746 749 747 750 void … … 751 754 DEBUGCALL(DB, void, "FlintWritableDatabase::replace_document", did << ", " << document); 752 755 Assert(did != 0); 753 756 757 did = did; 758 (void)document; 759 throw Xapian::UnimplementedError("replace_document not supported by this experimental patch"); 760 #if 0 754 761 try { 755 762 if (did > lastdocid) { 756 763 lastdocid = did; … … 896 903 897 904 if (++changes_made >= flush_threshold && !transaction_active()) 898 905 do_flush_const(); 906 #endif 899 907 } 900 908 901 909 Xapian::doccount … … 981 989 get_doccount())); 982 990 } 983 991 984 map<string, map<docid, pair<char, termcount> > >::const_iterator j;992 map<string, vector<pair<docid, termcount> > >::const_iterator j; 985 993 j = mod_plists.find(tname); 986 994 if (j != mod_plists.end()) { 987 995 // We've got buffered changes to this term's postlist, so we need to 988 996 // use a FlintModifiedPostList. 997 throw Xapian::UnimplementedError("do_open_post_list of a modified term not supported by this experimental patch"); 998 #if 0 989 999 RETURN(new FlintModifiedPostList(ptrtothis, 990 1000 &database_ro.postlist_table, 991 1001 &database_ro.positionlist_table, 992 1002 tname, 993 1003 j->second)); 1004 #endif 994 1005 } 995 1006 996 1007 RETURN(new FlintPostList(ptrtothis, -
backends/flint/flint_postlist.cc
1051 1051 1052 1052 void 1053 1053 FlintPostListTable::merge_changes( 1054 const map<string, map<Xapian::docid, pair<char, Xapian::termcount> > > & mod_plists,1054 const map<string, vector<pair<Xapian::docid, Xapian::termcount> > > & mod_plists, 1055 1055 const map<Xapian::docid, Xapian::termcount> & doclens, 1056 1056 const map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> > & freq_deltas) 1057 1057 { 1058 map<string, map<Xapian::docid, pair<char, Xapian::termcount> > >::const_iterator i;1058 map<string, vector<pair<Xapian::docid, Xapian::termcount> > >::const_iterator i; 1059 1059 for (i = mod_plists.begin(); i != mod_plists.end(); ++i) { 1060 1060 if (i->second.empty()) continue; 1061 1061 string tname = i->first; … … 1120 1120 add(current_key, tag); 1121 1121 } 1122 1122 } 1123 map<Xapian::docid, pair<char, Xapian::termcount> >::const_iterator j;1123 vector<pair<Xapian::docid, Xapian::termcount> >::const_iterator j; 1124 1124 j = i->second.begin(); 1125 1125 Assert(j != i->second.end()); // This case is caught above. 1126 1126 1127 1127 Xapian::docid max_did; 1128 1128 PostlistChunkReader *from; 1129 1129 PostlistChunkWriter *to; 1130 max_did = get_chunk(tname, j->first, j->second.first == 'A',1130 max_did = get_chunk(tname, j->first, true, 1131 1131 &from, &to); 1132 1132 for ( ; j != i->second.end(); ++j) { 1133 1133 Xapian::docid did = j->first; … … 1137 1137 Xapian::docid copy_did = from->get_docid(); 1138 1138 if (copy_did >= did) { 1139 1139 if (copy_did == did) { 1140 Assert( j->second.first != 'A');1140 Assert(false); 1141 1141 from->next(); 1142 1142 } 1143 1143 break; … … 1154 1154 goto next_chunk; 1155 1155 } 1156 1156 1157 if ( j->second.first != 'D') {1157 if (true) { 1158 1158 map<Xapian::docid, Xapian::termcount>::const_iterator k = doclens.find(did); 1159 1159 Assert(k != doclens.end()); 1160 1160 Xapian::termcount new_doclen = k->second; 1161 Xapian::termcount new_wdf = j->second .second;1161 Xapian::termcount new_wdf = j->second; 1162 1162 1163 1163 to->append(this, did, new_wdf, new_doclen); 1164 1164 } -
backends/flint/flint_postlist.h
63 63 64 64 /// Merge added, removed, and changed entries. 65 65 void merge_changes( 66 const map<string, map<Xapian::docid, pair<char, Xapian::termcount> > > & mod_plists,66 const map<string, vector<pair<Xapian::docid, Xapian::termcount> > > & mod_plists, 67 67 const map<Xapian::docid, Xapian::termcount> & doclens, 68 68 const map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> > & freq_deltas); 69 69