Changeset 75

Show
Ignore:
Timestamp:
1999-09-20 17:12:19 (9 years ago)
Author:
richard
Message:

Reads term lists (untested though)

Location:
trunk/xapian-core
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/xapian-core/backends/da/da_database.cc

    r67 r75  
    7777} 
    7878 
     79 
     80 
     81DATermList::DATermList(DADatabase *db, struct termvec *tv) { 
     82    tvec = tv; 
     83    dbase = db; 
     84 
     85    readterms(tvec); 
     86} 
     87 
     88DATermList::~DATermList() { 
     89    losetermvec(tvec); 
     90} 
     91 
     92termid 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 
     100void   DATermList::next() { 
     101    printf("Next\n"); 
     102    readterms(tvec); 
     103} 
     104 
     105bool   DATermList::at_end() { 
     106    if(tvec->term == 0) return true; 
     107    return false; 
     108} 
    79109 
    80110 
     
    156186{ 
    157187    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; 
    159198} 
    160199 
  • trunk/xapian-core/backends/da/da_database.h

    r61 r75  
    2929 
    3030class DATermList : public virtual TermList { 
     31    friend class DADatabase; 
     32    private: 
     33        struct termvec * tvec; 
     34        DADatabase * dbase; 
    3135 
     36        DATermList(DADatabase *db, struct termvec *tv); 
     37    public: 
     38        ~DATermList(); 
     39 
     40        termid get_termid(); 
     41        void   next(); 
     42        bool   at_end(); 
    3243}; 
    3344 
  • trunk/xapian-core/common/database.h

    r68 r75  
    3333        virtual termid get_termid() = 0;    // Gets current termid 
    3434        virtual void   next() = 0;          // Moves to next termid 
    35         virtual void   skip_to(termid) = 0; // Moves to next termid >= specified termid 
    3635        virtual bool   at_end() = 0;        // True if we're off the end of the list 
    3736 
  • trunk/xapian-core/tests/dbtest.cc

    r60 r75  
    88    DADatabase database; 
    99    PostList * postlist; 
     10    TermList * termlist; 
    1011    termid tid; 
     12    docid did; 
    1113 
    1214    try { 
     
    2628        } 
    2729        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; 
    2840        database.close(); 
    2941    }