00001
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <config.h>
00022
00023 #include "brass_inverter.h"
00024
00025 #include "brass_postlist.h"
00026
00027 #include <map>
00028 #include <string>
00029
00030 using namespace std;
00031
00032 void
00033 Inverter::flush_doclengths(BrassPostListTable & table)
00034 {
00035 table.merge_doclen_changes(doclen_changes);
00036 doclen_changes.clear();
00037 }
00038
00039 void
00040 Inverter::flush_post_list(BrassPostListTable & table, const string & term)
00041 {
00042 map<string, PostingChanges>::iterator i;
00043 i = postlist_changes.find(term);
00044 if (i == postlist_changes.end()) return;
00045
00046
00047 table.merge_changes(term, i->second);
00048 postlist_changes.erase(i);
00049 }
00050
00051 void
00052 Inverter::flush_all_post_lists(BrassPostListTable & table)
00053 {
00054 map<string, PostingChanges>::const_iterator i;
00055 for (i = postlist_changes.begin(); i != postlist_changes.end(); ++i) {
00056 table.merge_changes(i->first, i->second);
00057 }
00058 postlist_changes.clear();
00059 }
00060
00061 void
00062 Inverter::flush_post_lists(BrassPostListTable & table, const string & pfx)
00063 {
00064 if (pfx.empty())
00065 return flush_all_post_lists(table);
00066
00067 map<string, PostingChanges>::iterator i, begin, end;
00068 begin = postlist_changes.lower_bound(pfx);
00069 end = postlist_changes.upper_bound(pfx);
00070
00071 for (i = begin; i != end; ++i) {
00072 table.merge_changes(i->first, i->second);
00073 }
00074
00075
00076
00077 postlist_changes.erase(begin, end);
00078 }
00079
00080 void
00081 Inverter::flush(BrassPostListTable & table)
00082 {
00083 flush_doclengths(table);
00084 flush_all_post_lists(table);
00085 }