root / tags / 1.0.8 / xapian-core / backends / flint / flint_termlist.h

Revision 9256, 4.4 kB (checked in by olly, 16 months ago)

common/msvc_posix_wrapper.cc,common/msvc_posix_wrapper.h: Add
msvc_posix_rename() which can rename a file on top of another file.
common/stringutils.h: Add common_prefix_length() function.
backends/flint/: Clean up FlintWritableDatabase? - it now just
inherits from FlintDatabase? which allows several virtual methods
which just forwarded to FlintDatabase? to be dropped. Also, we
now no longer need to pass FlintTable objects to other classes
- they can just find the tables they want via the database pointer.
The never-used "store_termfreqs" flag has been dropped from the
termlist table entries - existing 1.0.x flint databases will be
automatically upgraded to the new version. Opening a database
now calls stat() less, so should be slightly more efficient.
And TermIterator::positionlist_count() now works for the flint
backend.
tests/Makefile.am,tests/api_db.cc,tests/testdata/flint-1.0.2/: New
test flintbackwardcompat2 which tests that we can open a flint
database from 1.0.2.
tests/api_wrdb.cc: New test adddoc4 which checks that termlists
handle an initial term of any valid length correctly.
tests/testdata/flint-1.0.1/postlist.DB: Mark as a binary file in
SVN.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/** @file flint_termlist.h
2 * @brief A TermList in a flint database.
3 */
4/* Copyright (C) 2007 Olly Betts
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (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 USA
19 */
20
21#ifndef XAPIAN_INCLUDED_FLINT_TERMLIST_H
22#define XAPIAN_INCLUDED_FLINT_TERMLIST_H
23
24#include <string>
25
26#include <xapian/base.h>
27#include <xapian/positioniterator.h>
28#include <xapian/types.h>
29
30namespace Xapian {
31    namespace Internal {
32        class ExpandStats;
33    }
34}
35
36#include "flint_database.h"
37#include "termlist.h"
38#include "flint_table.h"
39
40/// A TermList in a flint database.
41class FlintTermList : public TermList {
42    /// Don't allow assignment.
43    void operator=(const FlintTermList &);
44
45    /// Don't allow copying.
46    FlintTermList(const FlintTermList &);
47
48    /// The database we're reading data from.
49    Xapian::Internal::RefCntPtr<const FlintDatabase> db;
50
51    /// The document id that this TermList is for.
52    Xapian::docid did;
53
54    /// The length of document @a did.
55    flint_doclen_t doclen;
56
57    /// The number of entries in this termlist.
58    Xapian::termcount termlist_size;
59
60    /// The tag value from the termlist table which holds the encoded termlist.
61    std::string data;
62
63    /** Current position with the encoded tag value held in @a data.
64     *
65     *  If we've iterated to the end of the list, this gets set to NULL.
66     */
67    const char *pos;
68
69    /// Pointer to the end of the encoded tag value.
70    const char *end;
71
72    /// The termname at the current position.
73    std::string current_term;
74
75    /// The wdf for the term at the current position.
76    Xapian::termcount current_wdf;
77
78    /** The term frequency for the term at the current position.
79     *
80     *  This will have the value 0 if the term frequency has not yet been
81     *  looked up in the database (so it needs to be mutable).
82     */
83    mutable Xapian::doccount current_termfreq;
84
85  public:
86    /// Create a new FlintTermList object for document @a did_ in DB @a db_
87    FlintTermList(Xapian::Internal::RefCntPtr<const FlintDatabase> db_,
88                  Xapian::docid did_);
89
90    /** Return the length of this document.
91     *
92     *  This is a non-virtual method, used by FlintDatabase.
93     */
94    flint_doclen_t get_doclength() const;
95
96    /** Return approximate size of this termlist.
97     *
98     *  For a FlintTermList, this value will always be exact.
99     */
100    Xapian::termcount get_approx_size() const;
101
102    /// Collate weighting information for the current term.
103    void accumulate_stats(Xapian::Internal::ExpandStats & stats) const;
104
105    /// Return the termname at the current position.
106    std::string get_termname() const;
107
108    /// Return the wdf for the term at the current position.
109    Xapian::termcount get_wdf() const;
110
111    /** Return the term frequency for the term at the current position.
112     *
113     *  In order to be able to support updating databases efficiently, we can't
114     *  store this value in the termlist table, so it has to be read from the
115     *  postlist table, which is relatively expensive (compared to reading the
116     *  wdf for example).
117     */
118    Xapian::doccount get_termfreq() const;
119
120    /** Advance the current position to the next term in the termlist.
121     *
122     *  The list starts before the first term in the list, so next()
123     *  must be called before any methods which need the context of
124     *  the current position.
125     *
126     *  @return Always returns 0 for a FlintTermList.
127     */
128    TermList * next();
129
130    /// Return true if the current position is past the last term in this list.
131    bool at_end() const;
132
133    /// Return the length of the position list for the current position.
134    Xapian::termcount positionlist_count() const;
135
136    /// Return a PositionIterator for the current position.
137    Xapian::PositionIterator positionlist_begin() const;
138};
139
140#endif // XAPIAN_INCLUDED_FLINT_TERMLIST_H
Note: See TracBrowser for help on using the browser.