backends/flint/flint_positionlist.h

Go to the documentation of this file.
00001 /* flint_positionlist.h: A position list in a flint database.
00002  *
00003  * Copyright (C) 2005,2006 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_HGUARD_FLINT_POSITIONLIST_H
00022 #define XAPIAN_HGUARD_FLINT_POSITIONLIST_H
00023 
00024 #include <xapian/types.h>
00025 
00026 #include "flint_table.h"
00027 #include "flint_utils.h"
00028 #include "positionlist.h"
00029 
00030 #include <string>
00031 #include <vector>
00032 
00033 using namespace std;
00034 
00035 class FlintPositionListTable : public FlintTable {
00036     static string make_key(Xapian::docid did, const string & tname) {
00037         return pack_uint_preserving_sort(did) + tname;
00038     }
00039 
00040   public:
00049     FlintPositionListTable(string dbdir, bool readonly)
00050         : FlintTable(dbdir + "/position.", readonly, DONT_COMPRESS, true) { }
00051 
00053     void set_positionlist(Xapian::docid did, const string & tname,
00054                           Xapian::PositionIterator pos,
00055                           const Xapian::PositionIterator &pos_end);
00056 
00058     void delete_positionlist(Xapian::docid did, const string & tname) {
00059         del(make_key(did, tname));
00060     }
00061 
00063     Xapian::termcount positionlist_count(Xapian::docid did,
00064                                          const string & term) const;
00065 };
00066 
00068 class FlintPositionList : public PositionList {
00070     vector<Xapian::termpos> positions;
00071 
00073     vector<Xapian::termpos>::const_iterator current_pos;
00074 
00076     bool have_started;
00077 
00079     void next_internal();
00080 
00082     FlintPositionList(const FlintPositionList &);
00083 
00085     void operator=(const FlintPositionList &);
00086 
00087   public:
00089     FlintPositionList() : have_started(false) {}
00090 
00092     FlintPositionList(const FlintTable * table, Xapian::docid did,
00093                       const string & tname) {
00094         (void)read_data(table, did, tname);
00095     }
00096 
00098     ~FlintPositionList() { }
00099 
00104     bool read_data(const FlintTable * table, Xapian::docid did,
00105                    const string & tname);
00106 
00108     Xapian::termcount get_size() const;
00109 
00115     Xapian::termpos get_position() const;
00116 
00118     void next();
00119 
00121     void skip_to(Xapian::termpos termpos);
00122 
00124     bool at_end() const;
00125 };
00126 
00127 #endif /* XAPIAN_HGUARD_FLINT_POSITIONLIST_H */

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