RCS file: /usr/data/cvs/xapian/xapian-core/api/omdatabase.cc,v
retrieving revision 1.55
diff -p -u -u -r1.55 omdatabase.cc
|
|
OmPostListIterator
|
115 | 115 | OmDatabase::postlist_begin(const om_termname &tname) const |
116 | 116 | { |
117 | 117 | DEBUGAPICALL(OmPostListIterator, "OmDatabase::postlist_begin", tname); |
118 | | if (tname.empty()) |
119 | | throw OmInvalidArgumentError("Zero length terms are invalid"); |
120 | 118 | RETURN(OmPostListIterator(new OmPostListIterator::Internal(internal->open_post_list(tname, *this)))); |
121 | 119 | } |
122 | 120 | |
… |
… |
OmPostListIterator
|
124 | 122 | OmDatabase::postlist_end(const om_termname &tname) const |
125 | 123 | { |
126 | 124 | DEBUGAPICALL(OmPostListIterator, "OmDatabase::postlist_end", tname); |
127 | | if (tname.empty()) |
128 | | throw OmInvalidArgumentError("Zero length terms are invalid"); |
129 | 125 | RETURN(OmPostListIterator(NULL)); |
130 | 126 | } |
131 | 127 | |
RCS file: /usr/data/cvs/xapian/xapian-core/backends/inmemory/inmemory_database.cc,v
retrieving revision 1.105
diff -p -u -u -r1.105 inmemory_database.cc
|
|
InMemoryPostList::get_wdf() const
|
70 | 70 | return (*pos).wdf; |
71 | 71 | } |
72 | 72 | |
| 73 | // InMemoryAllDocsPostList |
| 74 | |
| 75 | om_doclength |
| 76 | InMemoryAllDocsPostList::get_doclength() const |
| 77 | { |
| 78 | return this_db->get_doclength(did); |
| 79 | } |
| 80 | |
| 81 | PositionList * |
| 82 | InMemoryAllDocsPostList::read_position_list() |
| 83 | { |
| 84 | throw OmUnimplementedError("Can't open position list for all docs iterator"); |
| 85 | } |
| 86 | |
| 87 | AutoPtr<PositionList> |
| 88 | InMemoryAllDocsPostList::open_position_list() const |
| 89 | { |
| 90 | throw OmUnimplementedError("Can't open position list for all docs iterator"); |
| 91 | } |
| 92 | |
| 93 | om_termcount |
| 94 | InMemoryAllDocsPostList::get_wdf() const |
| 95 | { |
| 96 | return 1; |
| 97 | } |
| 98 | |
73 | 99 | /////////////////////////// |
74 | 100 | // Actual database class // |
75 | 101 | /////////////////////////// |
… |
… |
InMemoryDatabase::~InMemoryDatabase()
|
99 | 121 | LeafPostList * |
100 | 122 | InMemoryDatabase::do_open_post_list(const om_termname & tname) const |
101 | 123 | { |
102 | | if (!term_exists(tname)) { |
103 | | return new EmptyPostList(); |
104 | | }; |
105 | | |
| 124 | if (tname.empty()) { |
| 125 | if (termlists.empty()) return new EmptyPostList(); |
| 126 | return new InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase>(RefCntPtrToThis(), this)); |
| 127 | } |
106 | 128 | map<om_termname, InMemoryTerm>::const_iterator i = postlists.find(tname); |
107 | | Assert(i != postlists.end()); |
| 129 | if (i == postlists.end()) return new EmptyPostList(); |
108 | 130 | |
109 | 131 | return new InMemoryPostList(RefCntPtr<const InMemoryDatabase>(RefCntPtrToThis(), this), |
110 | 132 | i->second); |
RCS file: /usr/data/cvs/xapian/xapian-core/backends/inmemory/inmemory_database.h,v
retrieving revision 1.116
diff -p -u -u -r1.116 inmemory_database.h
|
|
class InMemoryPostList : public LeafPost
|
164 | 164 | string get_description() const; |
165 | 165 | }; |
166 | 166 | |
| 167 | /** A PostList over all docs in an inmemory database. |
| 168 | */ |
| 169 | class InMemoryAllDocsPostList : public LeafPostList { |
| 170 | friend class InMemoryDatabase; |
| 171 | private: |
| 172 | om_docid did; |
| 173 | |
| 174 | RefCntPtr<const InMemoryDatabase> this_db; |
| 175 | |
| 176 | InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase> db); |
| 177 | public: |
| 178 | om_doccount get_termfreq() const; |
| 179 | |
| 180 | om_docid get_docid() const; // Gets current docid |
| 181 | om_doclength get_doclength() const; // Length of current document |
| 182 | om_termcount get_wdf() const; // Within Document Frequency |
| 183 | PositionList *read_position_list(); |
| 184 | AutoPtr<PositionList> open_position_list() const; |
| 185 | |
| 186 | PostList *next(om_weight w_min); // Moves to next docid |
| 187 | |
| 188 | PostList *skip_to(om_docid did, om_weight w_min); // Moves to next docid >= specified docid |
| 189 | |
| 190 | bool at_end() const; // True if we're off the end of the list |
| 191 | |
| 192 | string get_description() const; |
| 193 | }; |
167 | 194 | |
168 | 195 | // Term List |
169 | 196 | class InMemoryTermList : public LeafTermList { |
… |
… |
class InMemoryTermList : public LeafTerm
|
198 | 225 | */ |
199 | 226 | class InMemoryDatabase : public Database { |
200 | 227 | friend class DatabaseBuilder; |
| 228 | friend class InMemoryAllDocsPostList; |
201 | 229 | private: |
202 | 230 | map<om_termname, InMemoryTerm> postlists; |
203 | 231 | vector<InMemoryDoc> termlists; |
… |
… |
InMemoryPostList::get_description() cons
|
378 | 405 | return tname + ":" + om_tostring(termfreq); |
379 | 406 | } |
380 | 407 | |
| 408 | ////////////////////////////////////////////// |
| 409 | // Inline function definitions for postlist over all docs // |
| 410 | ////////////////////////////////////////////// |
| 411 | |
| 412 | inline |
| 413 | InMemoryAllDocsPostList::InMemoryAllDocsPostList(RefCntPtr<const InMemoryDatabase> db) |
| 414 | : did(0), this_db(db) |
| 415 | { |
| 416 | } |
| 417 | |
| 418 | inline om_doccount |
| 419 | InMemoryAllDocsPostList::get_termfreq() const |
| 420 | { |
| 421 | return this_db->totdocs; |
| 422 | } |
| 423 | |
| 424 | inline om_docid |
| 425 | InMemoryAllDocsPostList::get_docid() const |
| 426 | { |
| 427 | Assert(did > 0 && did <= this_db->termlists.size()); |
| 428 | Assert(this_db->termlists[did - 1].is_valid); |
| 429 | return did; |
| 430 | } |
| 431 | |
| 432 | inline PostList * |
| 433 | InMemoryAllDocsPostList::next(om_weight /*w_min*/) |
| 434 | { |
| 435 | Assert(!at_end()); |
| 436 | do { |
| 437 | ++did; |
| 438 | } while (did <= this_db->termlists.size() && !this_db->termlists[did - 1].is_valid); |
| 439 | return NULL; |
| 440 | } |
| 441 | |
| 442 | inline PostList * |
| 443 | InMemoryAllDocsPostList::skip_to(om_docid did_, om_weight /*w_min*/) |
| 444 | { |
| 445 | Assert(!at_end()); |
| 446 | Assert(did <= did_); |
| 447 | did = did_; |
| 448 | while (did <= this_db->termlists.size() && !this_db->termlists[did - 1].is_valid) { |
| 449 | ++did; |
| 450 | } |
| 451 | return NULL; |
| 452 | } |
| 453 | |
| 454 | inline bool |
| 455 | InMemoryAllDocsPostList::at_end() const |
| 456 | { |
| 457 | return (did > this_db->termlists.size()); |
| 458 | } |
| 459 | |
| 460 | |
| 461 | inline string |
| 462 | InMemoryAllDocsPostList::get_description() const |
| 463 | { |
| 464 | return om_tostring(did); |
| 465 | } |
381 | 466 | |
382 | 467 | ////////////////////////////////////////////// |
383 | 468 | // Inline function definitions for termlist // |
RCS file: /usr/data/cvs/xapian/xapian-core/backends/quartz/quartz_database.cc,v
retrieving revision 1.102
diff -p -u -u -r1.102 quartz_database.cc
|
|
QuartzDatabase::open_post_list_internal(
|
274 | 274 | RefCntPtr<const Database> ptrtothis) const |
275 | 275 | { |
276 | 276 | DEBUGCALL(DB, LeafPostList *, "QuartzDatabase::open_post_list_internal", tname << ", [ptrtothis]"); |
277 | | Assert(!tname.empty()); |
278 | | return(new QuartzPostList(ptrtothis, |
| 277 | if (!tname.empty()) { |
| 278 | // FIXME: RETURN(new QuartzAllPostList(ptrtothis, tables->get_record_table())); |
| 279 | } |
| 280 | RETURN(new QuartzPostList(ptrtothis, |
279 | 281 | tables->get_postlist_table(), |
280 | 282 | tables->get_positionlist_table(), |
281 | 283 | tname)); |
RCS file: /usr/data/cvs/xapian/xapian-core/backends/quartz/quartz_table.cc,v
retrieving revision 1.69
diff -p -u -u -r1.69 quartz_table.cc
|
|
QuartzBufferedTable::get_or_make_tag(con
|
612 | 609 | AutoPtr<string> tag(new string); |
613 | 610 | tagptr = tag.get(); |
614 | 611 | changed_entries.set_tag(key, tag); |
615 | | entry_count += 1; |
| 612 | if (!key.empty()) ++entry_count; |
616 | 613 | |
617 | 614 | AssertEq(changed_entries.get_tag(key), tagptr); |
618 | 615 | Assert(tag.get() == 0); |
619 | | |
620 | | RETURN(tagptr); |
621 | | } else { |
622 | | RETURN(tagptr); |
623 | 616 | } |
| 617 | RETURN(tagptr); |
624 | 618 | } |
625 | 619 | |
626 | 620 | AutoPtr<string> tag(new string); |
… |
… |
QuartzBufferedTable::get_or_make_tag(con
|
629 | 623 | bool found = disktable->get_exact_entry(key, *tag); |
630 | 624 | |
631 | 625 | changed_entries.set_tag(key, tag); |
632 | | if (!found) { |
633 | | DEBUGLINE(DB, "QuartzBufferedTable::get_or_make_tag - increasing entry_count - '" << key << "' added"); |
634 | | entry_count += 1; |
| 626 | if (!found && !key.empty()) { |
| 627 | DEBUGLINE(DB, "incrementing entry_count - '" << key << "' added"); |
| 628 | ++entry_count; |
635 | 629 | } |
636 | 630 | Assert(changed_entries.have_entry(key)); |
637 | 631 | AssertEq(changed_entries.get_tag(key), tagptr); |