xapian-core  1.4.26
chert_positionlist.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2005,2006,2008,2009,2010,2011,2013 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19  * USA
20  */
21 
22 #ifndef XAPIAN_HGUARD_CHERT_POSITIONLIST_H
23 #define XAPIAN_HGUARD_CHERT_POSITIONLIST_H
24 
25 #include <xapian/types.h>
26 
27 #include "bitstream.h"
28 #include "chert_lazytable.h"
29 #include "pack.h"
30 #include "backends/positionlist.h"
31 
32 #include <string>
33 
34 using namespace std;
35 
37  public:
38  static string make_key(Xapian::docid did, const string & term) {
39  string key;
41  key += term;
42  return key;
43  }
44 
53  ChertPositionListTable(const string & dbdir, bool readonly)
54  : ChertLazyTable("position", dbdir + "/position.", readonly,
55  DONT_COMPRESS) { }
56 
62  void set_positionlist(Xapian::docid did, const string & tname,
64  const Xapian::PositionIterator &pos_end,
65  bool check_for_update);
66 
68  void delete_positionlist(Xapian::docid did, const string & tname) {
69  del(make_key(did, tname));
70  }
71 
73  Xapian::termcount positionlist_count(Xapian::docid did,
74  const string & term) const;
75 };
76 
81 
84 
87 
90 
93 
96 
98  void operator=(const ChertPositionList &);
99 
100  public:
103 
106  const string & tname) {
107  (void)read_data(table, did, tname);
108  }
109 
114  bool read_data(const ChertTable * table, Xapian::docid did,
115  const string & tname);
116 
118  Xapian::termcount get_approx_size() const;
119 
125  Xapian::termpos get_position() const;
126 
128  bool next();
129 
131  bool skip_to(Xapian::termpos termpos);
132 };
133 
134 #endif /* XAPIAN_HGUARD_CHERT_POSITIONLIST_H */
static string make_key(Xapian::docid did, const string &term)
Xapian::termcount size
Number of entries.
A position list in a chert database.
typedefs for Xapian
ChertPositionList(const ChertTable *table, Xapian::docid did, const string &tname)
Construct and initialise with data.
Class managing a Btree table in a Chert database.
Definition: chert_table.h:347
Abstract base class for iterating term positions in a document.
STL namespace.
Xapian::termpos last
Last entry.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
Definition: types.h:72
void C_pack_uint_preserving_sort(std::string &s, U value)
Append an encoded unsigned integer to a string, preserving the sort order.
Definition: pack.h:149
void delete_positionlist(Xapian::docid did, const string &tname)
Delete the position list for term tname in document did.
Xapian::termpos current_pos
Current entry.
Read a stream created by BitWriter.
Definition: bitstream.h:64
Class for iterating over term positions.
Classes to encode/decode a bitstream.
ChertPositionListTable(const string &dbdir, bool readonly)
Create a new ChertPositionListTable object.
const int DONT_COMPRESS
Definition: chert_table.h:94
bool have_started
Have we started iterating yet?
ChertPositionList()
Default constructor.
Subclass of ChertTable for deriving lazy tables from.
Pack types into strings and unpack them again.
unsigned XAPIAN_TERMPOS_BASE_TYPE termpos
A term position within a document or query.
Definition: types.h:83
BitReader rd
Interpolative decoder.
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:52
Abstract base class for iterating term positions in a document.
Definition: positionlist.h:31
string make_key(Xapian::docid did)
Definition: chert_record.cc:35