backends/flint/flint_alltermslist.h

Go to the documentation of this file.
00001 /* flint_alltermslist.h: A termlist containing all terms in a flint database.
00002  *
00003  * Copyright (C) 2005,2007 Olly Betts
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License as
00007  * published by the Free Software Foundation; either version 2 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00018  * USA
00019  */
00020 
00021 #ifndef XAPIAN_INCLUDED_FLINT_ALLTERMSLIST_H
00022 #define XAPIAN_INCLUDED_FLINT_ALLTERMSLIST_H
00023 
00024 #include "alltermslist.h"
00025 #include "flint_database.h"
00026 #include "flint_postlist.h"
00027 
00028 class FlintCursor;
00029 
00030 class FlintAllTermsList : public AllTermsList {
00032     FlintAllTermsList(const FlintAllTermsList &);
00033 
00035     void operator=(const FlintAllTermsList &);
00036 
00038     Xapian::Internal::RefCntPtr<const FlintDatabase> database;
00039 
00043     FlintCursor * cursor;
00044 
00046     string current_term;
00047 
00049     string prefix;
00050 
00057     mutable Xapian::termcount termfreq;
00058 
00060     mutable Xapian::termcount collfreq;
00061 
00063     void read_termfreq_and_collfreq() const;
00064 
00065   public:
00066     FlintAllTermsList(Xapian::Internal::RefCntPtr<const FlintDatabase> database_,
00067                       const string & prefix_)
00068             : database(database_), prefix(prefix_), termfreq(0) {
00069         cursor = database->postlist_table.cursor_get();
00070         Assert(cursor); // The postlist table isn't optional.
00071 
00072         // Position the cursor on the highest key before the first key we want,
00073         // so that the first call to next() will put us on the first key we
00074         // want.
00075         if (prefix.empty()) {
00076             cursor->find_entry_lt(string("\x00\xff", 2));
00077         } else {
00078             cursor->find_entry_lt(pack_string_preserving_sort(prefix));
00079         }
00080     }
00081 
00083     ~FlintAllTermsList();
00084 
00090     string get_termname() const;
00091 
00097     Xapian::doccount get_termfreq() const;
00098 
00104     Xapian::termcount get_collection_freq() const;
00105 
00107     TermList * next();
00108 
00110     TermList * skip_to(const string &tname);
00111 
00113     bool at_end() const;
00114 };
00115 
00116 #endif /* XAPIAN_INCLUDED_FLINT_ALLTERMSLIST_H */

Documentation for Xapian (version 1.0.10).
Generated on 24 Dec 2008 by Doxygen 1.5.2.