backends/quartz/quartz_postlist.h

Go to the documentation of this file.
00001 /* quartz_postlist.h: Postlists in quartz databases
00002  *
00003  * Copyright 1999,2000,2001 BrightStation PLC
00004  * Copyright 2002 Ananova Ltd
00005  * Copyright 2002,2003,2004,2005,2007 Olly Betts
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
00020  * USA
00021  */
00022 
00023 #ifndef OM_HGUARD_QUARTZ_POSTLIST_H
00024 #define OM_HGUARD_QUARTZ_POSTLIST_H
00025 
00026 #include <map>
00027 #include <string>
00028 
00029 #include "autoptr.h"
00030 #include "leafpostlist.h"
00031 #include <xapian/database.h>
00032 #include <xapian/visibility.h>
00033 #include "omassert.h"
00034 #include "quartz_types.h"
00035 #include "quartz_positionlist.h"
00036 
00037 using namespace std;
00038 
00039 class Bcursor;
00040 class QuartzDatabase;
00041 
00042 class QPostlistChunkReader;
00043 class QPostlistChunkWriter;
00044 
00045 class QuartzPostListTable : public Btree {
00046     public:
00061         QuartzPostListTable(string path_, bool readonly_)
00062             : Btree(path_ + "/postlist_", readonly_) { }
00063 
00065         void merge_changes(
00066             const map<string, map<Xapian::docid, pair<char, Xapian::termcount> > > & mod_plists,
00067             const map<Xapian::docid, Xapian::termcount> & doclens,
00068             const map<string, pair<Xapian::termcount_diff, Xapian::termcount_diff> > & freq_deltas);
00069 
00070         Xapian::docid get_chunk(const string &tname,
00071                 Xapian::docid did, bool adding,
00072                 QPostlistChunkReader ** from, QPostlistChunkWriter **to);
00073 
00078         Xapian::doccount get_termfreq(const std::string & term) const;
00079 
00084         Xapian::termcount get_collection_freq(const std::string & term) const;
00085 };
00086 
00089 class XAPIAN_VISIBILITY_DEFAULT QuartzPostList : public LeafPostList {
00090     private:
00094         Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> this_db;
00095 
00097         const Btree * table;
00098 
00100         const Btree * positiontable;
00101 
00103         string tname;
00104 
00106         AutoPtr<Bcursor> cursor;
00107 
00109         bool is_last_chunk;
00110 
00112         Xapian::docid first_did_in_chunk;
00113 
00115         Xapian::docid last_did_in_chunk;
00116 
00118         const char * pos;
00119 
00121         const char * end;
00122 
00124         Xapian::docid did;
00125 
00127         quartz_doclen_t doclength;
00128 
00130         Xapian::termcount wdf;
00131 
00133         bool is_at_end;
00134 
00136         bool have_started;
00137 
00139         Xapian::doccount number_of_entries;
00140 
00142         QuartzPositionList positionlist;
00143 
00145         QuartzPostList(const QuartzPostList &);
00146 
00148         void operator=(const QuartzPostList &);
00149 
00153         bool next_in_chunk();
00154 
00160         void next_chunk();
00161 
00169         bool current_chunk_contains(Xapian::docid desired_did);
00170 
00182         void move_to_chunk_containing(Xapian::docid desired_did);
00183 
00193         bool move_forward_in_chunk_to_at_least(Xapian::docid desired_did);
00194 
00195     public:
00197         QuartzPostList(Xapian::Internal::RefCntPtr<const Xapian::Database::Internal> this_db_,
00198                        const Btree * table_,
00199                        const Btree * positiontable_,
00200                        const string & tname);
00201 
00203         ~QuartzPostList();
00204 
00209         Xapian::doccount get_termfreq() const { return number_of_entries; }
00210 
00212         Xapian::docid get_docid() const { Assert(have_started); return did; }
00213 
00215         Xapian::doclength get_doclength() const {
00216             Assert(have_started);
00217             return static_cast<Xapian::doclength>(doclength);
00218         }
00219 
00223         Xapian::termcount get_wdf() const { Assert(have_started); return wdf; }
00224 
00227         PositionList *read_position_list();
00228 
00231         PositionList * open_position_list() const;
00232 
00234         PostList * next(Xapian::weight w_min);
00235 
00237         PostList * skip_to(Xapian::docid desired_did, Xapian::weight w_min);
00238 
00240         bool at_end() const { return is_at_end; }
00241 
00243         std::string get_description() const;
00244 
00246         static void read_number_of_entries(const char ** posptr,
00247                                            const char * end,
00248                                            Xapian::termcount * number_of_entries_ptr,
00249                                            Xapian::termcount * collection_freq_ptr);
00250 };
00251 
00252 #endif /* OM_HGUARD_QUARTZ_POSTLIST_H */

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