39 const vector<Xapian::termpos> & posvec,
43 position_table.
pack(s, posvec);
44 if (modifying && has_positions_cache != 0) {
47 has_positions_cache = s.empty() ? -1 : 1;
49 auto i = pos_changes.find(tname);
50 if (i != pos_changes.end()) {
51 map<Xapian::docid, string> & m = i->second;
59 const string & key = position_table.
make_key(did, tname);
67 if (!s.empty()) has_positions_cache = 1;
69 set_positionlist(did, tname, s);
79 const std::vector<Xapian::termpos> * ptr;
83 store_positions(position_table, did, tname, *ptr, modifying);
90 store_positions(position_table, did, tname, posvec, modifying);
96 delete_positionlist(did, tname);
104 has_positions_cache = s.empty() ? -1 : 1;
105 pos_changes.insert(make_pair(term, map<Xapian::docid, string>()))
106 .first->second[did] = s;
113 set_positionlist(did, term,
string());
121 auto i = pos_changes.find(term);
122 if (i == pos_changes.end())
124 const map<Xapian::docid, string> & m = i->second;
125 auto j = m.find(did);
135 if (has_positions_cache < 0) {
139 for (
const auto& i : pos_changes) {
140 const map<Xapian::docid, string>& m = i.second;
141 for (
const auto& j : m) {
142 const string & s = j.second;
152 return has_positions_cache;
159 doclen_changes.clear();
165 map<string, PostingChanges>::iterator i;
166 i = postlist_changes.find(term);
167 if (i == postlist_changes.end())
return;
171 postlist_changes.erase(i);
177 map<string, PostingChanges>::const_iterator i;
178 for (i = postlist_changes.begin(); i != postlist_changes.end(); ++i) {
181 postlist_changes.clear();
188 return flush_all_post_lists(table);
190 map<string, PostingChanges>::iterator i, begin, end;
191 begin = postlist_changes.lower_bound(pfx);
194 if (pfxinc.back() !=
'\xff') {
196 end = postlist_changes.lower_bound(pfxinc);
199 pfxinc.resize(pfxinc.size() - 1);
200 if (pfxinc.empty()) {
201 end = postlist_changes.end();
206 for (i = begin; i != end; ++i) {
212 postlist_changes.erase(begin, end);
218 flush_doclengths(table);
219 flush_all_post_lists(table);
225 for (
auto i : pos_changes) {
226 const string & term = i.first;
227 const map<Xapian::docid, string> & m = i.second;
230 const string & s = j.second;
238 has_positions_cache = -1;
void pack(string &s, const std::vector< Xapian::termpos > &vec) const
Pack a position list into a string.
void merge_doclen_changes(const map< Xapian::docid, Xapian::termcount > &doclens)
Merge document length changes.
A position list in a glass database.
bool get_positionlist(Xapian::docid did, const std::string &term, std::string &s) const
bool has_positions(const GlassPositionListTable &position_table) const
void store_positions(const GlassPositionListTable &position_table, Xapian::docid did, const std::string &tname, const std::vector< Xapian::termpos > &posvec, bool modifying)
void delete_positionlist(Xapian::docid did, const string &tname)
Delete the position list for term tname in document did.
Postlists in glass databases.
unsigned long long glass_tablesize_t
How many entries there are in a table.
void delete_positionlist(Xapian::docid did, const std::string &term)
Class for iterating over a list of terms.
PositionIterator positionlist_end() const
Return an end PositionIterator for the current term.
void flush_post_list(GlassPostListTable &table, const std::string &term)
Flush postlist changes for term.
virtual const std::vector< Xapian::termpos > * get_vector_termpos() const
Get pointer to vector<termpos> if that's the internal representation.
void flush(GlassPostListTable &table)
Flush all postlist table changes.
void flush_all_post_lists(GlassPostListTable &table)
Flush postlist changes for all terms.
void set_positionlist(Xapian::docid did, const std::string &term, const std::string &s)
void merge_changes(const string &term, const Inverter::PostingChanges &changes)
Merge changes for a term.
Class for iterating over term positions.
void flush_pos_lists(GlassPositionListTable &table)
Flush position changes.
glass_tablesize_t get_entry_count() const
Return a count of the number of entries in the table.
bool get_exact_entry(const std::string &key, std::string &tag) const
Read an entry from the table, if and only if it is exactly that being asked for.
Abstract base class for termlists.
void flush_post_lists(GlassPostListTable &table, const std::string &pfx)
Flush postlist changes for all terms which start with pfx.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Inverter class which "inverts the file".
static string make_key(Xapian::docid did, const string &term)
void flush_doclengths(GlassPostListTable &table)
Flush document length changes.
void set_positionlist(Xapian::docid did, const string &tname, const string &s)
Set the position list for term tname in document did.
PositionIterator positionlist_begin() const
Return a PositionIterator for the current term.