📄 classxapian_1_1writabledatabase.tex
字号:
\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!commit_transaction@{commit\_\-transaction}}\index{commit_transaction@{commit\_\-transaction}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[commit\_\-transaction]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::commit\_\-transaction ()}}\label{classXapian_1_1WritableDatabase_3d330f3a27cc17d78635781c7b77280f}End the transaction currently in progress, committing the modifications made to the database. If this completes successfully, all the database modifications made during the transaction will have been committed to the database.If an error occurs, an exception will be thrown, and none of the modifications made to the database during the transaction will have been applied to the database.Whatever occurs, after this method the transaction will no longer be in progress.\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while modifying the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state.\item[{\em Xapian::Invalid\-Operation\-Error}]will be thrown if a transaction is not currently in progress.\item[{\em Xapian::Unimplemented\-Error}]will be thrown if transactions are not available for this database type. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_8426619892e77112e832fc4b11b8efc3}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!delete_document@{delete\_\-document}}\index{delete_document@{delete\_\-document}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[delete\_\-document]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::delete\_\-document (const std::string \& {\em unique\_\-term})}}\label{classXapian_1_1WritableDatabase_8426619892e77112e832fc4b11b8efc3}Delete any documents indexed by a term from the database. This method removes any documents indexed by the specified term from the database.The intended use is to allow UIDs from another system to easily be mapped to terms in \hyperlink{namespaceXapian}{Xapian}, although this method probably has other uses.\begin{Desc}\item[Parameters:]\begin{description}\item[{\em unique\_\-term}]The term to remove references to.\end{description}\end{Desc}\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while writing to the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_0cfd78ba9108b9ef2cf9b4a9f545c70d}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!delete_document@{delete\_\-document}}\index{delete_document@{delete\_\-document}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[delete\_\-document]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::delete\_\-document (\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} {\em did})}}\label{classXapian_1_1WritableDatabase_0cfd78ba9108b9ef2cf9b4a9f545c70d}Delete a document from the database. This method removes the document with the specified document ID from the database.Note that this does not mean the document will immediately disappear from the database; see \hyperlink{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{flush()} for more details.As with all database modification operations, the effect is atomic: the document will either be fully removed, or the document fails to be removed and an exception is thrown (possibly at a later time when flush is called or the database is closed).\begin{Desc}\item[Parameters:]\begin{description}\item[{\em did}]The document ID of the document to be removed.\end{description}\end{Desc}\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while writing to the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!flush@{flush}}\index{flush@{flush}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[flush]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::flush ()}}\label{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}Flush to disk any modifications made to the database. For efficiency reasons, when performing multiple updates to a database it is best (indeed, almost essential) to make as many modifications as memory will permit in a single pass through the database. To ensure this, \hyperlink{namespaceXapian}{Xapian} batches up modifications.Flush may be called at any time to ensure that the modifications which have been made are written to disk: if the flush succeeds, all the preceding modifications will have been written to disk.If any of the modifications fail, an exception will be thrown and the database will be left in a state in which each separate addition, replacement or deletion operation has either been fully performed or not performed at all: it is then up to the application to work out which operations need to be repeated.If called within a transaction, this will flush database modifications made before the transaction was begun, but will not flush modifications made since \hyperlink{classXapian_1_1WritableDatabase_702276148fd73a78310e5ec5e4c466cd}{begin\_\-transaction()} was called.Beware of calling flush too frequently: this will have a severe performance cost.Note that flush need not be called explicitly: it will be called automatically when the database is closed, or when a sufficient number of modifications have been made.\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while modifying the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state.\item[{\em Xapian::Database\-Lock\-Error}]will be thrown if a lock couldn't be acquired on the database. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_714ee6f7f21fd72307329a4ba21227a0}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!get_description@{get\_\-description}}\index{get_description@{get\_\-description}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[get\_\-description]{\setlength{\rightskip}{0pt plus 5cm}std::string Xapian::Writable\-Database::get\_\-description () const\hspace{0.3cm}{\tt \mbox{[}virtual\mbox{]}}}}\label{classXapian_1_1WritableDatabase_714ee6f7f21fd72307329a4ba21227a0}Introspection method. \begin{Desc}\item[Returns:]A string describing this object. \end{Desc}Reimplemented from \hyperlink{classXapian_1_1Database_59e5889c489ce77fb4e7ffd80b6bc52c}{Xapian::Database}.\hypertarget{classXapian_1_1WritableDatabase_c97254827cb74c93606ae046dcdd3754}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!operator=@{operator=}}\index{operator=@{operator=}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[operator=]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::operator= (const \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database} \& {\em other})}}\label{classXapian_1_1WritableDatabase_c97254827cb74c93606ae046dcdd3754}Assignment is allowed. The internals are reference counted, so assignment is cheap.Note that only an \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database} may be assigned to an \hyperlink{classXapian_1_1WritableDatabase}{Writable\-Database}: an attempt to assign a \hyperlink{classXapian_1_1Database}{Database} is caught at compile-time. \hypertarget{classXapian_1_1WritableDatabase_43c4630ec482508667e9ca539f19cbf0}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!replace_document@{replace\_\-document}}\index{replace_document@{replace\_\-document}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[replace\_\-document]{\setlength{\rightskip}{0pt plus 5cm}\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} Xapian::Writable\-Database::replace\_\-document (const std::string \& {\em unique\_\-term}, const \hyperlink{classXapian_1_1Document}{Xapian::Document} \& {\em document})}}\label{classXapian_1_1WritableDatabase_43c4630ec482508667e9ca539f19cbf0}Replace any documents matching a term. This method replaces any documents indexed by the specified term with the specified document. If any documents are indexed by the term, the lowest document ID will be used for the document, otherwise a new document ID will be generated as for add\_\-document.The intended use is to allow UIDs from another system to easily be mapped to terms in \hyperlink{namespaceXapian}{Xapian}, although this method probably has other uses.Note that this does not mean the document(s) will immediately change in the database; see \hyperlink{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{flush()} for more details.As with all database modification operations, the effect is atomic: the document(s) will either be fully replaced, or the document(s) fail to be replaced and an exception is thrown (possibly at a later time when flush is called or the database is closed).\begin{Desc}\item[Parameters:]\begin{description}\item[{\em unique\_\-term}]The \char`\"{}unique\char`\"{} term. \item[{\em document}]The new document.\end{description}\end{Desc}\begin{Desc}\item[Returns:]The document ID that document was given.\end{Desc}\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while writing to the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state. \end{description}\end{Desc}\hypertarget{classXapian_1_1WritableDatabase_23344c9000ea98b15d491fa875bd5d1e}{\index{Xapian::WritableDatabase@{Xapian::Writable\-Database}!replace_document@{replace\_\-document}}\index{replace_document@{replace\_\-document}!Xapian::WritableDatabase@{Xapian::Writable\-Database}}\subsubsection[replace\_\-document]{\setlength{\rightskip}{0pt plus 5cm}void Xapian::Writable\-Database::replace\_\-document (\hyperlink{types_8h_53073891e45d892a8d8a5d8f87f41402}{Xapian::docid} {\em did}, const \hyperlink{classXapian_1_1Document}{Xapian::Document} \& {\em document})}}\label{classXapian_1_1WritableDatabase_23344c9000ea98b15d491fa875bd5d1e}Replace a given document in the database. This method replaces the document with the specified document ID.Note that this does not mean the document will immediately change in the database; see \hyperlink{classXapian_1_1WritableDatabase_e767fd6fec96a126763f818fdc0abca7}{flush()} for more details.As with all database modification operations, the effect is atomic: the document will either be fully replaced, or the document fails to be replaced and an exception is thrown (possibly at a later time when flush is called or the database is closed).\begin{Desc}\item[Parameters:]\begin{description}\item[{\em did}]The document ID of the document to be replaced. \item[{\em document}]The new document.\end{description}\end{Desc}\begin{Desc}\item[Exceptions:]\begin{description}\item[{\em Xapian::Database\-Error}]will be thrown if a problem occurs while writing to the database.\item[{\em Xapian::Database\-Corrupt\-Error}]will be thrown if the database is in a corrupt state. \end{description}\end{Desc}The documentation for this class was generated from the following file:\begin{CompactItemize}\item include/xapian/\hyperlink{database_8h}{database.h}\end{CompactItemize}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -