backends/quartz/quartz_positionlist.h

Go to the documentation of this file.
00001 /* quartz_positionlist.h: Position lists in quartz databases
00002  *
00003  * ----START-LICENCE----
00004  * Copyright 1999,2000,2001 BrightStation PLC
00005  * Copyright 2001 Hein Ragas
00006  * Copyright 2002 Ananova Ltd
00007  * Copyright 2002,2003,2004 Olly Betts
00008  *
00009  * This program is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU General Public License as
00011  * published by the Free Software Foundation; either version 2 of the
00012  * License, or (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00022  * USA
00023  * -----END-LICENCE-----
00024  */
00025 
00026 #ifndef OM_HGUARD_QUARTZ_POSITIONLIST_H
00027 #define OM_HGUARD_QUARTZ_POSITIONLIST_H
00028 
00029 #include <xapian/types.h>
00030 #include "positionlist.h"
00031 #include "btree.h"
00032 
00033 #include <string>
00034 
00035 using namespace std;
00036 
00037 class QuartzPositionListTable : public Btree {
00038     public:
00053         QuartzPositionListTable(string path_, bool readonly_)
00054             : Btree(path_ + "/position_", readonly_) { }
00055 
00057         void set_positionlist(Xapian::docid did, const string & tname,
00058                         Xapian::PositionIterator pos,
00059                         const Xapian::PositionIterator &pos_end);
00060 
00062         void delete_positionlist(Xapian::docid did, const string & tname);
00063 };
00064 
00067 class QuartzPositionList : public PositionList {
00068     private:
00070         string data;
00071 
00074         const char * pos;
00075 
00078         const char * end;
00079 
00081         bool is_at_end;
00082 
00084         bool have_started;
00085 
00087         Xapian::termpos current_pos;
00088         
00090         Xapian::termcount number_of_entries;
00091 
00093         QuartzPositionList(const QuartzPositionList &);
00094 
00096         void operator=(const QuartzPositionList &);
00097 
00099         void next_internal();
00100 
00101     public:
00103         QuartzPositionList() : have_started(false) {}
00104 
00106         ~QuartzPositionList() { return; }
00107 
00109         void read_data(const Btree * table,
00110                        Xapian::docid did,
00111                        const string & tname);
00112 
00114         Xapian::termcount get_size() const {
00115             DEBUGCALL(DB, Xapian::termcount, "QuartzPositionList::get_size", "");
00116             RETURN(number_of_entries);
00117         }
00118 
00120         Xapian::termpos get_position() const {
00121             Assert(have_started);
00122             DEBUGCALL(DB, Xapian::termpos, "QuartzPositionList::get_position", "");
00123             RETURN(current_pos);
00124         }
00125 
00130         void next();
00131 
00136         void skip_to(Xapian::termpos termpos);
00137 
00139         bool at_end() const {
00140             DEBUGCALL(DB, bool, "QuartzPositionList::at_end", "");
00141             RETURN(is_at_end);
00142         }
00143 
00145         Xapian::termpos get_current_pos() {
00146             return(current_pos);
00147         }
00148 };
00149 
00150 #endif /* OM_HGUARD_QUARTZ_POSITIONLIST_H */

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