| database.h | | database.h | |
|
| /** \file database.h | | /** @file database.h | |
| * \brief API for working with Xapian databases | | * @brief API for working with Xapian databases | |
| */ | | */ | |
| /* Copyright 1999,2000,2001 BrightStation PLC | | /* Copyright 1999,2000,2001 BrightStation PLC | |
| * Copyright 2002 Ananova Ltd | | * Copyright 2002 Ananova Ltd | |
|
| * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts | | * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011,2012 Olly Betts | |
| * Copyright 2006,2008 Lemur Consulting Ltd | | * Copyright 2006,2008 Lemur Consulting Ltd | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| * License, or (at your option) any later version. | | * License, or (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 28 | | skipping to change at line 28 | |
| * | | * | |
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU General Public License | |
| * along with this program; if not, write to the Free Software | | * along with this program; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
| * USA | | * USA | |
| */ | | */ | |
| | | | |
| #ifndef XAPIAN_INCLUDED_DATABASE_H | | #ifndef XAPIAN_INCLUDED_DATABASE_H | |
| #define XAPIAN_INCLUDED_DATABASE_H | | #define XAPIAN_INCLUDED_DATABASE_H | |
| | | | |
|
| | | #include <iosfwd> | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| | | | |
|
| #include <xapian/base.h> | | #include <xapian/intrusive_ptr.h> | |
| #include <xapian/document.h> | | | |
| #include <xapian/types.h> | | #include <xapian/types.h> | |
| #include <xapian/positioniterator.h> | | #include <xapian/positioniterator.h> | |
| #include <xapian/postingiterator.h> | | #include <xapian/postingiterator.h> | |
| #include <xapian/termiterator.h> | | #include <xapian/termiterator.h> | |
| #include <xapian/valueiterator.h> | | #include <xapian/valueiterator.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
|
| | | class Document; | |
| | | | |
| /** This class is used to access a database, or a group of databases. | | /** This class is used to access a database, or a group of databases. | |
| * | | * | |
| * For searching, this class is used in conjunction with an Enquire object
. | | * For searching, this class is used in conjunction with an Enquire object
. | |
| * | | * | |
| * @exception InvalidArgumentError will be thrown if an invalid | | * @exception InvalidArgumentError will be thrown if an invalid | |
| * argument is supplied, for example, an unknown database type. | | * argument is supplied, for example, an unknown database type. | |
| * | | * | |
| * @exception DatabaseOpeningError may be thrown if the database cannot | | * @exception DatabaseOpeningError may be thrown if the database cannot | |
| * be opened (for example, a required file cannot be found). | | * be opened (for example, a required file cannot be found). | |
| * | | * | |
| * @exception DatabaseVersionError may be thrown if the database is in an | | * @exception DatabaseVersionError may be thrown if the database is in an | |
| * unsupported format (for example, created by a newer version of Xapian | | * unsupported format (for example, created by a newer version of Xapian | |
| * which uses an incompatible format). | | * which uses an incompatible format). | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT Database { | | class XAPIAN_VISIBILITY_DEFAULT Database { | |
| public: | | public: | |
| class Internal; | | class Internal; | |
| /// @private @internal Reference counted internals. | | /// @private @internal Reference counted internals. | |
|
| std::vector<Xapian::Internal::RefCntPtr<Internal> > internal; | | std::vector<Xapian::Internal::intrusive_ptr<Internal> > internal; | |
| | | | |
| /** @private @internal Get a document from the database, but doesn't | | /** @private @internal Get a document from the database, but doesn't | |
| * need to check if it exists. | | * need to check if it exists. | |
| * | | * | |
| * This method returns a Xapian::Document object which provides the | | * This method returns a Xapian::Document object which provides the | |
| * information about a document. If the document doesn't exist, | | * information about a document. If the document doesn't exist, | |
| * either a NULL pointer may be returned, or the returned object wi
ll | | * either a NULL pointer may be returned, or the returned object wi
ll | |
| * throw DocNotFoundError when you try to access it. | | * throw DocNotFoundError when you try to access it. | |
| * | | * | |
| * The caller should delete the returned object when it has finishe
d | | * The caller should delete the returned object when it has finishe
d | |
| * with it. | | * with it. | |
| * | | * | |
|
| | | * The returned value is cast to void* to avoid needing to include | |
| | | * xapian/document.h from here. | |
| | | * | |
| * @param did The document id of the document to retrieve. | | * @param did The document id of the document to retrieve. | |
| * | | * | |
|
| * @return Pointer to Document::Internal object. | | * @return Pointer to Document::Internal object cast to void*. | |
| */ | | */ | |
|
| Document::Internal * get_document_lazily(Xapian::docid did) const; | | void * get_document_lazily_(Xapian::docid did) const; | |
| | | | |
| /** Add an existing database (or group of databases) to those | | /** Add an existing database (or group of databases) to those | |
| * accessed by this object. | | * accessed by this object. | |
| * | | * | |
| * @param database the database(s) to add. | | * @param database the database(s) to add. | |
| */ | | */ | |
| void add_database(const Database & database); | | void add_database(const Database & database); | |
| | | | |
| /** Create a Database with no databases in. | | /** Create a Database with no databases in. | |
| */ | | */ | |
| | | | |
| skipping to change at line 130 | | skipping to change at line 135 | |
| void operator=(const Database &other); | | void operator=(const Database &other); | |
| | | | |
| /** Re-open the database. | | /** Re-open the database. | |
| * | | * | |
| * This re-opens the database(s) to the latest available version(s)
. | | * This re-opens the database(s) to the latest available version(s)
. | |
| * It can be used either to make sure the latest results are return
ed, | | * It can be used either to make sure the latest results are return
ed, | |
| * or to recover from a Xapian::DatabaseModifiedError. | | * or to recover from a Xapian::DatabaseModifiedError. | |
| * | | * | |
| * Calling reopen() on a database which has been closed (with @a | | * Calling reopen() on a database which has been closed (with @a | |
| * close()) will always raise a Xapian::DatabaseError. | | * close()) will always raise a Xapian::DatabaseError. | |
|
| | | * | |
| | | * @return true if the database might have been reopened (if fa | |
| | | lse | |
| | | * is returned, the database definitely hasn't been | |
| | | * reopened, which applications may find useful when | |
| | | * caching results, etc). In Xapian < 1.3.0, this meth | |
| | | od | |
| | | * did not return a value. | |
| */ | | */ | |
|
| void reopen(); | | bool reopen(); | |
| | | | |
| /** Close the database. | | /** Close the database. | |
| * | | * | |
| * This closes the database and closes all its file handles. | | * This closes the database and closes all its file handles. | |
| * | | * | |
| * For a WritableDatabase, if a transaction is active it will be | | * For a WritableDatabase, if a transaction is active it will be | |
| * aborted, while if no transaction is active commit() will be | | * aborted, while if no transaction is active commit() will be | |
| * implicitly called. Also the write lock is released. | | * implicitly called. Also the write lock is released. | |
| * | | * | |
| * Closing a database cannot be undone - in particular, calling | | * Closing a database cannot be undone - in particular, calling | |
| | | | |
| skipping to change at line 164 | | skipping to change at line 175 | |
| * cached) | | * cached) | |
| * | | * | |
| * - raise a Xapian::DatabaseError exception indicating that the | | * - raise a Xapian::DatabaseError exception indicating that the | |
| * database is closed. | | * database is closed. | |
| * | | * | |
| * The reason for this behaviour is that otherwise we'd have to che
ck | | * The reason for this behaviour is that otherwise we'd have to che
ck | |
| * that the database is still open on every method call on every | | * that the database is still open on every method call on every | |
| * object associated with a Database, when in many cases they are | | * object associated with a Database, when in many cases they are | |
| * working on data which has already been loaded and so they are ab
le | | * working on data which has already been loaded and so they are ab
le | |
| * to just behave correctly. | | * to just behave correctly. | |
|
| * | | | |
| * This method was added in Xapian 1.1.0. | | | |
| */ | | */ | |
| virtual void close(); | | virtual void close(); | |
| | | | |
| /// Return a string describing this object. | | /// Return a string describing this object. | |
| virtual std::string get_description() const; | | virtual std::string get_description() const; | |
| | | | |
| /** An iterator pointing to the start of the postlist | | /** An iterator pointing to the start of the postlist | |
| * for a given term. | | * for a given term. | |
| * | | * | |
| * @param tname The termname to iterate postings for. If th
e | | * @param tname The termname to iterate postings for. If th
e | |
| | | | |
| skipping to change at line 331 | | skipping to change at line 340 | |
| /// Get an upper bound on the length of a document in this DB. | | /// Get an upper bound on the length of a document in this DB. | |
| Xapian::termcount get_doclength_upper_bound() const; | | Xapian::termcount get_doclength_upper_bound() const; | |
| | | | |
| /// Get an upper bound on the wdf of term @a term. | | /// Get an upper bound on the wdf of term @a term. | |
| Xapian::termcount get_wdf_upper_bound(const std::string & term) cons
t; | | Xapian::termcount get_wdf_upper_bound(const std::string & term) cons
t; | |
| | | | |
| /// Return an iterator over the value in slot @a slot for each docum
ent. | | /// Return an iterator over the value in slot @a slot for each docum
ent. | |
| ValueIterator valuestream_begin(Xapian::valueno slot) const; | | ValueIterator valuestream_begin(Xapian::valueno slot) const; | |
| | | | |
| /// Return end iterator corresponding to valuestream_begin(). | | /// Return end iterator corresponding to valuestream_begin(). | |
|
| ValueIteratorEnd_ valuestream_end(Xapian::valueno) const { | | ValueIterator valuestream_end(Xapian::valueno) const { | |
| return ValueIteratorEnd_(); | | return ValueIterator(); | |
| } | | } | |
| | | | |
| /// Get the length of a document. | | /// Get the length of a document. | |
| Xapian::termcount get_doclength(Xapian::docid did) const; | | Xapian::termcount get_doclength(Xapian::docid did) const; | |
| | | | |
| /** Send a "keep-alive" to remote databases to stop them timing out. | | /** Send a "keep-alive" to remote databases to stop them timing out. | |
| * | | * | |
| * Has no effect on non-remote databases. | | * Has no effect on non-remote databases. | |
| */ | | */ | |
| void keep_alive(); | | void keep_alive(); | |
| | | | |
| skipping to change at line 475 | | skipping to change at line 484 | |
| * the database files) will have the same UUID. However, copies (m
ade | | * the database files) will have the same UUID. However, copies (m
ade | |
| * with copydatabase, or xapian-compact) will have different UUIDs. | | * with copydatabase, or xapian-compact) will have different UUIDs. | |
| * | | * | |
| * If the backend does not support UUIDs or this database has no | | * If the backend does not support UUIDs or this database has no | |
| * subdatabases, the UUID will be empty. | | * subdatabases, the UUID will be empty. | |
| * | | * | |
| * If this database has multiple sub-databases, the UUID string wil
l | | * If this database has multiple sub-databases, the UUID string wil
l | |
| * contain the UUIDs of all the sub-databases. | | * contain the UUIDs of all the sub-databases. | |
| */ | | */ | |
| std::string get_uuid() const; | | std::string get_uuid() const; | |
|
| | | | |
| | | /** Check the integrity of a database or database table. | |
| | | * | |
| | | * This method is currently experimental, and may change incompatib | |
| | | ly | |
| | | * or possibly even be removed. Feedback on how well it works and | |
| | | * how it might be improved are welcome. | |
| | | * | |
| | | * @param path Path to database or table | |
| | | * @param opts Options to use for check | |
| | | * @param out std::ostream to write output to | |
| | | */ | |
| | | static size_t check(const std::string & path, int opts, | |
| | | std::ostream &out); | |
| | | | |
| | | /** Check the integrity of a database or database table. | |
| | | * | |
| | | * This method is currently experimental, and may change incompatib | |
| | | ly | |
| | | * or possibly even be removed. Feedback on how well it works and | |
| | | * how it might be improved are welcome. | |
| | | * | |
| | | * @param path Path to database or table | |
| | | * @param opts Options to use for check | |
| | | */ | |
| | | static size_t check(const std::string & path, int opts); | |
| }; | | }; | |
| | | | |
| /** This class provides read/write access to a database. | | /** This class provides read/write access to a database. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database { | | class XAPIAN_VISIBILITY_DEFAULT WritableDatabase : public Database { | |
| public: | | public: | |
| /** Destroy this handle on the database. | | /** Destroy this handle on the database. | |
| * | | * | |
| * If no other handles to this database remain, the database will b
e | | * If no other handles to this database remain, the database will b
e | |
| * closed. | | * closed. | |
| | | | |
| skipping to change at line 936 | | skipping to change at line 969 | |
| | | | |
| /** Open for read/write; create if no db exists. */ | | /** Open for read/write; create if no db exists. */ | |
| const int DB_CREATE_OR_OPEN = 1; | | const int DB_CREATE_OR_OPEN = 1; | |
| /** Create a new database; fail if db exists. */ | | /** Create a new database; fail if db exists. */ | |
| const int DB_CREATE = 2; | | const int DB_CREATE = 2; | |
| /** Overwrite existing db; create if none exists. */ | | /** Overwrite existing db; create if none exists. */ | |
| const int DB_CREATE_OR_OVERWRITE = 3; | | const int DB_CREATE_OR_OVERWRITE = 3; | |
| /** Open for read/write; fail if no db exists. */ | | /** Open for read/write; fail if no db exists. */ | |
| const int DB_OPEN = 4; | | const int DB_OPEN = 4; | |
| | | | |
|
| | | /** Show a short-format display of the B-tree contents. | |
| | | * | |
| | | * For use with Xapian::Database::check(). | |
| | | */ | |
| | | const int DBCHECK_SHORT_TREE = 1; | |
| | | | |
| | | /** Show a full display of the B-tree contents. | |
| | | * | |
| | | * For use with Xapian::Database::check(). | |
| | | */ | |
| | | const int DBCHECK_FULL_TREE = 2; | |
| | | | |
| | | /** Show the bitmap for the B-tree. | |
| | | * | |
| | | * For use with Xapian::Database::check(). | |
| | | */ | |
| | | const int DBCHECK_SHOW_BITMAP = 4; | |
| | | | |
| | | /** Show statistics for the B-tree. | |
| | | * | |
| | | * For use with Xapian::Database::check(). | |
| | | */ | |
| | | const int DBCHECK_SHOW_STATS = 8; | |
| | | | |
| } | | } | |
| | | | |
| #endif /* XAPIAN_INCLUDED_DATABASE_H */ | | #endif /* XAPIAN_INCLUDED_DATABASE_H */ | |
| | | | |
End of changes. 15 change blocks. |
| 13 lines changed or deleted | | 74 lines changed or added | |
|
| enquire.h | | enquire.h | |
|
| /** \file enquire.h | | /** @file enquire.h | |
| * \brief API for running queries | | * @brief API for running queries | |
| */ | | */ | |
| /* Copyright 1999,2000,2001 BrightStation PLC | | /* Copyright 1999,2000,2001 BrightStation PLC | |
| * Copyright 2001,2002 Ananova Ltd | | * Copyright 2001,2002 Ananova Ltd | |
| * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts | | * Copyright 2002,2003,2004,2005,2006,2007,2008,2009,2011 Olly Betts | |
| * Copyright 2009 Lemur Consulting Ltd | | * Copyright 2009 Lemur Consulting Ltd | |
| * Copyright 2011 Action Without Borders | | * Copyright 2011 Action Without Borders | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| | | | |
| skipping to change at line 31 | | skipping to change at line 31 | |
| * along with this program; if not, write to the Free Software | | * along with this program; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
| * USA | | * USA | |
| */ | | */ | |
| | | | |
| #ifndef XAPIAN_INCLUDED_ENQUIRE_H | | #ifndef XAPIAN_INCLUDED_ENQUIRE_H | |
| #define XAPIAN_INCLUDED_ENQUIRE_H | | #define XAPIAN_INCLUDED_ENQUIRE_H | |
| | | | |
| #include <string> | | #include <string> | |
| | | | |
|
| #include <xapian/base.h> | | #include <xapian/intrusive_ptr.h> | |
| #include <xapian/deprecated.h> | | | |
| #include <xapian/keymaker.h> | | | |
| #include <xapian/types.h> | | #include <xapian/types.h> | |
| #include <xapian/termiterator.h> | | #include <xapian/termiterator.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
| class Database; | | class Database; | |
| class Document; | | class Document; | |
| class ErrorHandler; | | class ErrorHandler; | |
| class ExpandDecider; | | class ExpandDecider; | |
|
| | | class KeyMaker; | |
| class MatchSpy; | | class MatchSpy; | |
| class MSetIterator; | | class MSetIterator; | |
| class Query; | | class Query; | |
| class Weight; | | class Weight; | |
| | | | |
| /** A match set (MSet). | | /** A match set (MSet). | |
| * This class represents (a portion of) the results of a query. | | * This class represents (a portion of) the results of a query. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT MSet { | | class XAPIAN_VISIBILITY_DEFAULT MSet { | |
| public: | | public: | |
| class Internal; | | class Internal; | |
|
| /// @private @internal Reference counted internals. | | /// @internal Reference counted internals. | |
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
|
| /// @private @internal Constructor for internal use. | | /// @internal Constructor for internal use. | |
| explicit MSet(MSet::Internal * internal_); | | explicit MSet(Internal * internal_); | |
| | | | |
| /// Create an empty Xapian::MSet. | | /// Create an empty Xapian::MSet. | |
| MSet(); | | MSet(); | |
| | | | |
| /// Destroy a Xapian::MSet. | | /// Destroy a Xapian::MSet. | |
| ~MSet(); | | ~MSet(); | |
| | | | |
| /// Copying is allowed (and is cheap). | | /// Copying is allowed (and is cheap). | |
| MSet(const MSet & other); | | MSet(const MSet & other); | |
| | | | |
| | | | |
| skipping to change at line 104 | | skipping to change at line 103 | |
| /** Fetch all the items in the MSet. | | /** Fetch all the items in the MSet. | |
| */ | | */ | |
| void fetch() const; | | void fetch() const; | |
| | | | |
| /** This converts the weight supplied to a percentage score. | | /** This converts the weight supplied to a percentage score. | |
| * The return value will be in the range 0 to 100, and will be 0 if | | * The return value will be in the range 0 to 100, and will be 0 if | |
| * and only if the item did not match the query at all. | | * and only if the item did not match the query at all. | |
| * | | * | |
| * @param wt The weight to convert. | | * @param wt The weight to convert. | |
| */ | | */ | |
|
| Xapian::percent convert_to_percent(Xapian::weight wt) const; | | int convert_to_percent(double wt) const; | |
| | | | |
| /// Return the percentage score for a particular item. | | /// Return the percentage score for a particular item. | |
|
| Xapian::percent convert_to_percent(const MSetIterator &it) const; | | int convert_to_percent(const MSetIterator &it) const; | |
| | | | |
| /** Return the term frequency of the given query term. | | /** Return the term frequency of the given query term. | |
| * | | * | |
| * @param tname The term to look for. | | * @param tname The term to look for. | |
| * | | * | |
| * This is sometimes more efficient than asking the database direct
ly | | * This is sometimes more efficient than asking the database direct
ly | |
| * for the term frequency - in particular, if the term was in the | | * for the term frequency - in particular, if the term was in the | |
| * query, its frequency will usually be cached in the MSet. | | * query, its frequency will usually be cached in the MSet. | |
| */ | | */ | |
| Xapian::doccount get_termfreq(const std::string &tname) const; | | Xapian::doccount get_termfreq(const std::string &tname) const; | |
| | | | |
| /** Return the term weight of the given query term. | | /** Return the term weight of the given query term. | |
| * | | * | |
| * @param tname The term to look for. | | * @param tname The term to look for. | |
| * | | * | |
| * @exception Xapian::InvalidArgumentError is thrown if the term w
as | | * @exception Xapian::InvalidArgumentError is thrown if the term w
as | |
| * not in the query. | | * not in the query. | |
| */ | | */ | |
|
| Xapian::weight get_termweight(const std::string &tname) const; | | double get_termweight(const std::string &tname) const; | |
| | | | |
| /** The index of the first item in the result which was put into the | | /** The index of the first item in the result which was put into the | |
| * MSet. | | * MSet. | |
| * | | * | |
| * This corresponds to the parameter "first" specified in | | * This corresponds to the parameter "first" specified in | |
| * Xapian::Enquire::get_mset(). A value of 0 corresponds to the | | * Xapian::Enquire::get_mset(). A value of 0 corresponds to the | |
| * highest result being the first item in the MSet. | | * highest result being the first item in the MSet. | |
| */ | | */ | |
| Xapian::doccount get_firstitem() const; | | Xapian::doccount get_firstitem() const; | |
| | | | |
| | | | |
| skipping to change at line 194 | | skipping to change at line 193 | |
| * would match the query if collapsing wasn't used. | | * would match the query if collapsing wasn't used. | |
| */ | | */ | |
| Xapian::doccount get_uncollapsed_matches_upper_bound() const; | | Xapian::doccount get_uncollapsed_matches_upper_bound() const; | |
| | | | |
| /** The maximum possible weight in the MSet. | | /** The maximum possible weight in the MSet. | |
| * | | * | |
| * This weight is likely not to be attained in the set of results, | | * This weight is likely not to be attained in the set of results, | |
| * but represents an upper bound on the weight which a document | | * but represents an upper bound on the weight which a document | |
| * could attain for the given query. | | * could attain for the given query. | |
| */ | | */ | |
|
| Xapian::weight get_max_possible() const; | | double get_max_possible() const; | |
| | | | |
| /** The greatest weight which is attained by any document in the | | /** The greatest weight which is attained by any document in the | |
| * database. | | * database. | |
| * | | * | |
| * If firstitem == 0 and the primary ordering is by relevance, this
is | | * If firstitem == 0 and the primary ordering is by relevance, this
is | |
| * the weight of the first entry in the MSet. | | * the weight of the first entry in the MSet. | |
| * | | * | |
| * If no documents are found by the query, this will be 0. | | * If no documents are found by the query, this will be 0. | |
| * | | * | |
| * Note that calculation of max_attained requires calculation | | * Note that calculation of max_attained requires calculation | |
| * of at least one result item - therefore, if no items were | | * of at least one result item - therefore, if no items were | |
| * requested when the query was performed (by specifying | | * requested when the query was performed (by specifying | |
| * maxitems = 0 in Xapian::Enquire::get_mset()), this value will be
0. | | * maxitems = 0 in Xapian::Enquire::get_mset()), this value will be
0. | |
| */ | | */ | |
|
| Xapian::weight get_max_attained() const; | | double get_max_attained() const; | |
| | | | |
| /** The number of items in this MSet */ | | /** The number of items in this MSet */ | |
| Xapian::doccount size() const; | | Xapian::doccount size() const; | |
| | | | |
| /** Required to allow use as an STL container. */ | | /** Required to allow use as an STL container. */ | |
| Xapian::doccount max_size() const { return size(); } | | Xapian::doccount max_size() const { return size(); } | |
| | | | |
| /** Test if this MSet is empty */ | | /** Test if this MSet is empty */ | |
| bool empty() const; | | bool empty() const; | |
| | | | |
| | | | |
| skipping to change at line 352 | | skipping to change at line 351 | |
| * | | * | |
| * The rank is the position that this document is at in the ordered | | * The rank is the position that this document is at in the ordered | |
| * list of results of the query. The result is 0-based - i.e. the | | * list of results of the query. The result is 0-based - i.e. the | |
| * top-ranked document has a rank of 0. | | * top-ranked document has a rank of 0. | |
| */ | | */ | |
| Xapian::doccount get_rank() const { | | Xapian::doccount get_rank() const { | |
| return mset.get_firstitem() + index; | | return mset.get_firstitem() + index; | |
| } | | } | |
| | | | |
| /// Get the weight of the document at the current position | | /// Get the weight of the document at the current position | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| | | | |
| /** Get the collapse key for this document. | | /** Get the collapse key for this document. | |
| */ | | */ | |
| std::string get_collapse_key() const; | | std::string get_collapse_key() const; | |
| | | | |
| /** Get an estimate of the number of documents that have been collap
sed | | /** Get an estimate of the number of documents that have been collap
sed | |
| * into this one. | | * into this one. | |
| * | | * | |
| * The estimate will always be less than or equal to the actual | | * The estimate will always be less than or equal to the actual | |
| * number of other documents satisfying the match criteria with the | | * number of other documents satisfying the match criteria with the | |
| | | | |
| skipping to change at line 378 | | skipping to change at line 377 | |
| * documents. So this method may be used to inform the user that | | * documents. So this method may be used to inform the user that | |
| * there are "at least N other matches in this group", or to contro
l | | * there are "at least N other matches in this group", or to contro
l | |
| * whether to offer a "show other documents in this group" feature | | * whether to offer a "show other documents in this group" feature | |
| * (but note that it may not offer it in every case where it would | | * (but note that it may not offer it in every case where it would | |
| * show other documents). | | * show other documents). | |
| */ | | */ | |
| Xapian::doccount get_collapse_count() const; | | Xapian::doccount get_collapse_count() const; | |
| | | | |
| /** This returns the weight of the document as a percentage score. | | /** This returns the weight of the document as a percentage score. | |
| * | | * | |
|
| | | * You probably don't want to show these percentage scores to end | |
| | | * users in new applications - they're not really a percentage of | |
| | | * anything meaningful, and research seems to suggest that users | |
| | | * don't find numeric scores in search results useful. | |
| | | * | |
| * The return value will be an integer in the range 0 to 100: 0 | | * The return value will be an integer in the range 0 to 100: 0 | |
| * meaning that the item did not match the query at all. | | * meaning that the item did not match the query at all. | |
| * | | * | |
| * The intention is that the highest weighted document will get 100 | | * The intention is that the highest weighted document will get 100 | |
| * if it matches all the weight-contributing terms in the query. | | * if it matches all the weight-contributing terms in the query. | |
| * However, currently it may get a lower percentage score if you | | * However, currently it may get a lower percentage score if you | |
| * use a MatchDecider and the sorting is primarily by value. | | * use a MatchDecider and the sorting is primarily by value. | |
| * In this case, the percentage for a particular document may vary | | * In this case, the percentage for a particular document may vary | |
| * depending on the first, max_size, and checkatleast parameters | | * depending on the first, max_size, and checkatleast parameters | |
| * passed to Enquire::get_mset() (this bug is hard to fix without | | * passed to Enquire::get_mset() (this bug is hard to fix without | |
| * having to apply the MatchDecider to potentially many more | | * having to apply the MatchDecider to potentially many more | |
| * documents, which is potentially costly). | | * documents, which is potentially costly). | |
| */ | | */ | |
|
| Xapian::percent get_percent() const; | | int get_percent() const; | |
| | | | |
| /// Return a string describing this object. | | /// Return a string describing this object. | |
| std::string get_description() const; | | std::string get_description() const; | |
| | | | |
| /// Allow use as an STL iterator | | /// Allow use as an STL iterator | |
| //@{ | | //@{ | |
| typedef std::bidirectional_iterator_tag iterator_category; // FIXME:
could enhance to be a randomaccess_iterator | | typedef std::bidirectional_iterator_tag iterator_category; // FIXME:
could enhance to be a randomaccess_iterator | |
| typedef Xapian::docid value_type; | | typedef Xapian::docid value_type; | |
| typedef Xapian::doccount_diff difference_type; | | typedef Xapian::doccount_diff difference_type; | |
| typedef Xapian::docid * pointer; | | typedef Xapian::docid * pointer; | |
| | | | |
| skipping to change at line 427 | | skipping to change at line 431 | |
| | | | |
| class ESetIterator; | | class ESetIterator; | |
| | | | |
| /** Class representing an ordered set of expand terms (an ESet). | | /** Class representing an ordered set of expand terms (an ESet). | |
| * This set represents the results of an expand operation, which is | | * This set represents the results of an expand operation, which is | |
| * performed by Xapian::Enquire::get_eset(). | | * performed by Xapian::Enquire::get_eset(). | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT ESet { | | class XAPIAN_VISIBILITY_DEFAULT ESet { | |
| public: | | public: | |
| class Internal; | | class Internal; | |
|
| /// @private @internal Reference counted internals. | | /// @internal Reference counted internals. | |
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
| /// Construct an empty ESet | | /// Construct an empty ESet | |
| ESet(); | | ESet(); | |
| | | | |
| /// Destructor. | | /// Destructor. | |
| ~ESet(); | | ~ESet(); | |
| | | | |
| /// Copying is allowed (and is cheap). | | /// Copying is allowed (and is cheap). | |
| ESet(const ESet & other); | | ESet(const ESet & other); | |
| | | | |
| | | | |
| skipping to change at line 540 | | skipping to change at line 544 | |
| ESetIterator operator--(int) { | | ESetIterator operator--(int) { | |
| ESetIterator tmp = *this; | | ESetIterator tmp = *this; | |
| --index; | | --index; | |
| return tmp; | | return tmp; | |
| } | | } | |
| | | | |
| /// Get the term for the current position | | /// Get the term for the current position | |
| const std::string & operator *() const; | | const std::string & operator *() const; | |
| | | | |
| /// Get the weight of the term at the current position | | /// Get the weight of the term at the current position | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| | | | |
| /// Return a string describing this object. | | /// Return a string describing this object. | |
| std::string get_description() const; | | std::string get_description() const; | |
| | | | |
| /// Allow use as an STL iterator | | /// Allow use as an STL iterator | |
| //@{ | | //@{ | |
| typedef std::bidirectional_iterator_tag iterator_category; // FIXME:
go for randomaccess_iterator! | | typedef std::bidirectional_iterator_tag iterator_category; // FIXME:
go for randomaccess_iterator! | |
| typedef std::string value_type; | | typedef std::string value_type; | |
| typedef Xapian::termcount_diff difference_type; | | typedef Xapian::termcount_diff difference_type; | |
| typedef std::string * pointer; | | typedef std::string * pointer; | |
| | | | |
| skipping to change at line 576 | | skipping to change at line 580 | |
| | | | |
| /** A relevance set (R-Set). | | /** A relevance set (R-Set). | |
| * This is the set of documents which are marked as relevant, for use | | * This is the set of documents which are marked as relevant, for use | |
| * in modifying the term weights, and in performing query expansion. | | * in modifying the term weights, and in performing query expansion. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT RSet { | | class XAPIAN_VISIBILITY_DEFAULT RSet { | |
| public: | | public: | |
| /// Class holding details of RSet | | /// Class holding details of RSet | |
| class Internal; | | class Internal; | |
| | | | |
|
| /// @private @internal Reference counted internals. | | /// @internal Reference counted internals. | |
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
| /// Copy constructor | | /// Copy constructor | |
| RSet(const RSet &rset); | | RSet(const RSet &rset); | |
| | | | |
| /// Assignment operator | | /// Assignment operator | |
| void operator=(const RSet &rset); | | void operator=(const RSet &rset); | |
| | | | |
| /// Default constructor | | /// Default constructor | |
| RSet(); | | RSet(); | |
| | | | |
| | | | |
| skipping to change at line 655 | | skipping to change at line 659 | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT Enquire { | | class XAPIAN_VISIBILITY_DEFAULT Enquire { | |
| public: | | public: | |
| /// Copying is allowed (and is cheap). | | /// Copying is allowed (and is cheap). | |
| Enquire(const Enquire & other); | | Enquire(const Enquire & other); | |
| | | | |
| /// Assignment is allowed (and is cheap). | | /// Assignment is allowed (and is cheap). | |
| void operator=(const Enquire & other); | | void operator=(const Enquire & other); | |
| | | | |
| class Internal; | | class Internal; | |
|
| /// @private @internal Reference counted internals. | | /// @internal Reference counted internals. | |
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
| /** Create a Xapian::Enquire object. | | /** Create a Xapian::Enquire object. | |
| * | | * | |
| * This specification cannot be changed once the Xapian::Enquire is | | * This specification cannot be changed once the Xapian::Enquire is | |
| * opened: you must create a new Xapian::Enquire object to access a | | * opened: you must create a new Xapian::Enquire object to access a | |
| * different database, or set of databases. | | * different database, or set of databases. | |
| * | | * | |
| * The database supplied must have been initialised (ie, must not b
e | | * The database supplied must have been initialised (ie, must not b
e | |
| * the result of calling the Database::Database() constructor). If | | * the result of calling the Database::Database() constructor). If | |
| * you need to handle a situation where you have no index gracefull
y, | | * you need to handle a situation where you have no index gracefull
y, | |
| | | | |
| skipping to change at line 823 | | skipping to change at line 827 | |
| * (default 0 => no percentage cut-off). | | * (default 0 => no percentage cut-off). | |
| * @param weight_cutoff Minimum weight for a document to be returned
. | | * @param weight_cutoff Minimum weight for a document to be returned
. | |
| * If a document has a lower score that this, it will not appea
r | | * If a document has a lower score that this, it will not appea
r | |
| * in the MSet. It is usually only possible to choose an | | * in the MSet. It is usually only possible to choose an | |
| * appropriate weight for cutoff based on the results of a | | * appropriate weight for cutoff based on the results of a | |
| * previous run of the same query; this is thus mainly useful f
or | | * previous run of the same query; this is thus mainly useful f
or | |
| * alerting operations. The other potential use is with a user | | * alerting operations. The other potential use is with a user | |
| * specified weighting scheme. | | * specified weighting scheme. | |
| * (default 0 => no weight cut-off). | | * (default 0 => no weight cut-off). | |
| */ | | */ | |
|
| void set_cutoff(Xapian::percent percent_cutoff, Xapian::weight weigh
t_cutoff = 0); | | void set_cutoff(int percent_cutoff, double weight_cutoff = 0); | |
| | | | |
| /** Set the sorting to be by relevance only. | | /** Set the sorting to be by relevance only. | |
| * | | * | |
| * This is the default. | | * This is the default. | |
| */ | | */ | |
| void set_sort_by_relevance(); | | void set_sort_by_relevance(); | |
| | | | |
| /** Set the sorting to be by value only. | | /** Set the sorting to be by value only. | |
| * | | * | |
| * Note that sorting by values uses a string comparison, so to use | | * Note that sorting by values uses a string comparison, so to use | |
| | | | |
| skipping to change at line 846 | | skipping to change at line 850 | |
| * could use Xapian::sortable_serialise() (which works for floating | | * could use Xapian::sortable_serialise() (which works for floating | |
| * point numbers as well as integers), or store numbers padded with | | * point numbers as well as integers), or store numbers padded with | |
| * leading zeros or spaces, or with the number of digits prepended. | | * leading zeros or spaces, or with the number of digits prepended. | |
| * | | * | |
| * @param sort_key value number to sort on. | | * @param sort_key value number to sort on. | |
| * | | * | |
| * @param reverse If true, reverses the sort order. | | * @param reverse If true, reverses the sort order. | |
| */ | | */ | |
| void set_sort_by_value(Xapian::valueno sort_key, bool reverse); | | void set_sort_by_value(Xapian::valueno sort_key, bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_value(Xapian::valueno sort_key)); | | | |
| | | | |
| /** Set the sorting to be by key generated from values only. | | /** Set the sorting to be by key generated from values only. | |
| * | | * | |
| * @param sorter The functor to use for generating keys. | | * @param sorter The functor to use for generating keys. | |
| * | | * | |
| * @param reverse If true, reverses the sort order. | | * @param reverse If true, reverses the sort order. | |
| */ | | */ | |
| void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse); | | void set_sort_by_key(Xapian::KeyMaker * sorter, bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_key(Xapian::KeyMaker * sorter)); | | | |
| | | | |
| /** Set the sorting to be by value, then by relevance for documents | | /** Set the sorting to be by value, then by relevance for documents | |
| * with the same value. | | * with the same value. | |
| * | | * | |
| * Note that sorting by values uses a string comparison, so to use | | * Note that sorting by values uses a string comparison, so to use | |
| * this to sort by a numeric value you'll need to store the numeric | | * this to sort by a numeric value you'll need to store the numeric | |
| * values in a manner which sorts appropriately. For example, you | | * values in a manner which sorts appropriately. For example, you | |
| * could use Xapian::sortable_serialise() (which works for floating | | * could use Xapian::sortable_serialise() (which works for floating | |
| * point numbers as well as integers), or store numbers padded with | | * point numbers as well as integers), or store numbers padded with | |
| * leading zeros or spaces, or with the number of digits prepended. | | * leading zeros or spaces, or with the number of digits prepended. | |
| * | | * | |
| * @param sort_key value number to sort on. | | * @param sort_key value number to sort on. | |
| * | | * | |
| * @param reverse If true, reverses the sort order. | | * @param reverse If true, reverses the sort order. | |
| */ | | */ | |
| void set_sort_by_value_then_relevance(Xapian::valueno sort_key, | | void set_sort_by_value_then_relevance(Xapian::valueno sort_key, | |
| bool reverse); | | bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_value_then_relevance(Xapian::valu | | | |
| eno sort_key)); | | | |
| | | | |
| /** Set the sorting to be by keys generated from values, then by | | /** Set the sorting to be by keys generated from values, then by | |
| * relevance for documents with identical keys. | | * relevance for documents with identical keys. | |
| * | | * | |
| * @param sorter The functor to use for generating keys. | | * @param sorter The functor to use for generating keys. | |
| * | | * | |
| * @param reverse If true, reverses the sort order. | | * @param reverse If true, reverses the sort order. | |
| */ | | */ | |
| void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter, | | void set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter, | |
| bool reverse); | | bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_key_then_relevance(Xapian::KeyMak | | | |
| er * sorter)); | | | |
| | | | |
| /** Set the sorting to be by relevance then value. | | /** Set the sorting to be by relevance then value. | |
| * | | * | |
| * Note that sorting by values uses a string comparison, so to use | | * Note that sorting by values uses a string comparison, so to use | |
| * this to sort by a numeric value you'll need to store the numeric | | * this to sort by a numeric value you'll need to store the numeric | |
| * values in a manner which sorts appropriately. For example, you | | * values in a manner which sorts appropriately. For example, you | |
| * could use Xapian::sortable_serialise() (which works for floating | | * could use Xapian::sortable_serialise() (which works for floating | |
| * point numbers as well as integers), or store numbers padded with | | * point numbers as well as integers), or store numbers padded with | |
| * leading zeros or spaces, or with the number of digits prepended. | | * leading zeros or spaces, or with the number of digits prepended. | |
| * | | * | |
| * Note that with the default BM25 weighting scheme parameters, | | * Note that with the default BM25 weighting scheme parameters, | |
| * non-identical documents will rarely have the same weight, so | | * non-identical documents will rarely have the same weight, so | |
| * this setting will give very similar results to | | * this setting will give very similar results to | |
| * set_sort_by_relevance(). It becomes more useful with particular | | * set_sort_by_relevance(). It becomes more useful with particular | |
| * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom | | * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom | |
| * weighting schemes. | | * weighting schemes. | |
| * | | * | |
| * @param sort_key value number to sort on. | | * @param sort_key value number to sort on. | |
| * | | * | |
|
| * @param reverse If true, reverses the sort order of sort_key. | | * @param reverse If true, reverses the sort order. | |
| * Beware that in 1.2.16 and earlier, the sense | | | |
| * of this parameter was incorrectly inverted | | | |
| * and inconsistent with the other set_sort_by_... | | | |
| * methods. This was fixed in 1.2.17, so make that | | | |
| * version a minimum requirement if this detail | | | |
| * matters to your application. | | | |
| */ | | */ | |
| void set_sort_by_relevance_then_value(Xapian::valueno sort_key, | | void set_sort_by_relevance_then_value(Xapian::valueno sort_key, | |
| bool reverse); | | bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_relevance_then_value(Xapian::valu | | | |
| eno sort_key)); | | | |
| | | | |
| /** Set the sorting to be by relevance, then by keys generated from | | /** Set the sorting to be by relevance, then by keys generated from | |
| * values. | | * values. | |
| * | | * | |
| * Note that with the default BM25 weighting scheme parameters, | | * Note that with the default BM25 weighting scheme parameters, | |
| * non-identical documents will rarely have the same weight, so | | * non-identical documents will rarely have the same weight, so | |
| * this setting will give very similar results to | | * this setting will give very similar results to | |
| * set_sort_by_relevance(). It becomes more useful with particular | | * set_sort_by_relevance(). It becomes more useful with particular | |
| * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom | | * BM25 parameter settings (e.g. BM25Weight(1,0,1,0,0)) or custom | |
| * weighting schemes. | | * weighting schemes. | |
| * | | * | |
| * @param sorter The functor to use for generating keys. | | * @param sorter The functor to use for generating keys. | |
| * | | * | |
|
| * @param reverse If true, reverses the sort order of the generate | | * @param reverse If true, reverses the sort order. | |
| d | | | |
| * keys. Beware that in 1.2.16 and earlier, the se | | | |
| nse | | | |
| * of this parameter was incorrectly inverted | | | |
| * and inconsistent with the other set_sort_by_... | | | |
| * methods. This was fixed in 1.2.17, so make that | | | |
| * version a minimum requirement if this detail | | | |
| * matters to your application. | | | |
| */ | | */ | |
| void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter, | | void set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter, | |
| bool reverse); | | bool reverse); | |
| | | | |
|
| XAPIAN_DEPRECATED(void set_sort_by_relevance_then_key(Xapian::KeyMak | | | |
| er * sorter)); | | | |
| | | | |
| /** Get (a portion of) the match set for the current query. | | /** Get (a portion of) the match set for the current query. | |
| * | | * | |
| * @param first the first item in the result set to return. | | * @param first the first item in the result set to return. | |
| * A value of zero corresponds to the first item | | * A value of zero corresponds to the first item | |
| * returned being that with the highest score. | | * returned being that with the highest score. | |
| * A value of 10 corresponds to the first 10 items | | * A value of 10 corresponds to the first 10 items | |
| * being ignored, and the returned items starting | | * being ignored, and the returned items starting | |
| * at the eleventh. | | * at the eleventh. | |
| * @param maxitems the maximum number of items to return. If you | | * @param maxitems the maximum number of items to return. If you | |
| * want all matches, then you can pass the result | | * want all matches, then you can pass the result | |
| | | | |
| skipping to change at line 975 | | skipping to change at line 955 | |
| * looser. | | * looser. | |
| * @param checkatleast the minimum number of items to check. Beca
use | | * @param checkatleast the minimum number of items to check. Beca
use | |
| * the matcher optimises, it won't consider every | | * the matcher optimises, it won't consider every | |
| * document which might match, so the total number | | * document which might match, so the total number | |
| * of matches is estimated. Setting checkatleast | | * of matches is estimated. Setting checkatleast | |
| * forces it to consider at least this many matche
s | | * forces it to consider at least this many matche
s | |
| * and so allows for reliable paging links. | | * and so allows for reliable paging links. | |
| * @param omrset the relevance set to use when performing the qu
ery. | | * @param omrset the relevance set to use when performing the qu
ery. | |
| * @param mdecider a decision functor to use to decide whether a | | * @param mdecider a decision functor to use to decide whether a | |
| * given document should be put in the MSet. | | * given document should be put in the MSet. | |
|
| * @param matchspy a decision functor to use to decide whether a | | | |
| * given document should be put in the MSet. The | | | |
| * matchspy is applied to every document which is | | | |
| * a potential candidate for the MSet, so if there | | | |
| are | | | |
| * checkatleast or more such documents, the matchs | | | |
| py | | | |
| * will see at least checkatleast. The mdecider i | | | |
| s | | | |
| * assumed to be a relatively expensive test so ma | | | |
| y | | | |
| * be applied in a lazier fashion. | | | |
| * | | | |
| * @deprecated The matchspy parameter is deprecated - use the | | | |
| * newer MatchSpy class and add_matchspy() method | | | |
| * instead. | | | |
| * | | * | |
|
| * @return A Xapian::MSet object containing the results of
the | | * @return A Xapian::MSet object containing the results of
the | |
| * query. | | * query. | |
| * | | * | |
| * @exception Xapian::InvalidArgumentError See class documentation
. | | * @exception Xapian::InvalidArgumentError See class documentation
. | |
| * | | * | |
| * @{ | | * @{ | |
| */ | | */ | |
|
| XAPIAN_DEPRECATED( | | | |
| MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, | | | |
| Xapian::doccount checkatleast, | | | |
| const RSet * omrset, | | | |
| const MatchDecider * mdecider, | | | |
| const MatchDecider * matchspy) const); | | | |
| MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, | | MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, | |
| Xapian::doccount checkatleast = 0, | | Xapian::doccount checkatleast = 0, | |
| const RSet * omrset = 0, | | const RSet * omrset = 0, | |
| const MatchDecider * mdecider = 0) const; | | const MatchDecider * mdecider = 0) const; | |
| MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, | | MSet get_mset(Xapian::doccount first, Xapian::doccount maxitems, | |
| const RSet * omrset, | | const RSet * omrset, | |
| const MatchDecider * mdecider = 0) const { | | const MatchDecider * mdecider = 0) const { | |
| return get_mset(first, maxitems, 0, omrset, mdecider); | | return get_mset(first, maxitems, 0, omrset, mdecider); | |
| } | | } | |
| /** @} */ | | /** @} */ | |
| | | | |
| skipping to change at line 1090 | | skipping to change at line 1052 | |
| * @return An ESet object containing the results of the | | * @return An ESet object containing the results of the | |
| * expand. | | * expand. | |
| * | | * | |
| * @exception Xapian::InvalidArgumentError See class documentation
. | | * @exception Xapian::InvalidArgumentError See class documentation
. | |
| */ | | */ | |
| ESet get_eset(Xapian::termcount maxitems, | | ESet get_eset(Xapian::termcount maxitems, | |
| const RSet & omrset, | | const RSet & omrset, | |
| int flags, | | int flags, | |
| double k, | | double k, | |
| const Xapian::ExpandDecider * edecider, | | const Xapian::ExpandDecider * edecider, | |
|
| Xapian::weight min_wt) const; | | double min_wt) const; | |
| | | | |
| /** Get terms which match a given document, by document id. | | /** Get terms which match a given document, by document id. | |
| * | | * | |
| * This method returns the terms in the current query which match | | * This method returns the terms in the current query which match | |
| * the given document. | | * the given document. | |
| * | | * | |
| * It is possible for the document to have been removed from the | | * It is possible for the document to have been removed from the | |
| * database between the time it is returned in an MSet, and the | | * database between the time it is returned in an MSet, and the | |
| * time that this call is made. If possible, you should specify | | * time that this call is made. If possible, you should specify | |
| * an MSetIterator instead of a Xapian::docid, since this will enab
le | | * an MSetIterator instead of a Xapian::docid, since this will enab
le | |
| | | | |
| skipping to change at line 1160 | | skipping to change at line 1122 | |
| | | | |
| /** End iterator corresponding to get_matching_terms_begin() */ | | /** End iterator corresponding to get_matching_terms_begin() */ | |
| TermIterator get_matching_terms_end(const MSetIterator &/*it*/) cons
t { | | TermIterator get_matching_terms_end(const MSetIterator &/*it*/) cons
t { | |
| return TermIterator(); | | return TermIterator(); | |
| } | | } | |
| | | | |
| /// Return a string describing this object. | | /// Return a string describing this object. | |
| std::string get_description() const; | | std::string get_description() const; | |
| }; | | }; | |
| | | | |
|
| // Deprecated forms: | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_value(Xapian::valueno sort_key) | | | |
| { | | | |
| return set_sort_by_value(sort_key, true); | | | |
| } | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_key(Xapian::KeyMaker * sorter) | | | |
| { | | | |
| return set_sort_by_key(sorter, true); | | | |
| } | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_value_then_relevance(Xapian::valueno sort_key) | | | |
| { | | | |
| return set_sort_by_value_then_relevance(sort_key, true); | | | |
| } | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_key_then_relevance(Xapian::KeyMaker * sorter) | | | |
| { | | | |
| return set_sort_by_key_then_relevance(sorter, true); | | | |
| } | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_relevance_then_value(Xapian::valueno sort_key) | | | |
| { | | | |
| return set_sort_by_relevance_then_value(sort_key, true); | | | |
| } | | | |
| | | | |
| inline void | | | |
| Enquire::set_sort_by_relevance_then_key(Xapian::KeyMaker * sorter) | | | |
| { | | | |
| return set_sort_by_relevance_then_key(sorter, true); | | | |
| } | | | |
| | | | |
| } | | } | |
| | | | |
| #endif /* XAPIAN_INCLUDED_ENQUIRE_H */ | | #endif /* XAPIAN_INCLUDED_ENQUIRE_H */ | |
| | | | |
End of changes. 31 change blocks. |
| 118 lines changed or deleted | | 32 lines changed or added | |
|
| error.h | | error.h | |
| /** @file error.h | | /** @file error.h | |
| * @brief Hierarchy of classes which Xapian can throw as exceptions. | | * @brief Hierarchy of classes which Xapian can throw as exceptions. | |
| */ | | */ | |
|
| /* Warning: This file is generated by /data/home/olly/tmp/xapian-git-snapsh | | /* Warning: This file is generated by /data/home/olly/tmp/xapian-svn-snapsh | |
| ot/tags/v1.2.21/xapian/xapian-core/generate-exceptions - do not modify dire | | ot/tags/1.3.0/xapian/xapian-core/generate-exceptions - do not modify direct | |
| ctly! */ | | ly! */ | |
| /* Copyright (C) 2003,2004,2006,2007,2009 Olly Betts | | /* Copyright (C) 2003,2004,2006,2007,2008,2009,2011 Olly Betts | |
| | | * Copyright (C) 2007 Richard Boulton | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| * License, or (at your option) any later version. | | * License, or (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | | * GNU General Public License for more details. | |
| | | | |
| skipping to change at line 53 | | skipping to change at line 54 | |
| | | | |
| /** Optional context information. | | /** Optional context information. | |
| * | | * | |
| * This context is intended for use by Xapian::ErrorHandler (for examp
le | | * This context is intended for use by Xapian::ErrorHandler (for examp
le | |
| * so it can know which remote server is unreliable and report the pro
blem | | * so it can know which remote server is unreliable and report the pro
blem | |
| * and remove that server from those being searched). But it's typica
lly | | * and remove that server from those being searched). But it's typica
lly | |
| * a plain-text string, and so also fit for human consumption. | | * a plain-text string, and so also fit for human consumption. | |
| */ | | */ | |
| std::string context; | | std::string context; | |
| | | | |
|
| | | /** The error string derived from my_errno. | |
| | | * | |
| | | * This string is generated from my_errno lazily. | |
| | | */ | |
| | | mutable std::string error_string; | |
| | | | |
| /// The type of this error (e.g. DocNotFoundError.) | | /// The type of this error (e.g. DocNotFoundError.) | |
| const char * type; | | const char * type; | |
| | | | |
| /** Optional value of 'errno' associated with this error. | | /** Optional value of 'errno' associated with this error. | |
| * | | * | |
| * If no value is associated, this member variable will be 0. | | * If no value is associated, this member variable will be 0. | |
| * | | * | |
| * On UNIX, if this value is < 0, it's a negated h_errno value (giving | | * On UNIX, if this value is < 0, it's a negated h_errno value (giving | |
| * an error from gethostbyname() or similar). | | * an error from gethostbyname() or similar). | |
| * | | * | |
| * On Windows, if this value is < 0, it's a negated Windows error code | | * On Windows, if this value is < 0, it's a negated Windows error code | |
|
| * (as given by GetLastError()), while if it is >= WSABASEERR then it | | * (as given by GetLastError() or WSAGetLastError()). | |
| is a | | | |
| * WinSock error code (as given by WSAGetLastError()). Prior to Xapia | | | |
| n | | | |
| * 1.2.20 and 1.3.3, WSAGetLastError() codes were also negated. | | | |
| * | | * | |
| * NB We don't just call this member "errno" to avoid problems on | | * NB We don't just call this member "errno" to avoid problems on | |
| * platforms where errno is a preprocessor macro. | | * platforms where errno is a preprocessor macro. | |
| */ | | */ | |
| int my_errno; | | int my_errno; | |
| | | | |
|
| /** The error string derived from my_errno. | | | |
| * | | | |
| * This string is generated from my_errno lazily. | | | |
| */ | | | |
| mutable std::string error_string; | | | |
| | | | |
| /// True if this error has already been passed to an ErrorHandler. | | /// True if this error has already been passed to an ErrorHandler. | |
| bool already_handled; | | bool already_handled; | |
| | | | |
| /// Don't allow assignment of the base class. | | /// Don't allow assignment of the base class. | |
| void operator=(const Error &o); | | void operator=(const Error &o); | |
| | | | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| Error(const std::string &msg_, const std::string &context_, | | Error(const std::string &msg_, const std::string &context_, | |
| const char * type_, const char * error_string_); | | const char * type_, const char * error_string_); | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| Error(const std::string &msg_, const std::string &context_, | | Error(const std::string &msg_, const std::string &context_, | |
| const char * type_, int errno_) | | const char * type_, int errno_) | |
|
| : msg(msg_), context(context_), type(type_), my_errno(errno_), | | : msg(msg_), context(context_), error_string(), type(type_), | |
| error_string(), already_handled(false) { } | | my_errno(errno_), already_handled(false) { } | |
| | | | |
| public: | | public: | |
| /// The type of this error (e.g. "DocNotFoundError".) | | /// The type of this error (e.g. "DocNotFoundError".) | |
|
| const char * get_type() const { return type; } | | const char * get_type() const { return type + 1; } | |
| | | | |
| /// Message giving details of the error, intended for human consumption
. | | /// Message giving details of the error, intended for human consumption
. | |
| const std::string & get_msg() const { return msg; } | | const std::string & get_msg() const { return msg; } | |
| | | | |
| /** Optional context information. | | /** Optional context information. | |
| * | | * | |
| * This context is intended for use by Xapian::ErrorHandler (for examp
le | | * This context is intended for use by Xapian::ErrorHandler (for examp
le | |
| * so it can know which remote server is unreliable and report the pro
blem | | * so it can know which remote server is unreliable and report the pro
blem | |
| * and remove that server from those being searched). But it's typica
lly | | * and remove that server from those being searched). But it's typica
lly | |
| * a plain-text string, and so also fit for human consumption. | | * a plain-text string, and so also fit for human consumption. | |
| | | | |
| skipping to change at line 186 | | skipping to change at line 185 | |
| * has been violated, or the assertion is incorrect!) | | * has been violated, or the assertion is incorrect!) | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError { | | class XAPIAN_VISIBILITY_DEFAULT AssertionError : public LogicError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| AssertionError(const std::string &msg_, const std::string &context_, co
nst char * error_string_) | | AssertionError(const std::string &msg_, const std::string &context_, co
nst char * error_string_) | |
|
| : LogicError(msg_, context_, "AssertionError", error_string_) {} | | : LogicError(msg_, context_, "\000AssertionError", error_string_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit AssertionError(const std::string &msg_, const std::string &con
text_ = std::string(), int errno_ = 0) | | explicit AssertionError(const std::string &msg_, const std::string &con
text_ = std::string(), int errno_ = 0) | |
|
| : LogicError(msg_, context_, "AssertionError", errno_) {} | | : LogicError(msg_, context_, "\000AssertionError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| AssertionError(const std::string &msg_, int errno_) | | AssertionError(const std::string &msg_, int errno_) | |
|
| : LogicError(msg_, std::string(), "AssertionError", errno_) {} | | : LogicError(msg_, std::string(), "\000AssertionError", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| AssertionError(const std::string &msg_, const std::string &context_, co
nst char * type_, const char * error_string_) | | AssertionError(const std::string &msg_, const std::string &context_, co
nst char * type_, const char * error_string_) | |
| : LogicError(msg_, context_, type_, error_string_) {} | | : LogicError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 228 | | skipping to change at line 227 | |
| /** InvalidArgumentError indicates an invalid parameter value was passed to
the API. | | /** InvalidArgumentError indicates an invalid parameter value was passed to
the API. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError { | | class XAPIAN_VISIBILITY_DEFAULT InvalidArgumentError : public LogicError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| InvalidArgumentError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | | InvalidArgumentError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | |
|
| : LogicError(msg_, context_, "InvalidArgumentError", error_string_)
{} | | : LogicError(msg_, context_, "\001InvalidArgumentError", error_strin
g_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit InvalidArgumentError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | | explicit InvalidArgumentError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | |
|
| : LogicError(msg_, context_, "InvalidArgumentError", errno_) {} | | : LogicError(msg_, context_, "\001InvalidArgumentError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| InvalidArgumentError(const std::string &msg_, int errno_) | | InvalidArgumentError(const std::string &msg_, int errno_) | |
|
| : LogicError(msg_, std::string(), "InvalidArgumentError", errno_) {} | | : LogicError(msg_, std::string(), "\001InvalidArgumentError", errno_
) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| InvalidArgumentError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | | InvalidArgumentError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | |
| : LogicError(msg_, context_, type_, error_string_) {} | | : LogicError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 270 | | skipping to change at line 269 | |
| /** InvalidOperationError indicates the API was used in an invalid way. | | /** InvalidOperationError indicates the API was used in an invalid way. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError { | | class XAPIAN_VISIBILITY_DEFAULT InvalidOperationError : public LogicError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| InvalidOperationError(const std::string &msg_, const std::string &conte
xt_, const char * error_string_) | | InvalidOperationError(const std::string &msg_, const std::string &conte
xt_, const char * error_string_) | |
|
| : LogicError(msg_, context_, "InvalidOperationError", error_string_)
{} | | : LogicError(msg_, context_, "\002InvalidOperationError", error_stri
ng_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit InvalidOperationError(const std::string &msg_, const std::stri
ng &context_ = std::string(), int errno_ = 0) | | explicit InvalidOperationError(const std::string &msg_, const std::stri
ng &context_ = std::string(), int errno_ = 0) | |
|
| : LogicError(msg_, context_, "InvalidOperationError", errno_) {} | | : LogicError(msg_, context_, "\002InvalidOperationError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| InvalidOperationError(const std::string &msg_, int errno_) | | InvalidOperationError(const std::string &msg_, int errno_) | |
|
| : LogicError(msg_, std::string(), "InvalidOperationError", errno_) {
} | | : LogicError(msg_, std::string(), "\002InvalidOperationError", errno
_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| InvalidOperationError(const std::string &msg_, const std::string &conte
xt_, const char * type_, const char * error_string_) | | InvalidOperationError(const std::string &msg_, const std::string &conte
xt_, const char * type_, const char * error_string_) | |
| : LogicError(msg_, context_, type_, error_string_) {} | | : LogicError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 311 | | skipping to change at line 310 | |
| | | | |
| /** UnimplementedError indicates an attempt to use an unimplemented feature
. */ | | /** UnimplementedError indicates an attempt to use an unimplemented feature
. */ | |
| class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError { | | class XAPIAN_VISIBILITY_DEFAULT UnimplementedError : public LogicError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| UnimplementedError(const std::string &msg_, const std::string &context_
, const char * error_string_) | | UnimplementedError(const std::string &msg_, const std::string &context_
, const char * error_string_) | |
|
| : LogicError(msg_, context_, "UnimplementedError", error_string_) {} | | : LogicError(msg_, context_, "\003UnimplementedError", error_string_
) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit UnimplementedError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | | explicit UnimplementedError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | |
|
| : LogicError(msg_, context_, "UnimplementedError", errno_) {} | | : LogicError(msg_, context_, "\003UnimplementedError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| UnimplementedError(const std::string &msg_, int errno_) | | UnimplementedError(const std::string &msg_, int errno_) | |
|
| : LogicError(msg_, std::string(), "UnimplementedError", errno_) {} | | : LogicError(msg_, std::string(), "\003UnimplementedError", errno_)
{} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| UnimplementedError(const std::string &msg_, const std::string &context_
, const char * type_, const char * error_string_) | | UnimplementedError(const std::string &msg_, const std::string &context_
, const char * type_, const char * error_string_) | |
| : LogicError(msg_, context_, type_, error_string_) {} | | : LogicError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 352 | | skipping to change at line 351 | |
| | | | |
| /** DatabaseError indicates some sort of database related error. */ | | /** DatabaseError indicates some sort of database related error. */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT DatabaseError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseError(const std::string &msg_, const std::string &context_, con
st char * error_string_) | | DatabaseError(const std::string &msg_, const std::string &context_, con
st char * error_string_) | |
|
| : RuntimeError(msg_, context_, "DatabaseError", error_string_) {} | | : RuntimeError(msg_, context_, "\004DatabaseError", error_string_) {
} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseError(const std::string &msg_, const std::string &cont
ext_ = std::string(), int errno_ = 0) | | explicit DatabaseError(const std::string &msg_, const std::string &cont
ext_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "DatabaseError", errno_) {} | | : RuntimeError(msg_, context_, "\004DatabaseError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseError(const std::string &msg_, int errno_) | | DatabaseError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "DatabaseError", errno_) {} | | : RuntimeError(msg_, std::string(), "\004DatabaseError", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseError(const std::string &msg_, const std::string &context_, con
st char * type_, const char * error_string_) | | DatabaseError(const std::string &msg_, const std::string &context_, con
st char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 393 | | skipping to change at line 392 | |
| | | | |
| /** DatabaseCorruptError indicates database corruption was detected. */ | | /** DatabaseCorruptError indicates database corruption was detected. */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError
{ | | class XAPIAN_VISIBILITY_DEFAULT DatabaseCorruptError : public DatabaseError
{ | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseCorruptError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | | DatabaseCorruptError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | |
|
| : DatabaseError(msg_, context_, "DatabaseCorruptError", error_string
_) {} | | : DatabaseError(msg_, context_, "\005DatabaseCorruptError", error_st
ring_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseCorruptError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | | explicit DatabaseCorruptError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseError(msg_, context_, "DatabaseCorruptError", errno_) {} | | : DatabaseError(msg_, context_, "\005DatabaseCorruptError", errno_)
{} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseCorruptError(const std::string &msg_, int errno_) | | DatabaseCorruptError(const std::string &msg_, int errno_) | |
|
| : DatabaseError(msg_, std::string(), "DatabaseCorruptError", errno_)
{} | | : DatabaseError(msg_, std::string(), "\005DatabaseCorruptError", err
no_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseCorruptError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | | DatabaseCorruptError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | |
| : DatabaseError(msg_, context_, type_, error_string_) {} | | : DatabaseError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 434 | | skipping to change at line 433 | |
| | | | |
| /** DatabaseCreateError indicates a failure to create a database. */ | | /** DatabaseCreateError indicates a failure to create a database. */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError
{ | | class XAPIAN_VISIBILITY_DEFAULT DatabaseCreateError : public DatabaseError
{ | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseCreateError(const std::string &msg_, const std::string &context
_, const char * error_string_) | | DatabaseCreateError(const std::string &msg_, const std::string &context
_, const char * error_string_) | |
|
| : DatabaseError(msg_, context_, "DatabaseCreateError", error_string_
) {} | | : DatabaseError(msg_, context_, "\006DatabaseCreateError", error_str
ing_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseCreateError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | | explicit DatabaseCreateError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseError(msg_, context_, "DatabaseCreateError", errno_) {} | | : DatabaseError(msg_, context_, "\006DatabaseCreateError", errno_) {
} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseCreateError(const std::string &msg_, int errno_) | | DatabaseCreateError(const std::string &msg_, int errno_) | |
|
| : DatabaseError(msg_, std::string(), "DatabaseCreateError", errno_)
{} | | : DatabaseError(msg_, std::string(), "\006DatabaseCreateError", errn
o_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseCreateError(const std::string &msg_, const std::string &context
_, const char * type_, const char * error_string_) | | DatabaseCreateError(const std::string &msg_, const std::string &context
_, const char * type_, const char * error_string_) | |
| : DatabaseError(msg_, context_, type_, error_string_) {} | | : DatabaseError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 475 | | skipping to change at line 474 | |
| | | | |
| /** DatabaseLockError indicates failure to lock a database. */ | | /** DatabaseLockError indicates failure to lock a database. */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError { | | class XAPIAN_VISIBILITY_DEFAULT DatabaseLockError : public DatabaseError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseLockError(const std::string &msg_, const std::string &context_,
const char * error_string_) | | DatabaseLockError(const std::string &msg_, const std::string &context_,
const char * error_string_) | |
|
| : DatabaseError(msg_, context_, "DatabaseLockError", error_string_)
{} | | : DatabaseError(msg_, context_, "\007DatabaseLockError", error_strin
g_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseLockError(const std::string &msg_, const std::string &
context_ = std::string(), int errno_ = 0) | | explicit DatabaseLockError(const std::string &msg_, const std::string &
context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseError(msg_, context_, "DatabaseLockError", errno_) {} | | : DatabaseError(msg_, context_, "\007DatabaseLockError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseLockError(const std::string &msg_, int errno_) | | DatabaseLockError(const std::string &msg_, int errno_) | |
|
| : DatabaseError(msg_, std::string(), "DatabaseLockError", errno_) {} | | : DatabaseError(msg_, std::string(), "\007DatabaseLockError", errno_
) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseLockError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | | DatabaseLockError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | |
| : DatabaseError(msg_, context_, type_, error_string_) {} | | : DatabaseError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 521 | | skipping to change at line 520 | |
| * which failed. | | * which failed. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseErro
r { | | class XAPIAN_VISIBILITY_DEFAULT DatabaseModifiedError : public DatabaseErro
r { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseModifiedError(const std::string &msg_, const std::string &conte
xt_, const char * error_string_) | | DatabaseModifiedError(const std::string &msg_, const std::string &conte
xt_, const char * error_string_) | |
|
| : DatabaseError(msg_, context_, "DatabaseModifiedError", error_strin
g_) {} | | : DatabaseError(msg_, context_, "\010DatabaseModifiedError", error_s
tring_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseModifiedError(const std::string &msg_, const std::stri
ng &context_ = std::string(), int errno_ = 0) | | explicit DatabaseModifiedError(const std::string &msg_, const std::stri
ng &context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseError(msg_, context_, "DatabaseModifiedError", errno_) {} | | : DatabaseError(msg_, context_, "\010DatabaseModifiedError", errno_)
{} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseModifiedError(const std::string &msg_, int errno_) | | DatabaseModifiedError(const std::string &msg_, int errno_) | |
|
| : DatabaseError(msg_, std::string(), "DatabaseModifiedError", errno_
) {} | | : DatabaseError(msg_, std::string(), "\010DatabaseModifiedError", er
rno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseModifiedError(const std::string &msg_, const std::string &conte
xt_, const char * type_, const char * error_string_) | | DatabaseModifiedError(const std::string &msg_, const std::string &conte
xt_, const char * type_, const char * error_string_) | |
| : DatabaseError(msg_, context_, type_, error_string_) {} | | : DatabaseError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 562 | | skipping to change at line 561 | |
| | | | |
| /** DatabaseOpeningError indicates failure to open a database. */ | | /** DatabaseOpeningError indicates failure to open a database. */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError
{ | | class XAPIAN_VISIBILITY_DEFAULT DatabaseOpeningError : public DatabaseError
{ | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseOpeningError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | | DatabaseOpeningError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | |
|
| : DatabaseError(msg_, context_, "DatabaseOpeningError", error_string
_) {} | | : DatabaseError(msg_, context_, "\011DatabaseOpeningError", error_st
ring_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseOpeningError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | | explicit DatabaseOpeningError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseError(msg_, context_, "DatabaseOpeningError", errno_) {} | | : DatabaseError(msg_, context_, "\011DatabaseOpeningError", errno_)
{} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseOpeningError(const std::string &msg_, int errno_) | | DatabaseOpeningError(const std::string &msg_, int errno_) | |
|
| : DatabaseError(msg_, std::string(), "DatabaseOpeningError", errno_)
{} | | : DatabaseError(msg_, std::string(), "\011DatabaseOpeningError", err
no_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseOpeningError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | | DatabaseOpeningError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | |
| : DatabaseError(msg_, context_, type_, error_string_) {} | | : DatabaseError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 613 | | skipping to change at line 612 | |
| * the current version of Xapian. | | * the current version of Xapian. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeni
ngError { | | class XAPIAN_VISIBILITY_DEFAULT DatabaseVersionError : public DatabaseOpeni
ngError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DatabaseVersionError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | | DatabaseVersionError(const std::string &msg_, const std::string &contex
t_, const char * error_string_) | |
|
| : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", error
_string_) {} | | : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", e
rror_string_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DatabaseVersionError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | | explicit DatabaseVersionError(const std::string &msg_, const std::strin
g &context_ = std::string(), int errno_ = 0) | |
|
| : DatabaseOpeningError(msg_, context_, "DatabaseVersionError", errno
_) {} | | : DatabaseOpeningError(msg_, context_, "\012DatabaseVersionError", e
rrno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DatabaseVersionError(const std::string &msg_, int errno_) | | DatabaseVersionError(const std::string &msg_, int errno_) | |
|
| : DatabaseOpeningError(msg_, std::string(), "DatabaseVersionError",
errno_) {} | | : DatabaseOpeningError(msg_, std::string(), "\012DatabaseVersionErro
r", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DatabaseVersionError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | | DatabaseVersionError(const std::string &msg_, const std::string &contex
t_, const char * type_, const char * error_string_) | |
| : DatabaseOpeningError(msg_, context_, type_, error_string_) {} | | : DatabaseOpeningError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 654 | | skipping to change at line 653 | |
| | | | |
| /** Indicates an attempt to access a document not present in the database.
*/ | | /** Indicates an attempt to access a document not present in the database.
*/ | |
| class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT DocNotFoundError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| DocNotFoundError(const std::string &msg_, const std::string &context_,
const char * error_string_) | | DocNotFoundError(const std::string &msg_, const std::string &context_,
const char * error_string_) | |
|
| : RuntimeError(msg_, context_, "DocNotFoundError", error_string_) {} | | : RuntimeError(msg_, context_, "\013DocNotFoundError", error_string_
) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit DocNotFoundError(const std::string &msg_, const std::string &c
ontext_ = std::string(), int errno_ = 0) | | explicit DocNotFoundError(const std::string &msg_, const std::string &c
ontext_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "DocNotFoundError", errno_) {} | | : RuntimeError(msg_, context_, "\013DocNotFoundError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| DocNotFoundError(const std::string &msg_, int errno_) | | DocNotFoundError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "DocNotFoundError", errno_) {} | | : RuntimeError(msg_, std::string(), "\013DocNotFoundError", errno_)
{} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| DocNotFoundError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | | DocNotFoundError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 699 | | skipping to change at line 698 | |
| * because it requires other software or facilities which aren't available
. | | * because it requires other software or facilities which aren't available
. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeErr
or { | | class XAPIAN_VISIBILITY_DEFAULT FeatureUnavailableError : public RuntimeErr
or { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| FeatureUnavailableError(const std::string &msg_, const std::string &con
text_, const char * error_string_) | | FeatureUnavailableError(const std::string &msg_, const std::string &con
text_, const char * error_string_) | |
|
| : RuntimeError(msg_, context_, "FeatureUnavailableError", error_stri
ng_) {} | | : RuntimeError(msg_, context_, "\014FeatureUnavailableError", error_
string_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit FeatureUnavailableError(const std::string &msg_, const std::st
ring &context_ = std::string(), int errno_ = 0) | | explicit FeatureUnavailableError(const std::string &msg_, const std::st
ring &context_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "FeatureUnavailableError", errno_) {} | | : RuntimeError(msg_, context_, "\014FeatureUnavailableError", errno_
) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| FeatureUnavailableError(const std::string &msg_, int errno_) | | FeatureUnavailableError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "FeatureUnavailableError", errno
_) {} | | : RuntimeError(msg_, std::string(), "\014FeatureUnavailableError", e
rrno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| FeatureUnavailableError(const std::string &msg_, const std::string &con
text_, const char * type_, const char * error_string_) | | FeatureUnavailableError(const std::string &msg_, const std::string &con
text_, const char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 740 | | skipping to change at line 739 | |
| | | | |
| /** InternalError indicates a runtime problem of some sort. */ | | /** InternalError indicates a runtime problem of some sort. */ | |
| class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT InternalError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| InternalError(const std::string &msg_, const std::string &context_, con
st char * error_string_) | | InternalError(const std::string &msg_, const std::string &context_, con
st char * error_string_) | |
|
| : RuntimeError(msg_, context_, "InternalError", error_string_) {} | | : RuntimeError(msg_, context_, "\015InternalError", error_string_) {
} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit InternalError(const std::string &msg_, const std::string &cont
ext_ = std::string(), int errno_ = 0) | | explicit InternalError(const std::string &msg_, const std::string &cont
ext_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "InternalError", errno_) {} | | : RuntimeError(msg_, context_, "\015InternalError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| InternalError(const std::string &msg_, int errno_) | | InternalError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "InternalError", errno_) {} | | : RuntimeError(msg_, std::string(), "\015InternalError", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| InternalError(const std::string &msg_, const std::string &context_, con
st char * type_, const char * error_string_) | | InternalError(const std::string &msg_, const std::string &context_, con
st char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 781 | | skipping to change at line 780 | |
| | | | |
| /** Indicates a problem communicating with a remote database. */ | | /** Indicates a problem communicating with a remote database. */ | |
| class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT NetworkError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| NetworkError(const std::string &msg_, const std::string &context_, cons
t char * error_string_) | | NetworkError(const std::string &msg_, const std::string &context_, cons
t char * error_string_) | |
|
| : RuntimeError(msg_, context_, "NetworkError", error_string_) {} | | : RuntimeError(msg_, context_, "\016NetworkError", error_string_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit NetworkError(const std::string &msg_, const std::string &conte
xt_ = std::string(), int errno_ = 0) | | explicit NetworkError(const std::string &msg_, const std::string &conte
xt_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "NetworkError", errno_) {} | | : RuntimeError(msg_, context_, "\016NetworkError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| NetworkError(const std::string &msg_, int errno_) | | NetworkError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "NetworkError", errno_) {} | | : RuntimeError(msg_, std::string(), "\016NetworkError", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| NetworkError(const std::string &msg_, const std::string &context_, cons
t char * type_, const char * error_string_) | | NetworkError(const std::string &msg_, const std::string &context_, cons
t char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 822 | | skipping to change at line 821 | |
| | | | |
| /** Indicates a timeout expired while communicating with a remote database.
*/ | | /** Indicates a timeout expired while communicating with a remote database.
*/ | |
| class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError { | | class XAPIAN_VISIBILITY_DEFAULT NetworkTimeoutError : public NetworkError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| NetworkTimeoutError(const std::string &msg_, const std::string &context
_, const char * error_string_) | | NetworkTimeoutError(const std::string &msg_, const std::string &context
_, const char * error_string_) | |
|
| : NetworkError(msg_, context_, "NetworkTimeoutError", error_string_)
{} | | : NetworkError(msg_, context_, "\017NetworkTimeoutError", error_stri
ng_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit NetworkTimeoutError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | | explicit NetworkTimeoutError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | |
|
| : NetworkError(msg_, context_, "NetworkTimeoutError", errno_) {} | | : NetworkError(msg_, context_, "\017NetworkTimeoutError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| NetworkTimeoutError(const std::string &msg_, int errno_) | | NetworkTimeoutError(const std::string &msg_, int errno_) | |
|
| : NetworkError(msg_, std::string(), "NetworkTimeoutError", errno_) {
} | | : NetworkError(msg_, std::string(), "\017NetworkTimeoutError", errno
_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| NetworkTimeoutError(const std::string &msg_, const std::string &context
_, const char * type_, const char * error_string_) | | NetworkTimeoutError(const std::string &msg_, const std::string &context
_, const char * type_, const char * error_string_) | |
| : NetworkError(msg_, context_, type_, error_string_) {} | | : NetworkError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 863 | | skipping to change at line 862 | |
| | | | |
| /** Indicates a query string can't be parsed. */ | | /** Indicates a query string can't be parsed. */ | |
| class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT QueryParserError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| QueryParserError(const std::string &msg_, const std::string &context_,
const char * error_string_) | | QueryParserError(const std::string &msg_, const std::string &context_,
const char * error_string_) | |
|
| : RuntimeError(msg_, context_, "QueryParserError", error_string_) {} | | : RuntimeError(msg_, context_, "\020QueryParserError", error_string_
) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit QueryParserError(const std::string &msg_, const std::string &c
ontext_ = std::string(), int errno_ = 0) | | explicit QueryParserError(const std::string &msg_, const std::string &c
ontext_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "QueryParserError", errno_) {} | | : RuntimeError(msg_, context_, "\020QueryParserError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| QueryParserError(const std::string &msg_, int errno_) | | QueryParserError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "QueryParserError", errno_) {} | | : RuntimeError(msg_, std::string(), "\020QueryParserError", errno_)
{} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| QueryParserError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | | QueryParserError(const std::string &msg_, const std::string &context_,
const char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 904 | | skipping to change at line 903 | |
| | | | |
| /** Indicates an error in the std::string serialisation of an object. */ | | /** Indicates an error in the std::string serialisation of an object. */ | |
| class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT SerialisationError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| SerialisationError(const std::string &msg_, const std::string &context_
, const char * error_string_) | | SerialisationError(const std::string &msg_, const std::string &context_
, const char * error_string_) | |
|
| : RuntimeError(msg_, context_, "SerialisationError", error_string_)
{} | | : RuntimeError(msg_, context_, "\021SerialisationError", error_strin
g_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit SerialisationError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | | explicit SerialisationError(const std::string &msg_, const std::string
&context_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "SerialisationError", errno_) {} | | : RuntimeError(msg_, context_, "\021SerialisationError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| SerialisationError(const std::string &msg_, int errno_) | | SerialisationError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "SerialisationError", errno_) {} | | : RuntimeError(msg_, std::string(), "\021SerialisationError", errno_
) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| SerialisationError(const std::string &msg_, const std::string &context_
, const char * type_, const char * error_string_) | | SerialisationError(const std::string &msg_, const std::string &context_
, const char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
| skipping to change at line 946 | | skipping to change at line 945 | |
| /** RangeError indicates an attempt to access outside the bounds of a conta
iner. | | /** RangeError indicates an attempt to access outside the bounds of a conta
iner. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError { | | class XAPIAN_VISIBILITY_DEFAULT RangeError : public RuntimeError { | |
| public: | | public: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Private constructor for use by remote backend. | | * @brief Private constructor for use by remote backend. | |
| * | | * | |
| * @param error_string_ Optional string describing error. May be NU
LL. | | * @param error_string_ Optional string describing error. May be NU
LL. | |
| */ | | */ | |
| RangeError(const std::string &msg_, const std::string &context_, const
char * error_string_) | | RangeError(const std::string &msg_, const std::string &context_, const
char * error_string_) | |
|
| : RuntimeError(msg_, context_, "RangeError", error_string_) {} | | : RuntimeError(msg_, context_, "\022RangeError", error_string_) {} | |
| /** General purpose constructor. | | /** General purpose constructor. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param context_ Optional context information for this error. | | * @param context_ Optional context information for this error. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| explicit RangeError(const std::string &msg_, const std::string &context
_ = std::string(), int errno_ = 0) | | explicit RangeError(const std::string &msg_, const std::string &context
_ = std::string(), int errno_ = 0) | |
|
| : RuntimeError(msg_, context_, "RangeError", errno_) {} | | : RuntimeError(msg_, context_, "\022RangeError", errno_) {} | |
| /** Construct from message and errno value. | | /** Construct from message and errno value. | |
| * | | * | |
| * @param msg_ Message giving details of the error, intende
d | | * @param msg_ Message giving details of the error, intende
d | |
| * for human consumption. | | * for human consumption. | |
| * @param errno_ Optional errno value associated with this er
ror. | | * @param errno_ Optional errno value associated with this er
ror. | |
| */ | | */ | |
| RangeError(const std::string &msg_, int errno_) | | RangeError(const std::string &msg_, int errno_) | |
|
| : RuntimeError(msg_, std::string(), "RangeError", errno_) {} | | : RuntimeError(msg_, std::string(), "\022RangeError", errno_) {} | |
| protected: | | protected: | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| RangeError(const std::string &msg_, const std::string &context_, const
char * type_, const char * error_string_) | | RangeError(const std::string &msg_, const std::string &context_, const
char * type_, const char * error_string_) | |
| : RuntimeError(msg_, context_, type_, error_string_) {} | | : RuntimeError(msg_, context_, type_, error_string_) {} | |
| | | | |
| /** @private @internal | | /** @private @internal | |
| * @brief Constructor for use by constructors of derived classes. | | * @brief Constructor for use by constructors of derived classes. | |
| */ | | */ | |
| | | | |
End of changes. 63 change blocks. |
| 75 lines changed or deleted | | 72 lines changed or added | |
|
| postingsource.h | | postingsource.h | |
| | | | |
| skipping to change at line 34 | | skipping to change at line 34 | |
| | | | |
| #include <xapian/database.h> | | #include <xapian/database.h> | |
| #include <xapian/types.h> | | #include <xapian/types.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
| #include <string> | | #include <string> | |
| #include <map> | | #include <map> | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
|
| | | class Registry; | |
| | | | |
| /** Base class which provides an "external" source of postings. | | /** Base class which provides an "external" source of postings. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT PostingSource { | | class XAPIAN_VISIBILITY_DEFAULT PostingSource { | |
| /// Don't allow assignment. | | /// Don't allow assignment. | |
| void operator=(const PostingSource &); | | void operator=(const PostingSource &); | |
| | | | |
| /// Don't allow copying. | | /// Don't allow copying. | |
| PostingSource(const PostingSource &); | | PostingSource(const PostingSource &); | |
| | | | |
| /// The current upper bound on what get_weight() can return. | | /// The current upper bound on what get_weight() can return. | |
| | | | |
| skipping to change at line 77 | | skipping to change at line 79 | |
| * get_weight() earlier in the iteration, but the posting source must
not | | * get_weight() earlier in the iteration, but the posting source must
not | |
| * return a higher value from get_weight() than the currently set uppe
r | | * return a higher value from get_weight() than the currently set uppe
r | |
| * bound, and the upper bound must not be increased (until init() has
been | | * bound, and the upper bound must not be increased (until init() has
been | |
| * called). | | * called). | |
| * | | * | |
| * If you don't call this method, the upper bound will default to 0, f
or | | * If you don't call this method, the upper bound will default to 0, f
or | |
| * convenience when implementing "weight-less" PostingSource subclasse
s. | | * convenience when implementing "weight-less" PostingSource subclasse
s. | |
| * | | * | |
| * @param max_weight The upper bound to set. | | * @param max_weight The upper bound to set. | |
| */ | | */ | |
|
| void set_maxweight(Xapian::weight max_weight); | | void set_maxweight(double max_weight); | |
| | | | |
| public: | | public: | |
| /** @private @internal Set the object to inform of maxweight changes. | | /** @private @internal Set the object to inform of maxweight changes. | |
| * | | * | |
| * This method is for internal use only - it would be private except t
hat | | * This method is for internal use only - it would be private except t
hat | |
| * would force us to forward declare an internal class in an external
API | | * would force us to forward declare an internal class in an external
API | |
| * header just to make it a friend. | | * header just to make it a friend. | |
| */ | | */ | |
| void register_matcher_(void * matcher) { matcher_ = matcher; } | | void register_matcher_(void * matcher) { matcher_ = matcher; } | |
| | | | |
| | | | |
| skipping to change at line 117 | | skipping to change at line 119 | |
| virtual Xapian::doccount get_termfreq_est() const = 0; | | virtual Xapian::doccount get_termfreq_est() const = 0; | |
| | | | |
| /** An upper bound on the number of documents this object can return. | | /** An upper bound on the number of documents this object can return. | |
| * | | * | |
| * Xapian will always call init() on a PostingSource before calling th
is | | * Xapian will always call init() on a PostingSource before calling th
is | |
| * for the first time. | | * for the first time. | |
| */ | | */ | |
| virtual Xapian::doccount get_termfreq_max() const = 0; | | virtual Xapian::doccount get_termfreq_max() const = 0; | |
| | | | |
| /// Return the currently set upper bound on what get_weight() can retur
n. | | /// Return the currently set upper bound on what get_weight() can retur
n. | |
|
| Xapian::weight get_maxweight() const { return max_weight_; } | | double get_maxweight() const { return max_weight_; } | |
| | | | |
| /** Return the weight contribution for the current document. | | /** Return the weight contribution for the current document. | |
| * | | * | |
| * This default implementation always returns 0, for convenience when | | * This default implementation always returns 0, for convenience when | |
| * implementing "weight-less" PostingSource subclasses. | | * implementing "weight-less" PostingSource subclasses. | |
| * | | * | |
| * This method may assume that it will only be called when there is a | | * This method may assume that it will only be called when there is a | |
| * "current document". In detail: Xapian will always call init() on a | | * "current document". In detail: Xapian will always call init() on a | |
| * PostingSource before calling this for the first time. It will also | | * PostingSource before calling this for the first time. It will also | |
| * only call this if the PostingSource reports that it is pointing to
a | | * only call this if the PostingSource reports that it is pointing to
a | |
| * valid document (ie, it will not call it before calling at least one
of | | * valid document (ie, it will not call it before calling at least one
of | |
| * next(), skip_to() or check(), and will ensure that the PostingSourc
e is | | * next(), skip_to() or check(), and will ensure that the PostingSourc
e is | |
| * not at the end by calling at_end()). | | * not at the end by calling at_end()). | |
| */ | | */ | |
|
| virtual Xapian::weight get_weight() const; | | virtual double get_weight() const; | |
| | | | |
| /** Return the current docid. | | /** Return the current docid. | |
| * | | * | |
| * This method may assume that it will only be called when there is a | | * This method may assume that it will only be called when there is a | |
| * "current document". See @a get_weight() for details. | | * "current document". See @a get_weight() for details. | |
| * | | * | |
| * Note: in the case of a multi-database search, the returned docid sh
ould | | * Note: in the case of a multi-database search, the returned docid sh
ould | |
| * be in the single subdatabase relevant to this posting source. See
the | | * be in the single subdatabase relevant to this posting source. See
the | |
| * @a init() method for details. | | * @a init() method for details. | |
| */ | | */ | |
| | | | |
| skipping to change at line 157 | | skipping to change at line 159 | |
| * The PostingSource starts before the first entry in the list, so nex
t() | | * The PostingSource starts before the first entry in the list, so nex
t() | |
| * must be called before any methods which need the context of | | * must be called before any methods which need the context of | |
| * the current position. | | * the current position. | |
| * | | * | |
| * Xapian will always call init() on a PostingSource before calling th
is | | * Xapian will always call init() on a PostingSource before calling th
is | |
| * for the first time. | | * for the first time. | |
| * | | * | |
| * @param min_wt The minimum weight contribution that is needed (this
is | | * @param min_wt The minimum weight contribution that is needed (this
is | |
| * just a hint which subclasses may ignore). | | * just a hint which subclasses may ignore). | |
| */ | | */ | |
|
| virtual void next(Xapian::weight min_wt) = 0; | | virtual void next(double min_wt) = 0; | |
| | | | |
| /** Advance to the specified docid. | | /** Advance to the specified docid. | |
| * | | * | |
| * If the specified docid isn't in the list, position ourselves on the | | * If the specified docid isn't in the list, position ourselves on the | |
| * first document after it (or at_end() if no greater docids are prese
nt). | | * first document after it (or at_end() if no greater docids are prese
nt). | |
| * | | * | |
| * If the current position is already the specified docid, this method
will | | * If the current position is already the specified docid, this method
will | |
| * leave the position unmodified. | | * leave the position unmodified. | |
| * | | * | |
| * If the specified docid is earlier than the current position, the | | * If the specified docid is earlier than the current position, the | |
| | | | |
| skipping to change at line 186 | | skipping to change at line 188 | |
| * for the first time. | | * for the first time. | |
| * | | * | |
| * Note: in the case of a multi-database search, the docid specified i
s | | * Note: in the case of a multi-database search, the docid specified i
s | |
| * the docid in the single subdatabase relevant to this posting source
. | | * the docid in the single subdatabase relevant to this posting source
. | |
| * See the @a init() method for details. | | * See the @a init() method for details. | |
| * | | * | |
| * @param did The document id to advance to. | | * @param did The document id to advance to. | |
| * @param min_wt The minimum weight contribution that is needed (this
is | | * @param min_wt The minimum weight contribution that is needed (this
is | |
| * just a hint which subclasses may ignore). | | * just a hint which subclasses may ignore). | |
| */ | | */ | |
|
| virtual void skip_to(Xapian::docid did, Xapian::weight min_wt); | | virtual void skip_to(Xapian::docid did, double min_wt); | |
| | | | |
| /** Check if the specified docid occurs. | | /** Check if the specified docid occurs. | |
| * | | * | |
| * The caller is required to ensure that the specified document id @a
did | | * The caller is required to ensure that the specified document id @a
did | |
| * actually exists in the database. If it does, it must move to that | | * actually exists in the database. If it does, it must move to that | |
| * document id, and return true. If it does not, it may either: | | * document id, and return true. If it does not, it may either: | |
| * | | * | |
| * - return true, having moved to a definite position (including | | * - return true, having moved to a definite position (including | |
| * "at_end"), which must be the same position as skip_to() would have | | * "at_end"), which must be the same position as skip_to() would have | |
| * moved to. | | * moved to. | |
| | | | |
| skipping to change at line 223 | | skipping to change at line 225 | |
| * for the first time. | | * for the first time. | |
| * | | * | |
| * Note: in the case of a multi-database search, the docid specified i
s | | * Note: in the case of a multi-database search, the docid specified i
s | |
| * the docid in the single subdatabase relevant to this posting source
. | | * the docid in the single subdatabase relevant to this posting source
. | |
| * See the @a init() method for details. | | * See the @a init() method for details. | |
| * | | * | |
| * @param did The document id to check. | | * @param did The document id to check. | |
| * @param min_wt The minimum weight contribution that is needed (this
is | | * @param min_wt The minimum weight contribution that is needed (this
is | |
| * just a hint which subclasses may ignore). | | * just a hint which subclasses may ignore). | |
| */ | | */ | |
|
| virtual bool check(Xapian::docid did, Xapian::weight min_wt); | | virtual bool check(Xapian::docid did, double min_wt); | |
| | | | |
| /** Return true if the current position is past the last entry in this
list. | | /** Return true if the current position is past the last entry in this
list. | |
| * | | * | |
| * At least one of @a next(), @a skip_to() or @a check() will be calle
d | | * At least one of @a next(), @a skip_to() or @a check() will be calle
d | |
| * before this method is first called. | | * before this method is first called. | |
| */ | | */ | |
| virtual bool at_end() const = 0; | | virtual bool at_end() const = 0; | |
| | | | |
| /** Clone the posting source. | | /** Clone the posting source. | |
| * | | * | |
| | | | |
| skipping to change at line 300 | | skipping to change at line 302 | |
| * method in your subclass as shown here: | | * method in your subclass as shown here: | |
| * http://trac.xapian.org/ticket/554#comment:1 | | * http://trac.xapian.org/ticket/554#comment:1 | |
| * | | * | |
| * If you don't want to support the remote backend, you can use the | | * If you don't want to support the remote backend, you can use the | |
| * default implementation which simply throws Xapian::UnimplementedErr
or. | | * default implementation which simply throws Xapian::UnimplementedErr
or. | |
| * | | * | |
| * @param s A serialised instance of this PostingSource subclass. | | * @param s A serialised instance of this PostingSource subclass. | |
| */ | | */ | |
| virtual PostingSource * unserialise(const std::string &s) const; | | virtual PostingSource * unserialise(const std::string &s) const; | |
| | | | |
|
| | | /** Create object given string serialisation returned by serialise(). | |
| | | * | |
| | | * Note that the returned object will be deallocated by Xapian after u | |
| | | se | |
| | | * with "delete". If you want to handle the deletion in a special way | |
| | | * (for example when wrapping the Xapian API for use from another | |
| | | * language) then you can define a static <code>operator delete</code> | |
| | | * method in your subclass as shown here: | |
| | | * http://trac.xapian.org/ticket/554#comment:1 | |
| | | * | |
| | | * This method is supplied with a Registry object, which can be used w | |
| | | hen | |
| | | * unserialising objects contained within the posting source. The def | |
| | | ault | |
| | | * implementation simply calls unserialise() which doesn't take the | |
| | | * Registry object, so you do not need to implement this method unless | |
| | | you | |
| | | * want to take advantage of the Registry object when unserialising. | |
| | | * | |
| | | * @param s A serialised instance of this PostingSource subclass. | |
| | | */ | |
| | | virtual PostingSource * unserialise_with_registry(const std::string &s, | |
| | | const Registry & registry) const; | |
| | | | |
| /** Set this PostingSource to the start of the list of postings. | | /** Set this PostingSource to the start of the list of postings. | |
| * | | * | |
| * This is called automatically by the matcher prior to each query bei
ng | | * This is called automatically by the matcher prior to each query bei
ng | |
| * processed. | | * processed. | |
| * | | * | |
| * If a PostingSource is used for multiple searches, @a init() will | | * If a PostingSource is used for multiple searches, @a init() will | |
| * therefore be called multiple times, and must handle this by using t
he | | * therefore be called multiple times, and must handle this by using t
he | |
| * database passed in the most recent call. | | * database passed in the most recent call. | |
| * | | * | |
| * @param db The database which the PostingSource should iterate throu
gh. | | * @param db The database which the PostingSource should iterate throu
gh. | |
| | | | |
| skipping to change at line 390 | | skipping to change at line 412 | |
| /** Construct a ValuePostingSource. | | /** Construct a ValuePostingSource. | |
| * | | * | |
| * @param slot_ The value slot to read values from. | | * @param slot_ The value slot to read values from. | |
| */ | | */ | |
| ValuePostingSource(Xapian::valueno slot_); | | ValuePostingSource(Xapian::valueno slot_); | |
| | | | |
| Xapian::doccount get_termfreq_min() const; | | Xapian::doccount get_termfreq_min() const; | |
| Xapian::doccount get_termfreq_est() const; | | Xapian::doccount get_termfreq_est() const; | |
| Xapian::doccount get_termfreq_max() const; | | Xapian::doccount get_termfreq_max() const; | |
| | | | |
|
| void next(Xapian::weight min_wt); | | void next(double min_wt); | |
| void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); | | void skip_to(Xapian::docid min_docid, double min_wt); | |
| bool check(Xapian::docid min_docid, Xapian::weight min_wt); | | bool check(Xapian::docid min_docid, double min_wt); | |
| | | | |
| bool at_end() const; | | bool at_end() const; | |
| | | | |
| Xapian::docid get_docid() const; | | Xapian::docid get_docid() const; | |
| | | | |
| void init(const Database & db_); | | void init(const Database & db_); | |
| }; | | }; | |
| | | | |
| /** A posting source which reads weights from a value slot. | | /** A posting source which reads weights from a value slot. | |
| * | | * | |
| | | | |
| skipping to change at line 428 | | skipping to change at line 450 | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT ValueWeightPostingSource | | class XAPIAN_VISIBILITY_DEFAULT ValueWeightPostingSource | |
| : public ValuePostingSource { | | : public ValuePostingSource { | |
| public: | | public: | |
| /** Construct a ValueWeightPostingSource. | | /** Construct a ValueWeightPostingSource. | |
| * | | * | |
| * @param slot_ The value slot to read values from. | | * @param slot_ The value slot to read values from. | |
| */ | | */ | |
| ValueWeightPostingSource(Xapian::valueno slot_); | | ValueWeightPostingSource(Xapian::valueno slot_); | |
| | | | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| ValueWeightPostingSource * clone() const; | | ValueWeightPostingSource * clone() const; | |
| std::string name() const; | | std::string name() const; | |
| std::string serialise() const; | | std::string serialise() const; | |
| ValueWeightPostingSource * unserialise(const std::string &s) const; | | ValueWeightPostingSource * unserialise(const std::string &s) const; | |
| void init(const Database & db_); | | void init(const Database & db_); | |
| | | | |
| std::string get_description() const; | | std::string get_description() const; | |
| }; | | }; | |
| | | | |
| /** Read weights from a value which is known to decrease as docid increases
. | | /** Read weights from a value which is known to decrease as docid increases
. | |
| | | | |
| skipping to change at line 468 | | skipping to change at line 490 | |
| : public Xapian::ValueWeightPostingSource { | | : public Xapian::ValueWeightPostingSource { | |
| protected: | | protected: | |
| Xapian::docid range_start; | | Xapian::docid range_start; | |
| Xapian::docid range_end; | | Xapian::docid range_end; | |
| double curr_weight; | | double curr_weight; | |
| | | | |
| /// Flag, set to true if there are docs after the end of the range. | | /// Flag, set to true if there are docs after the end of the range. | |
| bool items_at_end; | | bool items_at_end; | |
| | | | |
| /// Skip the iterator forward if in the decreasing range, and weight is
low. | | /// Skip the iterator forward if in the decreasing range, and weight is
low. | |
|
| void skip_if_in_range(Xapian::weight min_wt); | | void skip_if_in_range(double min_wt); | |
| | | | |
| public: | | public: | |
| DecreasingValueWeightPostingSource(Xapian::valueno slot_, | | DecreasingValueWeightPostingSource(Xapian::valueno slot_, | |
| Xapian::docid range_start_ = 0, | | Xapian::docid range_start_ = 0, | |
| Xapian::docid range_end_ = 0); | | Xapian::docid range_end_ = 0); | |
| | | | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| DecreasingValueWeightPostingSource * clone() const; | | DecreasingValueWeightPostingSource * clone() const; | |
| std::string name() const; | | std::string name() const; | |
| std::string serialise() const; | | std::string serialise() const; | |
| DecreasingValueWeightPostingSource * unserialise(const std::string &s)
const; | | DecreasingValueWeightPostingSource * unserialise(const std::string &s)
const; | |
| void init(const Xapian::Database & db_); | | void init(const Xapian::Database & db_); | |
| | | | |
|
| void next(Xapian::weight min_wt); | | void next(double min_wt); | |
| void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); | | void skip_to(Xapian::docid min_docid, double min_wt); | |
| bool check(Xapian::docid min_docid, Xapian::weight min_wt); | | bool check(Xapian::docid min_docid, double min_wt); | |
| | | | |
| std::string get_description() const; | | std::string get_description() const; | |
| }; | | }; | |
| | | | |
| /** A posting source which looks up weights in a map using values as the ke
y. | | /** A posting source which looks up weights in a map using values as the ke
y. | |
| * | | * | |
| * This allows will return entries for all documents in the given database | | * This allows will return entries for all documents in the given database | |
| * which have a value in the slot specified. The values will be mapped to
the | | * which have a value in the slot specified. The values will be mapped to
the | |
| * corresponding weight in the weight map. If there is no mapping for a | | * corresponding weight in the weight map. If there is no mapping for a | |
| * particular value, the default weight will be returned (which itself | | * particular value, the default weight will be returned (which itself | |
| | | | |
| skipping to change at line 531 | | skipping to change at line 553 | |
| | | | |
| /** Clear all mappings. */ | | /** Clear all mappings. */ | |
| void clear_mappings(); | | void clear_mappings(); | |
| | | | |
| /** Set a default weight for document values not in the map. | | /** Set a default weight for document values not in the map. | |
| * | | * | |
| * @param wt The weight to set as the default. | | * @param wt The weight to set as the default. | |
| */ | | */ | |
| void set_default_weight(double wt); | | void set_default_weight(double wt); | |
| | | | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| ValueMapPostingSource * clone() const; | | ValueMapPostingSource * clone() const; | |
| std::string name() const; | | std::string name() const; | |
| std::string serialise() const; | | std::string serialise() const; | |
| ValueMapPostingSource * unserialise(const std::string &s) const; | | ValueMapPostingSource * unserialise(const std::string &s) const; | |
| void init(const Database & db_); | | void init(const Database & db_); | |
| | | | |
| std::string get_description() const; | | std::string get_description() const; | |
| }; | | }; | |
| | | | |
| /** A posting source which returns a fixed weight for all documents. | | /** A posting source which returns a fixed weight for all documents. | |
| | | | |
| skipping to change at line 567 | | skipping to change at line 589 | |
| bool started; | | bool started; | |
| | | | |
| /// The docid last passed to check() (0 if check() wasn't the last move
). | | /// The docid last passed to check() (0 if check() wasn't the last move
). | |
| Xapian::docid check_docid; | | Xapian::docid check_docid; | |
| | | | |
| public: | | public: | |
| /** Construct a FixedWeightPostingSource. | | /** Construct a FixedWeightPostingSource. | |
| * | | * | |
| * @param wt The fixed weight to return. | | * @param wt The fixed weight to return. | |
| */ | | */ | |
|
| FixedWeightPostingSource(Xapian::weight wt); | | FixedWeightPostingSource(double wt); | |
| | | | |
| Xapian::doccount get_termfreq_min() const; | | Xapian::doccount get_termfreq_min() const; | |
| Xapian::doccount get_termfreq_est() const; | | Xapian::doccount get_termfreq_est() const; | |
| Xapian::doccount get_termfreq_max() const; | | Xapian::doccount get_termfreq_max() const; | |
| | | | |
|
| Xapian::weight get_weight() const; | | double get_weight() const; | |
| | | | |
|
| void next(Xapian::weight min_wt); | | void next(double min_wt); | |
| void skip_to(Xapian::docid min_docid, Xapian::weight min_wt); | | void skip_to(Xapian::docid min_docid, double min_wt); | |
| bool check(Xapian::docid min_docid, Xapian::weight min_wt); | | bool check(Xapian::docid min_docid, double min_wt); | |
| | | | |
| bool at_end() const; | | bool at_end() const; | |
| | | | |
| Xapian::docid get_docid() const; | | Xapian::docid get_docid() const; | |
| | | | |
| FixedWeightPostingSource * clone() const; | | FixedWeightPostingSource * clone() const; | |
| std::string name() const; | | std::string name() const; | |
| std::string serialise() const; | | std::string serialise() const; | |
| FixedWeightPostingSource * unserialise(const std::string &s) const; | | FixedWeightPostingSource * unserialise(const std::string &s) const; | |
| void init(const Database & db_); | | void init(const Database & db_); | |
| | | | |
End of changes. 17 change blocks. |
| 21 lines changed or deleted | | 47 lines changed or added | |
|
| query.h | | query.h | |
|
| /** \file query.h | | /** @file query.h | |
| * \brief Classes for representing a query | | * @brief Xapian::Query API class | |
| */ | | */ | |
|
| /* Copyright 1999,2000,2001 BrightStation PLC | | /* Copyright (C) 2011,2012 Olly Betts | |
| * Copyright 2002 Ananova Ltd | | * Copyright (C) 2008 Richard Boulton | |
| * Copyright 2003,2004,2005,2006,2007,2008,2009,2012 Olly Betts | | | |
| * Copyright 2006,2007,2008,2009 Lemur Consulting Ltd | | | |
| * Copyright 2008 Richard Boulton | | | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| * License, or (at your option) any later version. | | * License, or (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| * GNU General Public License for more details. | | * GNU General Public License for more details. | |
| * | | * | |
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU General Public License | |
| * along with this program; if not, write to the Free Software | | * along with this program; if not, write to the Free Software | |
|
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US | |
| * USA | | A | |
| */ | | */ | |
| | | | |
| #ifndef XAPIAN_INCLUDED_QUERY_H | | #ifndef XAPIAN_INCLUDED_QUERY_H | |
| #define XAPIAN_INCLUDED_QUERY_H | | #define XAPIAN_INCLUDED_QUERY_H | |
| | | | |
| #include <string> | | #include <string> | |
| #include <vector> | | #include <vector> | |
| | | | |
|
| #include <xapian/base.h> | | #include <xapian/intrusive_ptr.h> | |
| #include <xapian/types.h> | | #include <xapian/postingiterator.h> | |
| | | #include <xapian/registry.h> | |
| #include <xapian/termiterator.h> | | #include <xapian/termiterator.h> | |
|
| | | #include <xapian/types.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
|
| // FIXME: sort this out so we avoid exposing Xapian::Query::Internal | | class QueryOptimiser; // FIXME | |
| // - we need to at present so that the Xapian::Query's template ctors | | | |
| // compile. | | | |
| class LocalSubMatch; | | | |
| class MultiMatch; | | | |
| class QueryOptimiser; | | | |
| struct SortPosName; | | | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
| class PostingSource; | | class PostingSource; | |
|
| class Registry; | | | |
| | | | |
|
| /** Class representing a query. | | /// Class representing a query. | |
| * | | | |
| * Queries are represented as a tree of objects. | | | |
| */ | | | |
| class XAPIAN_VISIBILITY_DEFAULT Query { | | class XAPIAN_VISIBILITY_DEFAULT Query { | |
|
| public: | | public: | |
| /// Class holding details of the query | | /// Class representing the query internals. | |
| class Internal; | | class Internal; | |
| /// @private @internal Reference counted internals. | | /// @private @internal Reference counted internals. | |
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
| /// Enum of possible query operations | | static const Xapian::Query MatchNothing; | |
| typedef enum { | | static const Xapian::Query MatchAll; | |
| /// Return iff both subqueries are satisfied | | | |
| OP_AND, | | /** Query operators. */ | |
| | | enum op { | |
| /// Return if either subquery is satisfied | | OP_AND = 0, | |
| OP_OR, | | OP_OR = 1, | |
| | | OP_AND_NOT = 2, | |
| /// Return if left but not right satisfied | | OP_XOR = 3, | |
| OP_AND_NOT, | | OP_AND_MAYBE = 4, | |
| | | OP_FILTER = 5, | |
| /// Return if one query satisfied, but not both | | OP_NEAR = 6, | |
| OP_XOR, | | OP_PHRASE = 7, | |
| | | OP_VALUE_RANGE = 8, | |
| /// Return iff left satisfied, but use weights from both | | OP_SCALE_WEIGHT = 9, | |
| OP_AND_MAYBE, | | | |
| | | /** Pick the best N subqueries and combine with OP_OR. | |
| /// As AND, but use only weights from left subquery | | * | |
| OP_FILTER, | | * If you want to implement a feature which finds documents similar | |
| | | to | |
| /** Find occurrences of a list of terms with all the terms | | * a piece of text, an obvious approach is to build an "OR" query f | |
| * occurring within a specified window of positions. | | rom | |
| * | | * all the terms in the text, and run this query against a database | |
| * Each occurrence of a term must be at a different position, | | * containing the documents. However such a query can contain a lo | |
| * but the order they appear in is irrelevant. | | ts | |
| * | | * of terms and be quite slow to perform, yet many of these terms | |
| * The window parameter should be specified for this operation, | | * don't contribute usefully to the results. | |
| * but will default to the number of terms in the list. | | * | |
| */ | | * The OP_ELITE_SET operator can be used instead of OP_OR in this | |
| OP_NEAR, | | * situation. OP_ELITE_SET selects the most important ''N'' terms | |
| | | and | |
| /** Find occurrences of a list of terms with all the terms | | * then acts as an OP_OR query with just these, ignoring any other | |
| * occurring within a specified window of positions, and all | | * terms. This will usually return results just as good as the ful | |
| * the terms appearing in the order specified. | | l | |
| * | | * OP_OR query, but much faster. | |
| * Each occurrence of a term must be at a different position. | | * | |
| * | | * In general, the OP_ELITE_SET operator can be used when you have | |
| * The window parameter should be specified for this operation, | | a | |
| * but will default to the number of terms in the list. | | * large OR query, but it doesn't matter if the search completely | |
| */ | | * ignores some of the less important terms in the query. | |
| OP_PHRASE, | | * | |
| | | * The subqueries don't have to be terms, but if they aren't then | |
| /** Filter by a range test on a document value. */ | | * OP_ELITE_SET will look at the estimated frequencies of the | |
| OP_VALUE_RANGE, | | * subqueries and so could pick a subset which don't actually | |
| | | * match any documents even if the full OR would match some. | |
| /** Scale the weight of a subquery by the specified factor. | | * | |
| * | | * You can specify a parameter to the query constructor which contr | |
| * A factor of 0 means this subquery will contribute no weight | | ol | |
| to | | * the number of terms which OP_ELITE_SET will pick. If not | |
| * the query - it will act as a purely boolean subquery. | | * specified, this defaults to 10 (Xapian used to default to | |
| * | | * <code>ceil(sqrt(number_of_subqueries))</code> if there are more | |
| * If the factor is negative, Xapian::InvalidArgumentError will | | * than 100 subqueries, but this rather arbitrary special case was | |
| * be thrown. | | * dropped in 1.3.0). For example, this will pick the best 7 terms | |
| */ | | : | |
| OP_SCALE_WEIGHT, | | * | |
| | | * <pre> | |
| /** Pick the best N subqueries and combine with OP_OR. | | * Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin(), | |
| * | | subqs.end(), 7); | |
| * If you want to implement a feature which finds documents | | * </pre> | |
| * similar to a piece of text, an obvious approach is to build | | * | |
| an | | * If the number of subqueries is less than this threshold, | |
| * "OR" query from all the terms in the text, and run this quer | | * OP_ELITE_SET behaves identically to OP_OR. | |
| y | | */ | |
| * against a database containing the documents. However such a | | OP_ELITE_SET = 10, | |
| * query can contain a lots of terms and be quite slow to perfo | | OP_VALUE_GE = 11, | |
| rm, | | OP_VALUE_LE = 12, | |
| * yet many of these terms don't contribute usefully to the | | OP_SYNONYM = 13 | |
| * results. | | }; | |
| * | | | |
| * The OP_ELITE_SET operator can be used instead of OP_OR in th | | /// Default constructor. | |
| is | | Query() : internal(0) { } | |
| * situation. OP_ELITE_SET selects the most important ''N'' te | | | |
| rms | | /// Destructor. | |
| * and then acts as an OP_OR query with just these, ignoring an | | ~Query() { } | |
| y | | | |
| * other terms. This will usually return results just as good | | /** Copying is allowed. | |
| as | | * | |
| * the full OP_OR query, but much faster. | | * The internals are reference counted, so copying is cheap. | |
| * | | */ | |
| * In general, the OP_ELITE_SET operator can be used when you h | | Query(const Query & o) : internal(o.internal) { } | |
| ave | | | |
| * a large OR query, but it doesn't matter if the search | | /** Copying is allowed. | |
| * completely ignores some of the less important terms in the | | * | |
| * query. | | * The internals are reference counted, so assignment is cheap. | |
| * | | */ | |
| * The subqueries don't have to be terms, but if they aren't th | | Query & operator=(const Query & o) { internal = o.internal; return *thi | |
| en | | s; } | |
| * OP_ELITE_SET will look at the estimated frequencies of the | | | |
| * subqueries and so could pick a subset which don't actually | | /** Construct a Query object for a term. */ | |
| * match any documents even if the full OR would match some. | | Query(const std::string & term, | |
| * | | Xapian::termcount wqf = 1, | |
| * You can specify a parameter to the query constructor which | | Xapian::termpos pos = 0); | |
| * control the number of terms which OP_ELITE_SET will pick. I | | | |
| f | | /** Construct a Query object for a PostingSource. */ | |
| * not specified, this defaults to 10 (or | | Query(Xapian::PostingSource * source); | |
| * <code>ceil(sqrt(number_of_subqueries))</code> if there are m | | | |
| ore | | // FIXME: new form for OP_SCALE_WEIGHT - do we want this? | |
| * than 100 subqueries, but this rather arbitrary special case | | Query(double factor, const Xapian::Query & subquery); | |
| * will be dropped in 1.3.0). For example, this will pick the | | | |
| * best 7 terms: | | // FIXME: legacy form of above (assuming we want to add that...) | |
| * | | Query(op op_, const Xapian::Query & subquery, double factor); | |
| * <pre> | | | |
| * Xapian::Query query(Xapian::Query::OP_ELITE_SET, subqs.begin | | // Pairwise. | |
| (), subqs.end(), 7); | | Query(op op_, const Xapian::Query & a, const Xapian::Query & b) | |
| * </pre> | | { | |
| * | | init(op_, 2); | |
| * If the number of subqueries is less than this threshold, | | add_subquery(a); | |
| * OP_ELITE_SET behaves identically to OP_OR. | | add_subquery(b); | |
| */ | | done(); | |
| OP_ELITE_SET, | | } | |
| | | | |
| /** Filter by a greater-than-or-equal test on a document value. | | | |
| */ | | | |
| OP_VALUE_GE, | | | |
| | | | |
| /** Filter by a less-than-or-equal test on a document value. */ | | | |
| OP_VALUE_LE, | | | |
| | | | |
| /** Treat a set of queries as synonyms. | | | |
| * | | | |
| * This returns all results which match at least one of the | | | |
| * queries, but weighting as if all the sub-queries are instanc | | | |
| es | | | |
| * of the same term: so multiple matching terms for a document | | | |
| * increase the wdf value used, and the term frequency is based | | | |
| on | | | |
| * the number of documents which would match an OR of all the | | | |
| * subqueries. | | | |
| * | | | |
| * The term frequency used will usually be an approximation, | | | |
| * because calculating the precise combined term frequency woul | | | |
| d | | | |
| * be overly expensive. | | | |
| * | | | |
| * Identical to OP_OR, except for the weightings returned. | | | |
| */ | | | |
| OP_SYNONYM | | | |
| } op; | | | |
| | | | |
|
| /** Copy constructor. */ | | // Pairwise with std::string. | |
| Query(const Query & copyme); | | Query(op op_, const std::string & a, const std::string & b) | |
| | | { | |
| | | init(op_, 2); | |
| | | add_subquery(a); | |
| | | add_subquery(b); | |
| | | done(); | |
| | | } | |
| | | | |
|
| /** Assignment. */ | | // OP_VALUE_GE/OP_VALUE_LE | |
| Query & operator=(const Query & copyme); | | Query(op op_, Xapian::valueno slot, const std::string & limit); | |
| | | | |
|
| /** Default constructor: makes an empty query which matches no | | // OP_VALUE_RANGE | |
| * documents. | | Query(op op_, Xapian::valueno slot, | |
| * | | const std::string & begin, const std::string & end); | |
| * Also useful for defining a Query object to be assigned to later. | | | |
| * | | template<typename I> | |
| * An exception will be thrown if an attempt is made to use an | | Query(op op_, I begin, I end, Xapian::termcount window = 0) | |
| * undefined query when building up a composite query. | | { | |
| */ | | if (begin != end) { | |
| Query(); | | typedef typename std::iterator_traits<I>::iterator_category iter | |
| | | ator_category; | |
| | | init(op_, window, begin, end, iterator_category()); | |
| | | for (I i = begin; i != end; ++i) { | |
| | | add_subquery(*i); | |
| | | } | |
| | | } | |
| | | done(); | |
| | | } | |
| | | | |
|
| /** Destructor. */ | | #ifdef SWIG | |
| ~Query(); | | // SWIG's %template doesn't seem to handle a templated ctor so we | |
| | | // provide this fake specialised form of the above prototype. | |
| | | Query::Query(op op_, XapianSWIGQueryItor qbegin, XapianSWIGQueryItor qe | |
| | | nd, | |
| | | Xapian::termcount parameter = 0); | |
| | | #endif | |
| | | | |
|
| /** A query consisting of a single term. */ | | const TermIterator get_terms_begin() const; | |
| Query(const std::string & tname_, Xapian::termcount wqf_ = 1, | | | |
| Xapian::termpos pos_ = 0); | | | |
| | | | |
|
| /** A query consisting of two subqueries, opp-ed together. */ | | const TermIterator get_terms_end() const { return TermIterator(); } | |
| Query(Query::op op_, const Query & left, const Query & right); | | | |
| | | | |
|
| /** A query consisting of two termnames opp-ed together. */ | | Xapian::termcount get_length() const; | |
| Query(Query::op op_, | | | |
| const std::string & left, const std::string & right); | | | |
| | | | |
|
| /** Combine a number of Xapian::Query-s with the specified operator. | | bool empty() const { return internal.get() == 0; } | |
| * | | | |
| * The Xapian::Query objects are specified with begin and end | | | |
| * iterators. | | | |
| * | | | |
| * AND, OR, XOR, ELITE_SET, SYNONYM, NEAR and PHRASE can take any | | | |
| * number of subqueries. Other operators take exactly two subqueri | | | |
| es. | | | |
| * | | | |
| * The iterators may be to Xapian::Query objects, pointers to | | | |
| * Xapian::Query objects, or termnames (std::string-s). | | | |
| * | | | |
| * For NEAR and PHRASE, a window size can be specified in parameter | | | |
| . | | | |
| * | | | |
| * For ELITE_SET, the elite set size can be specified in parameter. | | | |
| */ | | | |
| template <class Iterator> | | | |
| Query(Query::op op_, Iterator qbegin, Iterator qend, | | | |
| Xapian::termcount parameter = 0); | | | |
| | | | |
|
| /** Apply the specified operator to a single Xapian::Query object, w | | std::string serialise() const; | |
| ith | | | |
| * a double parameter. | | | |
| */ | | | |
| Query(Query::op op_, Xapian::Query q, double parameter); | | | |
| | | | |
|
| /** Construct a value range query on a document value. | | static const Query unserialise(const std::string & s, | |
| * | | const Registry & reg = Registry()); | |
| * A value range query matches those documents which have a value | | | |
| * stored in the slot given by @a slot which is in the range | | | |
| * specified by @a begin and @a end (in lexicographical | | | |
| * order), including the endpoints. | | | |
| * | | | |
| * @param op_ The operator to use for the query. Currently, must | | | |
| * be OP_VALUE_RANGE. | | | |
| * @param slot The slot number to get the value from. | | | |
| * @param begin The start of the range. | | | |
| * @param end The end of the range. | | | |
| */ | | | |
| Query(Query::op op_, Xapian::valueno slot, | | | |
| const std::string &begin, const std::string &end); | | | |
| | | | |
|
| /** Construct a value comparison query on a document value. | | std::string get_description() const; | |
| * | | | |
| * This query matches those documents which have a value stored in | | | |
| the | | | |
| * slot given by @a slot which compares, as specified by the | | | |
| * operator, to @a value. | | | |
| * | | | |
| * @param op_ The operator to use for the query. Currently, must | | | |
| * be OP_VALUE_GE or OP_VALUE_LE. | | | |
| * @param slot The slot number to get the value from. | | | |
| * @param value The value to compare. | | | |
| */ | | | |
| Query(Query::op op_, Xapian::valueno slot, const std::string &value) | | | |
| ; | | | |
| | | | |
|
| /** Construct an external source query. | | const Query operator&=(const Query & o) { | |
| * | | return (*this = Query(OP_AND, *this, o)); | |
| * An attempt to clone the posting source will be made immediately, | | } | |
| so | | | |
| * if the posting source supports clone(), the source supplied may | | | |
| be | | | |
| * safely deallocated after this call. If the source does not supp | | | |
| ort | | | |
| * clone(), the caller must ensure that the posting source remains | | | |
| * valid until the Query is deallocated. | | | |
| * | | | |
| * @param external_source The source to use in the query. | | | |
| */ | | | |
| explicit Query(Xapian::PostingSource * external_source); | | | |
| | | | |
| /** A query which matches all documents in the database. */ | | | |
| static const Xapian::Query MatchAll; | | | |
| | | | |
|
| /** A query which matches no documents. */ | | const Query operator|=(const Query & o) { | |
| static const Xapian::Query MatchNothing; | | return (*this = Query(OP_OR, *this, o)); | |
| | | } | |
| | | | |
|
| /** Get the length of the query, used by some ranking formulae. | | const Query operator^=(const Query & o) { | |
| * This value is calculated automatically - if you want to override | | return (*this = Query(OP_XOR, *this, o)); | |
| * it you can pass a different value to Enquire::set_query(). | | } | |
| */ | | | |
| Xapian::termcount get_length() const; | | | |
| | | | |
|
| /** Return a Xapian::TermIterator returning all the terms in the que | | const Query operator*=(double factor) { | |
| ry, | | return (*this = Query(factor, *this)); | |
| * in order of termpos. If multiple terms have the same term | | } | |
| * position, their order is unspecified. Duplicates (same term and | | | |
| * termpos) will be removed. | | | |
| */ | | | |
| TermIterator get_terms_begin() const; | | | |
| | | | |
|
| /** Return a Xapian::TermIterator to the end of the list of terms in | | const Query operator/=(double factor) { | |
| the | | return (*this = Query(1.0 / factor, *this)); | |
| * query. | | } | |
| */ | | | |
| TermIterator get_terms_end() const { | | | |
| return TermIterator(); | | | |
| } | | | |
| | | | |
|
| /** Test if the query is empty (i.e. was constructed using | | private: | |
| * the default ctor or with an empty iterator ctor). | | // Pass a reference to avoid ambiguity for Query(NULL) (not useful, but | |
| */ | | the | |
| bool empty() const; | | // testsuite does it...) FIXME | |
| | | Query(Query::Internal & internal_) : internal(&internal_) { } | |
| | | | |
| | | void init(Query::op op_, size_t n_subqueries, Xapian::termcount window | |
| | | = 0); | |
| | | | |
| | | template<typename I> | |
| | | void init(Query::op op_, Xapian::termcount window, | |
| | | const I & begin, const I & end, std::random_access_iterator_ta | |
| | | g) | |
| | | { | |
| | | init(op_, end - begin, window); | |
| | | } | |
| | | | |
|
| /** Serialise query into a string. | | template<typename I> | |
| * | | void init(Query::op op_, Xapian::termcount window, | |
| * The query representation may change between Xapian releases: | | const I &, const I &, std::input_iterator_tag) | |
| * even between minor versions. However, it is guaranteed not to | | { | |
| * change unless the remote database protocol has also changed betw | | init(op_, 0, window); | |
| een | | } | |
| * releases. | | | |
| */ | | | |
| std::string serialise() const; | | | |
| | | | |
|
| /** Unserialise a query from a string produced by serialise(). | | void add_subquery(const Xapian::Query & subquery); | |
| * | | | |
| * This method will fail if the query contains any external | | | |
| * PostingSource leaf nodes. | | | |
| * | | | |
| * @param s The string representing the serialised query. | | | |
| */ | | | |
| static Query unserialise(const std::string &s); | | | |
| | | | |
|
| /** Unserialise a query from a string produced by serialise(). | | void add_subquery(const std::string & subquery) { | |
| * | | add_subquery(Xapian::Query(subquery)); | |
| * The supplied registry will be used to attempt to unserialise any | | } | |
| * external PostingSource leaf nodes. This method will fail if the | | | |
| * query contains any external PostingSource leaf nodes which are n | | | |
| ot | | | |
| * registered in the registry. | | | |
| * | | | |
| * @param s The string representing the serialised query. | | | |
| * @param registry Xapian::Registry to use. | | | |
| */ | | | |
| static Query unserialise(const std::string & s, | | | |
| const Registry & registry); | | | |
| | | | |
|
| /// Return a string describing this object. | | void add_subquery(const Xapian::Query * subquery) { | |
| std::string get_description() const; | | // FIXME: subquery NULL? | |
| | | add_subquery(*subquery); | |
| | | } | |
| | | | |
|
| private: | | void done(); | |
| void add_subquery(const Query & subq); | | | |
| void add_subquery(const Query * subq); | | | |
| void add_subquery(const std::string & tname); | | | |
| void start_construction(Query::op op_, Xapian::termcount parameter); | | | |
| void end_construction(); | | | |
| void abort_construction(); | | | |
| }; | | }; | |
| | | | |
|
| template <class Iterator> | | inline const Query | |
| Query::Query(Query::op op_, Iterator qbegin, Iterator qend, termcount param | | operator&(const Query & a, const Query & b) | |
| eter) | | | |
| : internal(0) | | | |
| { | | { | |
|
| try { | | return Query(Query::OP_AND, a, b); | |
| start_construction(op_, parameter); | | | |
| | | | |
| /* Add all the elements */ | | | |
| while (qbegin != qend) { | | | |
| add_subquery(*qbegin); | | | |
| ++qbegin; | | | |
| } | | | |
| | | | |
| end_construction(); | | | |
| } catch (...) { | | | |
| abort_construction(); | | | |
| throw; | | | |
| } | | | |
| } | | } | |
| | | | |
|
| #ifndef SWIG // SWIG has no interest in the internal class, so hide it comp | | inline const Query | |
| letely. | | operator|(const Query & a, const Query & b) | |
| | | { | |
| /// @private @internal Internal class, implementing most of Xapian::Query. | | return Query(Query::OP_OR, a, b); | |
| class XAPIAN_VISIBILITY_DEFAULT Query::Internal : public Xapian::Internal:: | | } | |
| RefCntBase { | | | |
| friend class ::LocalSubMatch; | | | |
| friend class ::MultiMatch; | | | |
| friend class ::QueryOptimiser; | | | |
| friend struct ::SortPosName; | | | |
| friend class Query; | | | |
| public: | | | |
| static const int OP_LEAF = -1; | | | |
| static const int OP_EXTERNAL_SOURCE = -2; | | | |
| | | | |
| /// The container type for storing pointers to subqueries | | | |
| typedef std::vector<Internal *> subquery_list; | | | |
| | | | |
| /// Type storing the operation | | | |
| typedef int op_t; | | | |
| | | | |
| private: | | | |
| /// Operation to be performed at this node | | | |
| Xapian::Query::Internal::op_t op; | | | |
| | | | |
| /// Sub queries on which to perform operation | | | |
| subquery_list subqs; | | | |
| | | | |
| /** For NEAR or PHRASE, how close terms must be to match: all terms | | | |
| * within the operation must occur in a window of this size. | | | |
| * | | | |
| * For ELITE_SET, the number of terms to select from those specified | | | |
| . | | | |
| * | | | |
| * For RANGE, the value number to apply the range test to. | | | |
| * | | | |
| * For a leaf node, this is the within query frequency of the term. | | | |
| */ | | | |
| Xapian::termcount parameter; | | | |
| | | | |
| /** Term that this node represents, or start of a range query. | | | |
| * | | | |
| * For a leaf node, this holds the term name. For an OP_VALUE_RANG | | | |
| E | | | |
| * query this holds the start of the range. For an OP_VALUE_GE or | | | |
| * OP_VALUE_LE query this holds the value to compare against. | | | |
| */ | | | |
| std::string tname; | | | |
| | | | |
| /** Used to store the end of a range query. */ | | | |
| std::string str_parameter; | | | |
| | | | |
| /// Position in query of this term - leaf node only | | | |
| Xapian::termpos term_pos; | | | |
| | | | |
| /// External posting source. | | | |
| Xapian::PostingSource * external_source; | | | |
| | | | |
| /// Flag, indicating whether the external source is owned by the que | | | |
| ry. | | | |
| bool external_source_owned; | | | |
| | | | |
| /// Copy another Xapian::Query::Internal into self. | | | |
| void initialise_from_copy(const Query::Internal & copyme); | | | |
| | | | |
| void accumulate_terms( | | | |
| std::vector<std::pair<std::string, Xapian::termpos> > &terms) co | | | |
| nst; | | | |
| | | | |
| /** Simplify the query. | | | |
| * For example, an AND query with only one subquery would become th | | | |
| e | | | |
| * subquery itself. | | | |
| */ | | | |
| Internal * simplify_query(); | | | |
| | | | |
| /** Perform checks that query is valid. (e.g., has correct number of | | | |
| * sub queries.) Throw an exception if not. This is initially cal | | | |
| led | | | |
| * on the query before any simplifications have been made, and afte | | | |
| r | | | |
| * simplifications. | | | |
| */ | | | |
| void validate_query() const; | | | |
| | | | |
|
| /** Simplify any matchnothing subqueries, either eliminating them, | | inline const Query | |
| * or setting this query to matchnothing, depending on the query | | operator^(const Query & a, const Query & b) | |
| * operator. Returns true if simplification resulted in a | | { | |
| * matchnothing query. | | return Query(Query::OP_XOR, a, b); | |
| */ | | } | |
| bool simplify_matchnothing(); | | | |
| | | | |
|
| /** Get a string describing the given query type. | | inline const Query | |
| */ | | operator*(double factor, const Query & q) | |
| static std::string get_op_name(Xapian::Query::Internal::op_t op); | | { | |
| | | return Query(factor, q); | |
| | | } | |
| | | | |
|
| /** Collapse the subqueries together if appropriate. | | inline const Query | |
| */ | | operator*(const Query & q, double factor) | |
| void collapse_subqs(); | | { | |
| | | return Query(factor, q); | |
| | | } | |
| | | | |
|
| /** Flatten a query structure, by changing, for example, | | inline const Query | |
| * "A NEAR (B AND C)" to "(A NEAR B) AND (A NEAR C)" | | operator/(const Query & q, double factor) | |
| */ | | { | |
| Xapian::Query::Internal * flatten_subqs(); | | return Query(1.0 / factor, q); | |
| | | } | |
| | | | |
|
| /** Implementation of serialisation; called recursively. | | class InvertedQuery_ { | |
| */ | | const Query & query; | |
| std::string serialise(Xapian::termpos & curpos) const; | | | |
| | | | |
|
| public: | | void operator=(const InvertedQuery_ &); | |
| /** Copy constructor. */ | | | |
| Internal(const Query::Internal & copyme); | | | |
| | | | |
|
| /** Assignment. */ | | InvertedQuery_(const Query & query_) : query(query_) { } | |
| void operator=(const Query::Internal & copyme); | | | |
| | | | |
|
| /** A query consisting of a single term. */ | | public: | |
| explicit Internal(const std::string & tname_, Xapian::termcount wqf_ | | // GCC 4.2 seems to needs a copy ctor. | |
| = 1, | | InvertedQuery_(const InvertedQuery_ & o) : query(o.query) { } | |
| Xapian::termpos term_pos_ = 0); | | | |
| | | | |
|
| /** Create internals given only the operator and a parameter. */ | | operator Query() const { | |
| Internal(op_t op_, Xapian::termcount parameter); | | return Query(Query::OP_AND_NOT, Query::MatchAll, query); | |
| | | } | |
| | | | |
|
| /** Construct a range query on a document value. */ | | friend const InvertedQuery_ operator~(const Query &q); | |
| Internal(op_t op_, Xapian::valueno slot, | | | |
| const std::string &begin, const std::string &end); | | | |
| | | | |
|
| /** Construct a value greater-than-or-equal query on a document valu | | friend const Query operator&(const Query & a, const InvertedQuery_ & b) | |
| e. | | ; | |
| */ | | }; | |
| Internal(op_t op_, Xapian::valueno slot, const std::string &value); | | | |
| | | | |
|
| /// Construct an external source query. | | inline const Query | |
| explicit Internal(Xapian::PostingSource * external_source_, bool own | | operator&(const Query & a, const InvertedQuery_ & b) | |
| ed); | | { | |
| | | return Query(Query::OP_AND_NOT, a, b.query); | |
| | | } | |
| | | | |
|
| /** Destructor. */ | | inline const InvertedQuery_ | |
| ~Internal(); | | operator~(const Query &q) | |
| | | { | |
| | | return InvertedQuery_(q); | |
| | | } | |
| | | | |
|
| static Xapian::Query::Internal * unserialise(const std::string &s, | | namespace Internal { | |
| const Registry & regist | | class AndContext; | |
| ry); | | class OrContext; | |
| | | class XorContext; | |
| | | } | |
| | | | |
|
| /** Add a subquery. */ | | class Query::Internal : public Xapian::Internal::intrusive_base { | |
| void add_subquery(const Query::Internal * subq); | | public: | |
| | | Internal() { } | |
| | | | |
|
| /** Add a subquery without copying it. | | virtual ~Internal(); | |
| * | | | |
| * subq is owned by the object this is called on after the call. | | | |
| */ | | | |
| void add_subquery_nocopy(Query::Internal * subq); | | | |
| | | | |
|
| void set_dbl_parameter(double dbl_parameter_); | | virtual PostingIterator::Internal * postlist(QueryOptimiser * qopt, dou
ble factor) const = 0; | |
| | | | |
|
| double get_dbl_parameter() const; | | virtual void postlist_sub_and_like(Xapian::Internal::AndContext& ctx, | |
| | | QueryOptimiser * qopt, | |
| | | double factor) const; | |
| | | | |
|
| /** Finish off the construction. | | virtual void postlist_sub_or_like(Xapian::Internal::OrContext& ctx, | |
| */ | | QueryOptimiser * qopt, | |
| Query::Internal * end_construction(); | | double factor) const; | |
| | | | |
|
| /** Return a string in an easily parsed form | | virtual void postlist_sub_xor(Xapian::Internal::XorContext& ctx, | |
| * which contains all the information in a query. | | QueryOptimiser * qopt, | |
| */ | | double factor) const; | |
| std::string serialise() const { | | | |
| Xapian::termpos curpos = 1; | | | |
| return serialise(curpos); | | | |
| } | | | |
| | | | |
|
| /// Return a string describing this object. | | virtual termcount get_length() const; | |
| std::string get_description() const; | | | |
| | | | |
|
| /** Get the numeric parameter used in this query. | | virtual void serialise(std::string & result) const = 0; | |
| * | | | |
| * This is used by the QueryParser to get the value number for | | | |
| * VALUE_RANGE queries. It should be replaced by a public method o | | | |
| n | | | |
| * the Query class at some point, but the API which should be used | | | |
| for | | | |
| * that is unclear, so this is a temporary workaround. | | | |
| */ | | | |
| Xapian::termcount get_parameter() const { return parameter; } | | | |
| | | | |
|
| Xapian::termcount get_wqf() const { return parameter; } | | static Query::Internal * unserialise(const char ** p, const char * end,
const Registry & reg); | |
| | | | |
|
| /** Get the length of the query, used by some ranking formulae. | | virtual std::string get_description() const = 0; | |
| * This value is calculated automatically - if you want to override | | | |
| * it you can pass a different value to Enquire::set_query(). | | | |
| */ | | | |
| Xapian::termcount get_length() const; | | | |
| | | | |
|
| /** Return an iterator over all the terms in the query, | | virtual void gather_terms(std::vector<std::pair<Xapian::termpos, std::s | |
| * in order of termpos. If multiple terms have the same term | | tring> > &terms) const; | |
| * position, their order is unspecified. Duplicates (same term and | | | |
| * termpos) will be removed. | | | |
| */ | | | |
| TermIterator get_terms() const; | | | |
| }; | | }; | |
| | | | |
|
| #endif // SWIG | | | |
| | | | |
| } | | } | |
| | | | |
|
| #endif /* XAPIAN_INCLUDED_QUERY_H */ | | #endif // XAPIAN_INCLUDED_QUERY_H | |
| | | | |
End of changes. 61 change blocks. |
| 517 lines changed or deleted | | 293 lines changed or added | |
|
| queryparser.h | | queryparser.h | |
|
| /** \file queryparser.h | | /** @file queryparser.h | |
| * \brief parsing a user query string to build a Xapian::Query object | | * @brief parsing a user query string to build a Xapian::Query object | |
| */ | | */ | |
|
| /* Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2014 Olly Betts | | /* Copyright (C) 2005,2006,2007,2008,2009,2010,2011,2012 Olly Betts | |
| * Copyright (C) 2010 Adam Sjøgren | | * Copyright (C) 2010 Adam Sjøgren | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| * License, or (at your option) any later version. | | * License, or (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 26 | | skipping to change at line 26 | |
| * | | * | |
| * You should have received a copy of the GNU General Public License | | * You should have received a copy of the GNU General Public License | |
| * along with this program; if not, write to the Free Software | | * along with this program; if not, write to the Free Software | |
| * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 | |
| * USA | | * USA | |
| */ | | */ | |
| | | | |
| #ifndef XAPIAN_INCLUDED_QUERYPARSER_H | | #ifndef XAPIAN_INCLUDED_QUERYPARSER_H | |
| #define XAPIAN_INCLUDED_QUERYPARSER_H | | #define XAPIAN_INCLUDED_QUERYPARSER_H | |
| | | | |
|
| #include <xapian/base.h> | | #include <xapian/intrusive_ptr.h> | |
| #include <xapian/query.h> | | #include <xapian/query.h> | |
| #include <xapian/termiterator.h> | | #include <xapian/termiterator.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
| #include <set> | | #include <set> | |
| #include <string> | | #include <string> | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
| class Database; | | class Database; | |
| | | | |
| skipping to change at line 63 | | skipping to change at line 63 | |
| }; | | }; | |
| | | | |
| /// Simple implementation of Stopper class - this will suit most users. | | /// Simple implementation of Stopper class - this will suit most users. | |
| class XAPIAN_VISIBILITY_DEFAULT SimpleStopper : public Stopper { | | class XAPIAN_VISIBILITY_DEFAULT SimpleStopper : public Stopper { | |
| std::set<std::string> stop_words; | | std::set<std::string> stop_words; | |
| | | | |
| public: | | public: | |
| /// Default constructor. | | /// Default constructor. | |
| SimpleStopper() { } | | SimpleStopper() { } | |
| | | | |
|
| /** Initialise from a pair of iterators. | | /// Initialise from a pair of iterators. | |
| * | | | |
| * Xapian includes stop list files for many languages. You can initiali | | | |
| se from a file like that: | | | |
| * @code | | | |
| * ifstream inFile ("stopwords/english/stop.txt"); | | | |
| * Xapian::SimplerStopper stopper(istream_iterator<string>(inFile), ist | | | |
| ream_iterator<string>()); | | | |
| * @endcode | | | |
| * | | | |
| */ | | | |
| #if ! defined __SUNPRO_CC || __SUNPRO_CC - 0 >= 0x580 | | #if ! defined __SUNPRO_CC || __SUNPRO_CC - 0 >= 0x580 | |
| template <class Iterator> | | template <class Iterator> | |
| SimpleStopper(Iterator begin, Iterator end) : stop_words(begin, end) {
} | | SimpleStopper(Iterator begin, Iterator end) : stop_words(begin, end) {
} | |
| #else | | #else | |
| // Older versions of Sun's C++ compiler don't cope with the Iterator | | // Older versions of Sun's C++ compiler don't cope with the Iterator | |
| // pointing to const char *. | | // pointing to const char *. | |
| template <class Iterator> | | template <class Iterator> | |
| SimpleStopper(Iterator begin, Iterator end) { | | SimpleStopper(Iterator begin, Iterator end) { | |
| while (begin != end) stop_words.insert(*begin++); | | while (begin != end) stop_words.insert(*begin++); | |
| } | | } | |
| | | | |
| skipping to change at line 232 | | skipping to change at line 224 | |
| * For example, if str_ is "created:" and prefix_ is true, and the ran
ge | | * For example, if str_ is "created:" and prefix_ is true, and the ran
ge | |
| * processor has been added to the queryparser, the queryparser will | | * processor has been added to the queryparser, the queryparser will | |
| * accept "created:1/1/2000..31/12/2001". | | * accept "created:1/1/2000..31/12/2001". | |
| */ | | */ | |
| DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, | | DateValueRangeProcessor(Xapian::valueno slot_, const std::string &str_, | |
| bool prefix_ = true, | | bool prefix_ = true, | |
| bool prefer_mdy_ = false, int epoch_year_ = 1970
) | | bool prefer_mdy_ = false, int epoch_year_ = 1970
) | |
| : StringValueRangeProcessor(slot_, str_, prefix_), | | : StringValueRangeProcessor(slot_, str_, prefix_), | |
| prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } | | prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } | |
| | | | |
|
| #ifndef SWIG | | | |
| /** Constructor. | | | |
| * | | | |
| * This is like the previous version, but with const char * instead of | | | |
| * std::string - we need this overload as otherwise | | | |
| * DateValueRangeProcessor(1, "date:") quietly interprets the second | | | |
| * argument as a boolean in preference to std::string. If you want to | | | |
| * be compatible with 1.2.12 and earlier, then explicitly convert to | | | |
| * std::string, i.e.: DateValueRangeProcessor(1, std::string("date:")) | | | |
| * | | | |
| * @param slot_ The value number to return from operator(). | | | |
| * | | | |
| * @param str_ A string to look for to recognise values as belongi | | | |
| ng | | | |
| * to this date range. | | | |
| * | | | |
| * @param prefix_ Whether to look for the string at the start or end | | | |
| of | | | |
| * the values. If true, the string is a prefix; if | | | |
| * false, the string is a suffix (default: true). | | | |
| * | | | |
| * @param prefer_mdy_ Should ambiguous dates be interpreted as | | | |
| * month/day/year rather than day/month/year? | | | |
| * (default: false) | | | |
| * | | | |
| * @param epoch_year_ Year to use as the epoch for dates with 2 digit | | | |
| * years (default: 1970, so 1/1/69 is 2069 while | | | |
| * 1/1/70 is 1970). | | | |
| * | | | |
| * The string supplied in str_ is used by @a operator() to decide whet | | | |
| her | | | |
| * the pair of strings supplied to it constitute a valid range. If | | | |
| * prefix_ is true, the first value in a range must begin with str_ (a | | | |
| nd | | | |
| * the second value may optionally begin with str_); | | | |
| * if prefix_ is false, the second value in a range must end with str_ | | | |
| * (and the first value may optionally end with str_). | | | |
| * | | | |
| * If str_ is empty, the setting of prefix_ is irrelevant, and no spec | | | |
| ial | | | |
| * strings are required at the start or end of the strings defining th | | | |
| e | | | |
| * range. | | | |
| * | | | |
| * The remainder of both strings defining the endpoints must be valid | | | |
| * dates. | | | |
| * | | | |
| * For example, if str_ is "created:" and prefix_ is true, and the ran | | | |
| ge | | | |
| * processor has been added to the queryparser, the queryparser will | | | |
| * accept "created:1/1/2000..31/12/2001". | | | |
| */ | | | |
| DateValueRangeProcessor(Xapian::valueno slot_, const char * str_, | | | |
| bool prefix_ = true, | | | |
| bool prefer_mdy_ = false, int epoch_year_ = 1970 | | | |
| ) | | | |
| : StringValueRangeProcessor(slot_, str_, prefix_), | | | |
| prefer_mdy(prefer_mdy_), epoch_year(epoch_year_) { } | | | |
| #endif | | | |
| | | | |
| /** Check for a valid date range. | | /** Check for a valid date range. | |
| * | | * | |
| * @param[in,out] begin The start of the range as specified in the | | * @param[in,out] begin The start of the range as specified in the | |
| * query string by the user. This parameter is
a | | * query string by the user. This parameter is
a | |
| * non-const reference so the ValueRangeProcess
or | | * non-const reference so the ValueRangeProcess
or | |
| * can modify it to return the value to start t
he | | * can modify it to return the value to start t
he | |
| * range with. | | * range with. | |
| * @param[in,out] end The end of the range. This is also a non-co
nst | | * @param[in,out] end The end of the range. This is also a non-co
nst | |
| * reference so it can be modified. | | * reference so it can be modified. | |
| * | | * | |
| | | | |
| skipping to change at line 380 | | skipping to change at line 320 | |
| */ | | */ | |
| Xapian::valueno operator()(std::string &begin, std::string &end); | | Xapian::valueno operator()(std::string &begin, std::string &end); | |
| }; | | }; | |
| | | | |
| /// Build a Xapian::Query object from a user query string. | | /// Build a Xapian::Query object from a user query string. | |
| class XAPIAN_VISIBILITY_DEFAULT QueryParser { | | class XAPIAN_VISIBILITY_DEFAULT QueryParser { | |
| public: | | public: | |
| /// Class representing the queryparser internals. | | /// Class representing the queryparser internals. | |
| class Internal; | | class Internal; | |
| /// @private @internal Reference counted internals. | | /// @private @internal Reference counted internals. | |
|
| Xapian::Internal::RefCntPtr<Internal> internal; | | Xapian::Internal::intrusive_ptr<Internal> internal; | |
| | | | |
| /// Enum of feature flags. | | /// Enum of feature flags. | |
| typedef enum { | | typedef enum { | |
| /// Support AND, OR, etc and bracketed subexpressions. | | /// Support AND, OR, etc and bracketed subexpressions. | |
| FLAG_BOOLEAN = 1, | | FLAG_BOOLEAN = 1, | |
| /// Support quoted phrases. | | /// Support quoted phrases. | |
| FLAG_PHRASE = 2, | | FLAG_PHRASE = 2, | |
| /// Support + and -. | | /// Support + and -. | |
| FLAG_LOVEHATE = 4, | | FLAG_LOVEHATE = 4, | |
| /// Support AND, OR, etc even if they aren't in ALLCAPS. | | /// Support AND, OR, etc even if they aren't in ALLCAPS. | |
| FLAG_BOOLEAN_ANY_CASE = 8, | | FLAG_BOOLEAN_ANY_CASE = 8, | |
|
| /** Support wildcards. | | /** Support right truncation (e.g. Xap*). | |
| * | | | |
| * At present only right truncation (e.g. Xap*) is supported. | | | |
| * | | * | |
| * Currently you can't use wildcards with boolean filter prefixes, | | * Currently you can't use wildcards with boolean filter prefixes, | |
| * or in a phrase (either an explicitly quoted one, or one implicit
ly | | * or in a phrase (either an explicitly quoted one, or one implicit
ly | |
| * generated by hyphens or other punctuation). | | * generated by hyphens or other punctuation). | |
| * | | * | |
| * NB: You need to tell the QueryParser object which database to | | * NB: You need to tell the QueryParser object which database to | |
| * expand wildcards from by calling set_database. | | * expand wildcards from by calling set_database. | |
| */ | | */ | |
| FLAG_WILDCARD = 16, | | FLAG_WILDCARD = 16, | |
| /** Allow queries such as 'NOT apples'. | | /** Allow queries such as 'NOT apples'. | |
| | | | |
| skipping to change at line 462 | | skipping to change at line 400 | |
| * | | * | |
| * NB: You must also call set_database() for this to work. | | * NB: You must also call set_database() for this to work. | |
| */ | | */ | |
| FLAG_AUTO_SYNONYMS = 512, | | FLAG_AUTO_SYNONYMS = 512, | |
| | | | |
| /** Enable automatic use of synonyms for single terms and groups of | | /** Enable automatic use of synonyms for single terms and groups of | |
| * terms. | | * terms. | |
| * | | * | |
| * NB: You must also call set_database() for this to work. | | * NB: You must also call set_database() for this to work. | |
| */ | | */ | |
|
| FLAG_AUTO_MULTIWORD_SYNONYMS = 1024 | FLAG_AUTO_SYNONYMS, | | FLAG_AUTO_MULTIWORD_SYNONYMS = 1024, | |
| | | | |
| /** The default flags. | | /** The default flags. | |
| * | | * | |
| * Used if you don't explicitly pass any to @a parse_query(). | | * Used if you don't explicitly pass any to @a parse_query(). | |
| * The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE. | | * The default flags are FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE. | |
| * | | * | |
| * Added in Xapian 1.0.11. | | * Added in Xapian 1.0.11. | |
| */ | | */ | |
| FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE | | FLAG_DEFAULT = FLAG_PHRASE|FLAG_BOOLEAN|FLAG_LOVEHATE | |
| } feature_flag; | | } feature_flag; | |
| | | | |
|
| /// Stemming strategies, for use with set_stemming_strategy(). | | typedef enum { STEM_NONE, STEM_SOME, STEM_ALL } stem_strategy; | |
| typedef enum { STEM_NONE, STEM_SOME, STEM_ALL, STEM_ALL_Z } stem_strate | | | |
| gy; | | | |
| | | | |
| /// Copy constructor. | | /// Copy constructor. | |
| QueryParser(const QueryParser & o); | | QueryParser(const QueryParser & o); | |
| | | | |
| /// Assignment. | | /// Assignment. | |
| QueryParser & operator=(const QueryParser & o); | | QueryParser & operator=(const QueryParser & o); | |
| | | | |
| /// Default constructor. | | /// Default constructor. | |
| QueryParser(); | | QueryParser(); | |
| | | | |
| | | | |
| skipping to change at line 508 | | skipping to change at line 445 | |
| */ | | */ | |
| void set_stemmer(const Xapian::Stem & stemmer); | | void set_stemmer(const Xapian::Stem & stemmer); | |
| | | | |
| /** Set the stemming strategy. | | /** Set the stemming strategy. | |
| * | | * | |
| * This controls how the query parser will apply the stemming algorith
m. | | * This controls how the query parser will apply the stemming algorith
m. | |
| * Note that the stemming algorithm is only applied to words in | | * Note that the stemming algorithm is only applied to words in | |
| * probabilistic fields - boolean filter terms are never stemmed. | | * probabilistic fields - boolean filter terms are never stemmed. | |
| * | | * | |
| * @param strategy The strategy to use - possible values are: | | * @param strategy The strategy to use - possible values are: | |
|
| * - STEM_NONE: Don't perform any stemming. (default in Xapian <= | | * - STEM_NONE: Don't perform any stemming (the default). | |
| * 1.3.0) | | * - STEM_SOME: Search for stemmed forms of terms except for those wh | |
| * - STEM_SOME: Stem all terms except for those which start with a | | ich | |
| * capital letter, or are followed by certain character | | * start with a capital letter, or are followed by certai | |
| s | | n | |
| * (currently: <code>(/\@<>=*[{"</code> ), or are used | | * characters (currently: (/\@<>=*[{" ), or are used with | |
| * with operators which need positional information. | | * operators which need positional information. Stemmed | |
| * Stemmed terms are prefixed with 'Z'. (default in | | * terms are prefixed with 'Z'. | |
| * Xapian >= 1.3.1) | | * - STEM_ALL: Search for stemmed forms of all words (note: no 'Z' | |
| * - STEM_ALL: Stem all terms (note: no 'Z' prefix is added). | | * prefix is added). | |
| * - STEM_ALL_Z: Stem all terms (note: 'Z' prefix is added). (new in | | | |
| * Xapian 1.2.11 and 1.3.1) | | | |
| */ | | */ | |
| void set_stemming_strategy(stem_strategy strategy); | | void set_stemming_strategy(stem_strategy strategy); | |
| | | | |
| /** Set the stopper. | | /** Set the stopper. | |
| * | | * | |
| * @param stop The Stopper object to set (default NULL, which means
no | | * @param stop The Stopper object to set (default NULL, which means
no | |
| * stopwords). | | * stopwords). | |
| */ | | */ | |
| void set_stopper(const Stopper *stop = NULL); | | void set_stopper(const Stopper *stop = NULL); | |
| | | | |
| /** Set the default operator. | | /** Set the default operator. | |
| * | | * | |
| * @param default_op The operator to use to combine non-filter | | * @param default_op The operator to use to combine non-filter | |
| * query items when no explicit operator is use
d. | | * query items when no explicit operator is use
d. | |
| * | | * | |
|
| * The most useful values for this are OP_OR (t | | | |
| he | | | |
| * default) and OP_AND. OP_NEAR and OP_PHRASE | | | |
| can | | | |
| * also be useful. | | | |
| * | | | |
| * So for example, 'weather forecast' is parsed
as | | * So for example, 'weather forecast' is parsed
as | |
| * if it were 'weather OR forecast' by default. | | * if it were 'weather OR forecast' by default. | |
|
| | | * | |
| | | * The most useful values for this are OP_OR (t | |
| | | he | |
| | | * default) and OP_AND. OP_NEAR, OP_PHRASE, | |
| | | * OP_ELITE_SET and OP_SYNONYM are also permitt | |
| | | ed. | |
| | | * Passing other values will result in | |
| | | * InvalidArgumentError being thrown. | |
| */ | | */ | |
| void set_default_op(Query::op default_op); | | void set_default_op(Query::op default_op); | |
| | | | |
| /** Get the current default operator. */ | | /** Get the current default operator. */ | |
| Query::op get_default_op() const; | | Query::op get_default_op() const; | |
| | | | |
| /** Specify the database being searched. | | /** Specify the database being searched. | |
| * | | * | |
| * @param db The database to use for wildcard expansion | | * @param db The database to use for wildcard expansion | |
| * (FLAG_WILDCARD and FLAG_PARTIAL), spelling correctio
n | | * (FLAG_WILDCARD and FLAG_PARTIAL), spelling correctio
n | |
| | | | |
| skipping to change at line 579 | | skipping to change at line 515 | |
| * multiple values with bitwise-or (|) (default FLAG_DEFAULT). | | * multiple values with bitwise-or (|) (default FLAG_DEFAULT). | |
| * @param default_prefix The default term prefix to use (default none)
. | | * @param default_prefix The default term prefix to use (default none)
. | |
| * For example, you can pass "A" when parsing an "Author" field
. | | * For example, you can pass "A" when parsing an "Author" field
. | |
| * | | * | |
| * @exception If the query string can't be parsed, then | | * @exception If the query string can't be parsed, then | |
| * Xapian::QueryParserError is thrown. You can get an Engli
sh | | * Xapian::QueryParserError is thrown. You can get an Engli
sh | |
| * error message to report to the user by catching it and | | * error message to report to the user by catching it and | |
| * calling get_msg() on the caught exception. The current | | * calling get_msg() on the caught exception. The current | |
| * possible values (in case you want to translate them) are: | | * possible values (in case you want to translate them) are: | |
| * | | * | |
|
| * @li Unknown range operation | | * @li Unknown range operation | |
| * @li parse error | | * @li parse error | |
| * @li Syntax: <expression> AND <expression> | | * @li Syntax: <expression> AND <expression> | |
| * @li Syntax: <expression> AND NOT <expression> | | ; | |
| * @li Syntax: <expression> NOT <expression> | | * @li Syntax: <expression> AND NOT <expressio | |
| * @li Syntax: <expression> OR <expression> | | n> | |
| * @li Syntax: <expression> XOR <expression> | | * @li Syntax: <expression> NOT <expression> | |
| | | ; | |
| | | * @li Syntax: <expression> OR <expression> | |
| | | * @li Syntax: <expression> XOR <expression> | |
| | | ; | |
| */ | | */ | |
| Query parse_query(const std::string &query_string, | | Query parse_query(const std::string &query_string, | |
| unsigned flags = FLAG_DEFAULT, | | unsigned flags = FLAG_DEFAULT, | |
| const std::string &default_prefix = std::string()); | | const std::string &default_prefix = std::string()); | |
| | | | |
| /** Add a probabilistic term prefix. | | /** Add a probabilistic term prefix. | |
| * | | * | |
| * For example: | | * For example: | |
| * | | * | |
| * @code | | * @code | |
| | | | |
| skipping to change at line 685 | | skipping to change at line 621 | |
| * @param prefix The term prefix to map this to | | * @param prefix The term prefix to map this to | |
| * @param exclusive If true, each document can have at most one term w
ith | | * @param exclusive If true, each document can have at most one term w
ith | |
| * this prefix, so multiple filters with this prefix | | * this prefix, so multiple filters with this prefix | |
| * should be combined with OP_OR. If false, each | | * should be combined with OP_OR. If false, each | |
| * document can have multiple terms with this prefix,
so | | * document can have multiple terms with this prefix,
so | |
| * multiple filters should be combined with OP_AND, li
ke | | * multiple filters should be combined with OP_AND, li
ke | |
| * happens with filters with different prefixes. | | * happens with filters with different prefixes. | |
| * [default: true] | | * [default: true] | |
| */ | | */ | |
| void add_boolean_prefix(const std::string &field, const std::string &pr
efix, | | void add_boolean_prefix(const std::string &field, const std::string &pr
efix, | |
|
| bool exclusive); | | bool exclusive = true); | |
| | | | |
| /* FIXME:1.3: Merge two versions into one with optional parameter | | | |
| * "exclusive", default true. */ | | | |
| void add_boolean_prefix(const std::string &field, const std::string &pr | | | |
| efix); | | | |
| | | | |
| /// Iterate over terms omitted from the query as stopwords. | | /// Iterate over terms omitted from the query as stopwords. | |
| TermIterator stoplist_begin() const; | | TermIterator stoplist_begin() const; | |
| TermIterator stoplist_end() const { | | TermIterator stoplist_end() const { | |
| return TermIterator(); | | return TermIterator(); | |
| } | | } | |
| | | | |
| /// Iterate over unstemmed forms of the given (stemmed) term used in th
e query. | | /// Iterate over unstemmed forms of the given (stemmed) term used in th
e query. | |
| TermIterator unstem_begin(const std::string &term) const; | | TermIterator unstem_begin(const std::string &term) const; | |
| TermIterator unstem_end(const std::string &) const { | | TermIterator unstem_end(const std::string &) const { | |
| | | | |
End of changes. 14 change blocks. |
| 114 lines changed or deleted | | 39 lines changed or added | |
|
| weight.h | | weight.h | |
| /** @file weight.h | | /** @file weight.h | |
| * @brief Weighting scheme API. | | * @brief Weighting scheme API. | |
| */ | | */ | |
|
| /* Copyright (C) 2007,2008,2009,2010,2011,2012,2014 Olly Betts | | /* Copyright (C) 2007,2008,2009,2010,2011,2012 Olly Betts | |
| * Copyright (C) 2009 Lemur Consulting Ltd | | * Copyright (C) 2009 Lemur Consulting Ltd | |
| * | | * | |
| * This program is free software; you can redistribute it and/or | | * This program is free software; you can redistribute it and/or | |
| * modify it under the terms of the GNU General Public License as | | * modify it under the terms of the GNU General Public License as | |
| * published by the Free Software Foundation; either version 2 of the | | * published by the Free Software Foundation; either version 2 of the | |
| * License, or (at your option) any later version. | | * License, or (at your option) any later version. | |
| * | | * | |
| * This program is distributed in the hope that it will be useful, | | * This program is distributed in the hope that it will be useful, | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| | | | |
| skipping to change at line 37 | | skipping to change at line 37 | |
| #include <xapian/types.h> | | #include <xapian/types.h> | |
| #include <xapian/visibility.h> | | #include <xapian/visibility.h> | |
| | | | |
| namespace Xapian { | | namespace Xapian { | |
| | | | |
| /** Abstract base class for weighting schemes. */ | | /** Abstract base class for weighting schemes. */ | |
| class XAPIAN_VISIBILITY_DEFAULT Weight { | | class XAPIAN_VISIBILITY_DEFAULT Weight { | |
| protected: | | protected: | |
| /// Stats which the weighting scheme can use (see @a need_stat()). | | /// Stats which the weighting scheme can use (see @a need_stat()). | |
| typedef enum { | | typedef enum { | |
|
| /// Number of documents in the collection. | | | |
| COLLECTION_SIZE = 1, | | COLLECTION_SIZE = 1, | |
|
| /// Number of documents in the RSet. | | | |
| RSET_SIZE = 2, | | RSET_SIZE = 2, | |
|
| /// Average length of documents in the collection. | | | |
| AVERAGE_LENGTH = 4, | | AVERAGE_LENGTH = 4, | |
|
| /// How many documents the current term is in. | | | |
| TERMFREQ = 8, | | TERMFREQ = 8, | |
|
| /// How many documents in the RSet the current term is in. | | | |
| RELTERMFREQ = 16, | | RELTERMFREQ = 16, | |
|
| /// Sum of wqf for terms in the query. | | | |
| QUERY_LENGTH = 32, | | QUERY_LENGTH = 32, | |
|
| /// Within-query-frequency of the current term. | | | |
| WQF = 64, | | WQF = 64, | |
|
| /// Within-document-frequency of the current term in the current doc
ument. | | | |
| WDF = 128, | | WDF = 128, | |
|
| /// Length of the current document (sum wdf). | | | |
| DOC_LENGTH = 256, | | DOC_LENGTH = 256, | |
|
| /// Lower bound on (non-zero) document lengths. | | | |
| DOC_LENGTH_MIN = 512, | | DOC_LENGTH_MIN = 512, | |
|
| /// Upper bound on document lengths. | | | |
| DOC_LENGTH_MAX = 1024, | | DOC_LENGTH_MAX = 1024, | |
|
| /// Upper bound on wdf. | | | |
| WDF_MAX = 2048 | | WDF_MAX = 2048 | |
| } stat_flags; | | } stat_flags; | |
| | | | |
| /** Tell Xapian that your subclass will want a particular statistic. | | /** Tell Xapian that your subclass will want a particular statistic. | |
| * | | * | |
| * Some of the statistics can be costly to fetch or calculate, so | | * Some of the statistics can be costly to fetch or calculate, so | |
| * Xapian needs to know which are actually going to be used. You | | * Xapian needs to know which are actually going to be used. You | |
| * should call need_stat() from your constructor for each such | | * should call need_stat() from your constructor for each such | |
| * statistic. | | * statistic. | |
| * | | * | |
| * @param flag The stat_flags value for a required statistic. | | * @param flag The stat_flags value for a required statistic. | |
| */ | | */ | |
| void need_stat(stat_flags flag) { | | void need_stat(stat_flags flag) { | |
| stats_needed = stat_flags(stats_needed | flag); | | stats_needed = stat_flags(stats_needed | flag); | |
| } | | } | |
| | | | |
| /** Allow the subclass to perform any initialisation it needs to. | | /** Allow the subclass to perform any initialisation it needs to. | |
| * | | * | |
| * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). | | * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). | |
|
| * If the Weight object is for the term-independent | | | |
| * weight supplied by get_sumextra()/get_maxextra(), | | | |
| * then init(0.0) is called (starting from Xapian | | | |
| * 1.2.11 and 1.3.1 - earlier versions failed to | | | |
| * call init() for such Weight objects). | | | |
| */ | | */ | |
| virtual void init(double factor) = 0; | | virtual void init(double factor) = 0; | |
| | | | |
| private: | | private: | |
| /// Don't allow assignment. | | /// Don't allow assignment. | |
| void operator=(const Weight &); | | void operator=(const Weight &); | |
| | | | |
| /// A bitmask of the statistics this weighting scheme needs. | | /// A bitmask of the statistics this weighting scheme needs. | |
| stat_flags stats_needed; | | stat_flags stats_needed; | |
| | | | |
| | | | |
| skipping to change at line 115 | | skipping to change at line 98 | |
| | | | |
| /// The number of relevant documents which this term indexes. | | /// The number of relevant documents which this term indexes. | |
| Xapian::doccount reltermfreq_; | | Xapian::doccount reltermfreq_; | |
| | | | |
| /// The length of the query. | | /// The length of the query. | |
| Xapian::termcount query_length_; | | Xapian::termcount query_length_; | |
| | | | |
| /// The within-query-frequency of this term. | | /// The within-query-frequency of this term. | |
| Xapian::termcount wqf_; | | Xapian::termcount wqf_; | |
| | | | |
|
| /// A lower bound on the minimum length of any document in the database
. | | /// An lower bound on the maximum length of any document in the databas
e. | |
| Xapian::termcount doclength_lower_bound_; | | Xapian::termcount doclength_lower_bound_; | |
| | | | |
| /// An upper bound on the maximum length of any document in the databas
e. | | /// An upper bound on the maximum length of any document in the databas
e. | |
| Xapian::termcount doclength_upper_bound_; | | Xapian::termcount doclength_upper_bound_; | |
| | | | |
| /// An upper bound on the wdf of this term. | | /// An upper bound on the wdf of this term. | |
| Xapian::termcount wdf_upper_bound_; | | Xapian::termcount wdf_upper_bound_; | |
| | | | |
| public: | | public: | |
| class Internal; | | class Internal; | |
| | | | |
| skipping to change at line 197 | | skipping to change at line 180 | |
| virtual Weight * unserialise(const std::string & s) const; | | virtual Weight * unserialise(const std::string & s) const; | |
| | | | |
| /** Calculate the weight contribution for this object's term to a docum
ent. | | /** Calculate the weight contribution for this object's term to a docum
ent. | |
| * | | * | |
| * The parameters give information about the document which may be use
d | | * The parameters give information about the document which may be use
d | |
| * in the calculations: | | * in the calculations: | |
| * | | * | |
| * @param wdf The within document frequency of the term in the docu
ment. | | * @param wdf The within document frequency of the term in the docu
ment. | |
| * @param doclen The document's length (unnormalised). | | * @param doclen The document's length (unnormalised). | |
| */ | | */ | |
|
| virtual Xapian::weight get_sumpart(Xapian::termcount wdf, | | virtual double get_sumpart(Xapian::termcount wdf, | |
| Xapian::termcount doclen) const = 0; | | Xapian::termcount doclen) const = 0; | |
| | | | |
| /** Return an upper bound on what get_sumpart() can return for any docu
ment. | | /** Return an upper bound on what get_sumpart() can return for any docu
ment. | |
| * | | * | |
| * This information is used by the matcher to perform various | | * This information is used by the matcher to perform various | |
| * optimisations, so strive to make the bound as tight as possible. | | * optimisations, so strive to make the bound as tight as possible. | |
| */ | | */ | |
|
| virtual Xapian::weight get_maxpart() const = 0; | | virtual double get_maxpart() const = 0; | |
| | | | |
| /** Calculate the term-independent weight component for a document. | | /** Calculate the term-independent weight component for a document. | |
| * | | * | |
| * The parameter gives information about the document which may be use
d | | * The parameter gives information about the document which may be use
d | |
| * in the calculations: | | * in the calculations: | |
| * | | * | |
| * @param doclen The document's length (unnormalised). | | * @param doclen The document's length (unnormalised). | |
| */ | | */ | |
|
| virtual Xapian::weight get_sumextra(Xapian::termcount doclen) const = 0
; | | virtual double get_sumextra(Xapian::termcount doclen) const = 0; | |
| | | | |
| /** Return an upper bound on what get_sumextra() can return for any | | /** Return an upper bound on what get_sumextra() can return for any | |
| * document. | | * document. | |
| * | | * | |
| * This information is used by the matcher to perform various | | * This information is used by the matcher to perform various | |
| * optimisations, so strive to make the bound as tight as possible. | | * optimisations, so strive to make the bound as tight as possible. | |
| */ | | */ | |
|
| virtual Xapian::weight get_maxextra() const = 0; | | virtual double get_maxextra() const = 0; | |
| | | | |
| /** @private @internal Initialise this object to calculate weights for
term | | /** @private @internal Initialise this object to calculate weights for
term | |
| * @a term. | | * @a term. | |
| * | | * | |
| * @param stats Source of statistics. | | * @param stats Source of statistics. | |
| * @param query_len_ Query length. | | * @param query_len_ Query length. | |
| * @param term The term for the new object. | | * @param term The term for the new object. | |
| * @param wqf_ The within-query-frequency of @a term. | | * @param wqf_ The within-query-frequency of @a term. | |
| * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). | | * @param factor Any scaling factor (e.g. from OP_SCALE_WEIGHT). | |
| */ | | */ | |
| | | | |
| skipping to change at line 309 | | skipping to change at line 292 | |
| | | | |
| /// The number of relevant documents which this term indexes. | | /// The number of relevant documents which this term indexes. | |
| Xapian::doccount get_reltermfreq() const { return reltermfreq_; } | | Xapian::doccount get_reltermfreq() const { return reltermfreq_; } | |
| | | | |
| /// The length of the query. | | /// The length of the query. | |
| Xapian::termcount get_query_length() const { return query_length_; } | | Xapian::termcount get_query_length() const { return query_length_; } | |
| | | | |
| /// The within-query-frequency of this term. | | /// The within-query-frequency of this term. | |
| Xapian::termcount get_wqf() const { return wqf_; } | | Xapian::termcount get_wqf() const { return wqf_; } | |
| | | | |
|
| /** An upper bound on the maximum length of any document in the databas
e. | | /** An lower bound on the maximum length of any document in the databas
e. | |
| * | | * | |
| * This should only be used by get_maxpart() and get_maxextra(). | | * This should only be used by get_maxpart() and get_maxextra(). | |
| */ | | */ | |
| Xapian::termcount get_doclength_upper_bound() const { | | Xapian::termcount get_doclength_upper_bound() const { | |
| return doclength_upper_bound_; | | return doclength_upper_bound_; | |
| } | | } | |
| | | | |
|
| /** A lower bound on the minimum length of any document in the database | | /** An upper bound on the maximum length of any document in the databas | |
| . | | e. | |
| * | | | |
| * This bound does not include any zero-length documents. | | | |
| * | | * | |
| * This should only be used by get_maxpart() and get_maxextra(). | | * This should only be used by get_maxpart() and get_maxextra(). | |
| */ | | */ | |
| Xapian::termcount get_doclength_lower_bound() const { | | Xapian::termcount get_doclength_lower_bound() const { | |
| return doclength_lower_bound_; | | return doclength_lower_bound_; | |
| } | | } | |
| | | | |
| /** An upper bound on the wdf of this term. | | /** An upper bound on the wdf of this term. | |
| * | | * | |
| * This should only be used by get_maxpart() and get_maxextra(). | | * This should only be used by get_maxpart() and get_maxextra(). | |
| | | | |
| skipping to change at line 354 | | skipping to change at line 335 | |
| | | | |
| public: | | public: | |
| /** Construct a BoolWeight. */ | | /** Construct a BoolWeight. */ | |
| BoolWeight() { } | | BoolWeight() { } | |
| | | | |
| std::string name() const; | | std::string name() const; | |
| | | | |
| std::string serialise() const; | | std::string serialise() const; | |
| BoolWeight * unserialise(const std::string & s) const; | | BoolWeight * unserialise(const std::string & s) const; | |
| | | | |
|
| Xapian::weight get_sumpart(Xapian::termcount wdf, | | double get_sumpart(Xapian::termcount wdf, | |
| Xapian::termcount doclen) const; | | Xapian::termcount doclen) const; | |
| Xapian::weight get_maxpart() const; | | double get_maxpart() const; | |
| | | | |
|
| Xapian::weight get_sumextra(Xapian::termcount doclen) const; | | double get_sumextra(Xapian::termcount doclen) const; | |
| Xapian::weight get_maxextra() const; | | double get_maxextra() const; | |
| }; | | }; | |
| | | | |
| /// Xapian::Weight subclass implementing the BM25 probabilistic formula. | | /// Xapian::Weight subclass implementing the BM25 probabilistic formula. | |
| class XAPIAN_VISIBILITY_DEFAULT BM25Weight : public Weight { | | class XAPIAN_VISIBILITY_DEFAULT BM25Weight : public Weight { | |
| /// Factor to multiply the document length by. | | /// Factor to multiply the document length by. | |
| mutable Xapian::doclength len_factor; | | mutable Xapian::doclength len_factor; | |
| | | | |
| /// Factor combining all the document independent factors. | | /// Factor combining all the document independent factors. | |
|
| mutable Xapian::weight termweight; | | mutable double termweight; | |
| | | | |
| /// The BM25 parameters. | | /// The BM25 parameters. | |
| double param_k1, param_k2, param_k3, param_b; | | double param_k1, param_k2, param_k3, param_b; | |
| | | | |
| /// The minimum normalised document length value. | | /// The minimum normalised document length value. | |
| Xapian::doclength param_min_normlen; | | Xapian::doclength param_min_normlen; | |
| | | | |
| BM25Weight * clone() const; | | BM25Weight * clone() const; | |
| | | | |
| void init(double factor); | | void init(double factor); | |
| | | | |
| skipping to change at line 426 | | skipping to change at line 407 | |
| param_b = 0; | | param_b = 0; | |
| } else if (param_b > 1) { | | } else if (param_b > 1) { | |
| param_b = 1; | | param_b = 1; | |
| } | | } | |
| need_stat(COLLECTION_SIZE); | | need_stat(COLLECTION_SIZE); | |
| need_stat(RSET_SIZE); | | need_stat(RSET_SIZE); | |
| need_stat(TERMFREQ); | | need_stat(TERMFREQ); | |
| need_stat(RELTERMFREQ); | | need_stat(RELTERMFREQ); | |
| need_stat(WDF); | | need_stat(WDF); | |
| need_stat(WDF_MAX); | | need_stat(WDF_MAX); | |
|
| | | need_stat(WDF); | |
| if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) { | | if (param_k2 != 0 || (param_k1 != 0 && param_b != 0)) { | |
| need_stat(DOC_LENGTH_MIN); | | need_stat(DOC_LENGTH_MIN); | |
| need_stat(AVERAGE_LENGTH); | | need_stat(AVERAGE_LENGTH); | |
| } | | } | |
| if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH); | | if (param_k1 != 0 && param_b != 0) need_stat(DOC_LENGTH); | |
| if (param_k2 != 0) need_stat(QUERY_LENGTH); | | if (param_k2 != 0) need_stat(QUERY_LENGTH); | |
| if (param_k3 != 0) need_stat(WQF); | | if (param_k3 != 0) need_stat(WQF); | |
| } | | } | |
| | | | |
| BM25Weight() | | BM25Weight() | |
| : param_k1(1), param_k2(0), param_k3(1), param_b(0.5), | | : param_k1(1), param_k2(0), param_k3(1), param_b(0.5), | |
| param_min_normlen(0.5) | | param_min_normlen(0.5) | |
| { | | { | |
| need_stat(COLLECTION_SIZE); | | need_stat(COLLECTION_SIZE); | |
| need_stat(RSET_SIZE); | | need_stat(RSET_SIZE); | |
| need_stat(TERMFREQ); | | need_stat(TERMFREQ); | |
| need_stat(RELTERMFREQ); | | need_stat(RELTERMFREQ); | |
| need_stat(WDF); | | need_stat(WDF); | |
| need_stat(WDF_MAX); | | need_stat(WDF_MAX); | |
|
| | | need_stat(WDF); | |
| need_stat(DOC_LENGTH_MIN); | | need_stat(DOC_LENGTH_MIN); | |
| need_stat(AVERAGE_LENGTH); | | need_stat(AVERAGE_LENGTH); | |
| need_stat(DOC_LENGTH); | | need_stat(DOC_LENGTH); | |
| need_stat(WQF); | | need_stat(WQF); | |
| } | | } | |
| | | | |
| std::string name() const; | | std::string name() const; | |
| | | | |
| std::string serialise() const; | | std::string serialise() const; | |
| BM25Weight * unserialise(const std::string & s) const; | | BM25Weight * unserialise(const std::string & s) const; | |
| | | | |
|
| Xapian::weight get_sumpart(Xapian::termcount wdf, | | double get_sumpart(Xapian::termcount wdf, | |
| Xapian::termcount doclen) const; | | Xapian::termcount doclen) const; | |
| Xapian::weight get_maxpart() const; | | double get_maxpart() const; | |
| | | | |
|
| Xapian::weight get_sumextra(Xapian::termcount doclen) const; | | double get_sumextra(Xapian::termcount doclen) const; | |
| Xapian::weight get_maxextra() const; | | double get_maxextra() const; | |
| }; | | }; | |
| | | | |
| /** Xapian::Weight subclass implementing the traditional probabilistic form
ula. | | /** Xapian::Weight subclass implementing the traditional probabilistic form
ula. | |
| * | | * | |
| * This class implements the "traditional" Probabilistic Weighting scheme,
as | | * This class implements the "traditional" Probabilistic Weighting scheme,
as | |
| * described by the early papers on Probabilistic Retrieval. BM25 generall
y | | * described by the early papers on Probabilistic Retrieval. BM25 generall
y | |
| * gives better results. | | * gives better results. | |
| * | | * | |
| * TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that | | * TradWeight(k) is equivalent to BM25Weight(k, 0, 0, 1, 0), except that | |
| * the latter returns weights (k+1) times larger. | | * the latter returns weights (k+1) times larger. | |
| */ | | */ | |
| class XAPIAN_VISIBILITY_DEFAULT TradWeight : public Weight { | | class XAPIAN_VISIBILITY_DEFAULT TradWeight : public Weight { | |
| /// Factor to multiply the document length by. | | /// Factor to multiply the document length by. | |
| mutable Xapian::doclength len_factor; | | mutable Xapian::doclength len_factor; | |
| | | | |
| /// Factor combining all the document independent factors. | | /// Factor combining all the document independent factors. | |
|
| mutable Xapian::weight termweight; | | mutable double termweight; | |
| | | | |
| /// The parameter in the formula. | | /// The parameter in the formula. | |
| double param_k; | | double param_k; | |
| | | | |
| TradWeight * clone() const; | | TradWeight * clone() const; | |
| | | | |
| void init(double factor); | | void init(double factor); | |
| | | | |
| public: | | public: | |
| /** Construct a TradWeight. | | /** Construct a TradWeight. | |
| * | | * | |
| * @param k A non-negative parameter controlling how influential | | * @param k A non-negative parameter controlling how influential | |
| * within-document-frequency (wdf) and document length are. | | * within-document-frequency (wdf) and document length are. | |
| * k=0 means that wdf and document length don't affect the | | * k=0 means that wdf and document length don't affect the | |
|
| * weights. The larger k is, the more they do. (default 1) | | * weights. The larger k1 is, the more they do. (default 1) | |
| */ | | */ | |
| explicit TradWeight(double k = 1.0) : param_k(k) { | | explicit TradWeight(double k = 1.0) : param_k(k) { | |
| if (param_k < 0) param_k = 0; | | if (param_k < 0) param_k = 0; | |
| if (param_k != 0.0) { | | if (param_k != 0.0) { | |
| need_stat(AVERAGE_LENGTH); | | need_stat(AVERAGE_LENGTH); | |
| need_stat(DOC_LENGTH); | | need_stat(DOC_LENGTH); | |
| } | | } | |
| need_stat(COLLECTION_SIZE); | | need_stat(COLLECTION_SIZE); | |
| need_stat(RSET_SIZE); | | need_stat(RSET_SIZE); | |
| need_stat(TERMFREQ); | | need_stat(TERMFREQ); | |
| need_stat(RELTERMFREQ); | | need_stat(RELTERMFREQ); | |
| need_stat(DOC_LENGTH_MIN); | | need_stat(DOC_LENGTH_MIN); | |
| need_stat(WDF); | | need_stat(WDF); | |
| need_stat(WDF_MAX); | | need_stat(WDF_MAX); | |
|
| | | need_stat(WDF); | |
| } | | } | |
| | | | |
| std::string name() const; | | std::string name() const; | |
| | | | |
| std::string serialise() const; | | std::string serialise() const; | |
| TradWeight * unserialise(const std::string & s) const; | | TradWeight * unserialise(const std::string & s) const; | |
| | | | |
|
| Xapian::weight get_sumpart(Xapian::termcount wdf, | | double get_sumpart(Xapian::termcount wdf, | |
| Xapian::termcount doclen) const; | | Xapian::termcount doclen) const; | |
| Xapian::weight get_maxpart() const; | | double get_maxpart() const; | |
| | | | |
|
| Xapian::weight get_sumextra(Xapian::termcount doclen) const; | | double get_sumextra(Xapian::termcount doclen) const; | |
| Xapian::weight get_maxextra() const; | | double get_maxextra() const; | |
| }; | | }; | |
| | | | |
| } | | } | |
| | | | |
| #endif // XAPIAN_INCLUDED_WEIGHT_H | | #endif // XAPIAN_INCLUDED_WEIGHT_H | |
| | | | |
End of changes. 33 change blocks. |
| 47 lines changed or deleted | | 31 lines changed or added | |
|