| 1 | /** @file |
| 2 | * @brief A TermList in a glass database. |
| 3 | */ |
| 4 | /* Copyright (C) 2007,2008,2009,2010,2011 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_GLASS_TERMLIST_H |
| 22 | #define XAPIAN_INCLUDED_GLASS_TERMLIST_Hcxx . . $ `backends/glass/glass_termlist.h:22:9`! |
| 23 | |
| 24 | #include <string> |
| 25 | |
| 26 | #include "xapian/intrusive_ptr.h"cxx . . $ `<file>/include/xapian/intrusive_ptr.h`/ |
| 27 | #include <xapian/positioniterator.h>cxx . . $ `<file>/include/xapian/positioniterator.h`/ |
| 28 | #include <xapian/types.h>cxx . . $ `<file>/include/xapian/types.h`/ |
| 29 | |
| 30 | namespace Xapiancxx . . $ Xapian/ { |
| 31 | namespace Internalcxx . . $ Xapian/Internal/ { |
| 32 | class ExpandStatscxx . . $ Xapian/Internal/ExpandStats#; |
| 33 | } |
| 34 | } |
| 35 | |
| 36 | #include "glass_database.h"cxx . . $ `<file>/backends/glass/glass_database.h`/ |
| 37 | #include "api/termlist.h"cxx . . $ `<file>/api/termlist.h`/ |
| 38 | #include "glass_table.h"cxx . . $ `<file>/backends/glass/glass_table.h`/ |
| 39 | |
| 40 | /// A TermList in a glass database. |
| 41 | class GlassTermListcxx . . $ GlassTermList# : public TermListcxx . . $ TermList# { |
| 42 | /// Don't allow assignment. |
| 43 | void operatorcxx . . $ GlassTermList#`operator=`(61c7a2db5cae8c74).=(const GlassTermListcxx . . $ GlassTermList# &); |
| 44 | |
| 45 | /// Don't allow copying. |
| 46 | GlassTermListcxx . . $ GlassTermList#GlassTermList(61c7a2db5cae8c74).(const GlassTermListcxx . . $ GlassTermList# &); |
| 47 | |
| 48 | /// The database we're reading data from. |
| 49 | Xapiancxx . . $ Xapian/::Internalcxx . . $ Xapian/Internal/::intrusive_ptrcxx . . $ Xapian/Internal/intrusive_ptr#<const GlassDatabasecxx . . $ GlassDatabase#> dbcxx . . $ GlassTermList#db.; |
| 50 | |
| 51 | /// The document id that this TermList is for. |
| 52 | Xapiancxx . . $ Xapian/::docidcxx . . $ Xapian/docid# didcxx . . $ GlassTermList#did.; |
| 53 | |
| 54 | /// The length of document @a did. |
| 55 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# doclencxx . . $ GlassTermList#doclen.; |
| 56 | |
| 57 | /// The number of entries in this termlist. |
| 58 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# termlist_sizecxx . . $ GlassTermList#termlist_size.; |
| 59 | |
| 60 | /// The tag value from the termlist table which holds the encoded termlist. |
| 61 | stdcxx . . $ std/::stringcxx . . $ std/string# datacxx . . $ GlassTermList#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 *poscxx . . $ GlassTermList#pos.; |
| 68 | |
| 69 | /// Pointer to the end of the encoded tag value. |
| 70 | const char *endcxx . . $ GlassTermList#end.; |
| 71 | |
| 72 | /// The termname at the current position. |
| 73 | stdcxx . . $ std/::stringcxx . . $ std/string# current_termcxx . . $ GlassTermList#current_term.; |
| 74 | |
| 75 | /// The wdf for the term at the current position. |
| 76 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# current_wdfcxx . . $ GlassTermList#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 Xapiancxx . . $ Xapian/::doccountcxx . . $ Xapian/doccount# current_termfreqcxx . . $ GlassTermList#current_termfreq.; |
| 84 | |
| 85 | public: |
| 86 | /** Create a new GlassTermList object for document @a did_ in DB @a db_ |
| 87 | * |
| 88 | * @param throw_if_not_present Specifies behaviour if document @a did_ |
| 89 | * isn't present: if true then throw |
| 90 | * DocNotFoundError, otherwise the |
| 91 | * constructed GlassTermList object will |
| 92 | * signal at_end() before next() is called |
| 93 | * (normally at_end() isn't meaningful |
| 94 | * on a freshly constructed TermList). |
| 95 | */ |
| 96 | GlassTermListcxx . . $ GlassTermList#GlassTermList(bee74f70357f3bf5).(Xapiancxx . . $ Xapian/::Internalcxx . . $ Xapian/Internal/::intrusive_ptrcxx . . $ Xapian/Internal/intrusive_ptr#<const GlassDatabasecxx . . $ GlassDatabase#> db_, |
| 97 | Xapiancxx . . $ Xapian/::docidcxx . . $ Xapian/docid# did_, bool throw_if_not_present = true); |
| 98 | |
| 99 | /** Return the length of this document. |
| 100 | * |
| 101 | * This is a non-virtual method, used by GlassDatabase. |
| 102 | */ |
| 103 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# get_doclengthcxx . . $ GlassTermList#get_doclength(ddd8539a2fcdd4ce).() const; |
| 104 | |
| 105 | /** Return the number of unique terms. |
| 106 | * |
| 107 | * This is a non-virtual method, used by GlassDatabase. |
| 108 | */ |
| 109 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# get_unique_termscxx . . $ GlassTermList#get_unique_terms(ddd8539a2fcdd4ce).() const; |
| 110 | |
| 111 | /** Return approximate size of this termlist. |
| 112 | * |
| 113 | * For a GlassTermList, this value will always be exact. |
| 114 | */ |
| 115 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# get_approx_sizecxx . . $ GlassTermList#get_approx_size(ddd8539a2fcdd4ce).() const; |
| 116 | |
| 117 | /// Collate weighting information for the current term. |
| 118 | void accumulate_statscxx . . $ GlassTermList#accumulate_stats(777225637cd5f0a1).(Xapiancxx . . $ Xapian/::Internalcxx . . $ Xapian/Internal/::ExpandStatscxx . . $ Xapian/Internal/ExpandStats# & stats) const; |
| 119 | |
| 120 | /// Return the termname at the current position. |
| 121 | stdcxx . . $ std/::stringcxx . . $ std/string# get_termnamecxx . . $ GlassTermList#get_termname(219584694fe2b248).() const; |
| 122 | |
| 123 | /// Return the wdf for the term at the current position. |
| 124 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# get_wdfcxx . . $ GlassTermList#get_wdf(ddd8539a2fcdd4ce).() const; |
| 125 | |
| 126 | /** Return the term frequency for the term at the current position. |
| 127 | * |
| 128 | * In order to be able to support updating databases efficiently, we can't |
| 129 | * store this value in the termlist table, so it has to be read from the |
| 130 | * postlist table, which is relatively expensive (compared to reading the |
| 131 | * wdf for example). |
| 132 | */ |
| 133 | Xapiancxx . . $ Xapian/::doccountcxx . . $ Xapian/doccount# get_termfreqcxx . . $ GlassTermList#get_termfreq(ddd8539a2fcdd4ce).() const; |
| 134 | |
| 135 | /** Advance the current position to the next term in the termlist. |
| 136 | * |
| 137 | * The list starts before the first term in the list, so next(), skip_to() |
| 138 | * or check() must be called before any methods which need the context of |
| 139 | * the current position. |
| 140 | * |
| 141 | * @return Always returns 0 for a GlassTermList. |
| 142 | */ |
| 143 | TermListcxx . . $ TermList# * nextcxx . . $ GlassTermList#next(cd86c745428e820f).(); |
| 144 | |
| 145 | TermListcxx . . $ TermList# * skip_tocxx . . $ GlassTermList#skip_to(c2d075377a6ea65f).(const stdcxx . . $ std/::stringcxx . . $ std/string# & term); |
| 146 | |
| 147 | /// Return true if the current position is past the last term in this list. |
| 148 | bool at_endcxx . . $ GlassTermList#at_end(50ce9a9e25b4a850).() const; |
| 149 | |
| 150 | /// Return the length of the position list for the current position. |
| 151 | Xapiancxx . . $ Xapian/::termcountcxx . . $ Xapian/termcount# positionlist_countcxx . . $ GlassTermList#positionlist_count(ddd8539a2fcdd4ce).() const; |
| 152 | |
| 153 | /// Return a PositionIterator for the current position. |
| 154 | Xapiancxx . . $ Xapian/::PositionIteratorcxx . . $ Xapian/PositionIterator# positionlist_begincxx . . $ GlassTermList#positionlist_begin(1ab6e7e44dfdf8aa).() const; |
| 155 | }; |
| 156 | |
| 157 | #endif // XAPIAN_INCLUDED_GLASS_TERMLIST_H |