Changeset 61
- Timestamp:
- 1999-09-17 15:47:14 (9 years ago)
- Location:
- trunk/xapian-core
- Files:
-
- 5 modified
-
backends/da/da_database.cc (modified) (1 diff)
-
backends/da/da_database.h (modified) (1 diff)
-
common/database.h (modified) (2 diffs)
-
common/match.h (modified) (1 diff)
-
matcher/match.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xapian-core/backends/da/da_database.cc
r60 r61 26 26 } 27 27 28 doccount DAPostList::get_termfreq() {28 doccount DAPostList::get_termfreq() const { 29 29 return termfreq; 30 30 } -
trunk/xapian-core/backends/da/da_database.h
r60 r61 19 19 ~DAPostList(); 20 20 21 doccount get_termfreq() ;21 doccount get_termfreq() const; 22 22 23 23 docid get_docid(); // Gets current docid -
trunk/xapian-core/common/database.h
r57 r61 39 39 private: 40 40 public: 41 virtual doccount get_termfreq() = 0;// Gets number of docs indexed by this term41 virtual doccount get_termfreq() const = 0;// Gets number of docs indexed by this term 42 42 43 43 virtual docid get_docid() = 0; // Gets current docid … … 49 49 50 50 virtual ~PostList() { return; } 51 52 virtual bool operator < (const PostList *x) const 53 { 54 return get_termfreq() > x->get_termfreq(); 55 } 51 56 }; 52 57 -
trunk/xapian-core/common/match.h
r35 r61 1 1 #include "database.h" 2 2 #include "mergedpostlist.h" 3 4 #include <queue> 3 5 4 6 class Match { 5 7 private: 6 8 IRDatabase *DB; 9 7 10 PostList *merger; 8 11 // const int msize = 1000; 12 13 priority_queue<PostList *> pq; 9 14 10 15 public: -
trunk/xapian-core/matcher/match.cc
r59 r61 15 15 16 16 PostList *postlist = DB->open_post_list(id); 17 if (merger) { 18 // FIXME: want to build a tree balanced by the term frequencies 19 // (similar to a huffman encoding tree) 20 merger = new MergedPostList(merger, postlist); 21 } else { 22 merger = postlist; 23 } 17 18 pq.push(postlist); 19 24 20 return true; 25 21 } … … 34 30 void 35 31 Match::match(void) 36 { 37 if (!merger) return; 32 { 33 if (!merger) { 34 if (pq.empty()) return; // No terms in query 35 36 PostList *tmp; 37 38 // build a tree balanced by the term frequencies 39 // (similar to a huffman encoding tree) 40 while (true) { 41 tmp = pq.top(); 42 pq.pop(); 43 if (pq.empty()) break; 44 tmp = new MergedPostList(pq.top(), tmp); 45 pq.pop(); 46 pq.push(tmp); 47 } 48 49 merger = tmp; 50 } 38 51 39 52 docid msize = 0, mtotal = 0;
