Changeset 75
- Timestamp:
- 1999-09-20 17:12:19 (9 years ago)
- Location:
- trunk/xapian-core
- Files:
-
- 4 modified
-
backends/da/da_database.cc (modified) (2 diffs)
-
backends/da/da_database.h (modified) (1 diff)
-
common/database.h (modified) (1 diff)
-
tests/dbtest.cc (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/xapian-core/backends/da/da_database.cc
r67 r75 77 77 } 78 78 79 80 81 DATermList::DATermList(DADatabase *db, struct termvec *tv) { 82 tvec = tv; 83 dbase = db; 84 85 readterms(tvec); 86 } 87 88 DATermList::~DATermList() { 89 losetermvec(tvec); 90 } 91 92 termid DATermList::get_termid() { 93 if(at_end()) throw OmError("Attempt to access beyond end of termlist."); 94 95 char *term = (char *)tvec->term; 96 97 return dbase->term_name_to_id(string(term + 1, (unsigned)term[0])); 98 } 99 100 void DATermList::next() { 101 printf("Next\n"); 102 readterms(tvec); 103 } 104 105 bool DATermList::at_end() { 106 if(tvec->term == 0) return true; 107 return false; 108 } 79 109 80 110 … … 156 186 { 157 187 if(!opened) throw OmError("DADatabase not opened."); 158 return NULL; 188 189 struct termvec *tv = maketermvec(); 190 int found = DAgettermvec(DA_r, id, tv); 191 192 if(found == 0) throw RangeError("Docid not found"); 193 194 openterms(tv); 195 196 DATermList *tl = new DATermList(this, tv); 197 return tl; 159 198 } 160 199 -
trunk/xapian-core/backends/da/da_database.h
r61 r75 29 29 30 30 class DATermList : public virtual TermList { 31 friend class DADatabase; 32 private: 33 struct termvec * tvec; 34 DADatabase * dbase; 31 35 36 DATermList(DADatabase *db, struct termvec *tv); 37 public: 38 ~DATermList(); 39 40 termid get_termid(); 41 void next(); 42 bool at_end(); 32 43 }; 33 44 -
trunk/xapian-core/common/database.h
r68 r75 33 33 virtual termid get_termid() = 0; // Gets current termid 34 34 virtual void next() = 0; // Moves to next termid 35 virtual void skip_to(termid) = 0; // Moves to next termid >= specified termid36 35 virtual bool at_end() = 0; // True if we're off the end of the list 37 36 -
trunk/xapian-core/tests/dbtest.cc
r60 r75 8 8 DADatabase database; 9 9 PostList * postlist; 10 TermList * termlist; 10 11 termid tid; 12 docid did; 11 13 12 14 try { … … 26 28 } 27 29 delete postlist; 30 did = 2510; 31 termlist = database.open_term_list(did); 32 printf("\nTermlist for document %d:\n", did); 33 while(!termlist->at_end()) { 34 termid tid = termlist->get_termid(); 35 36 printf("TermId: %d\n", tid); 37 termlist->next(); 38 } 39 delete termlist; 28 40 database.close(); 29 41 }
