xapian-core
1.4.26
|
Compact a database, or merge and compact several. More...
#include <compactor.h>
Classes | |
class | Internal |
Public Types | |
enum | compaction_level { STANDARD = 0, FULL = 1, FULLER = 2 } |
Compaction level. More... | |
Public Member Functions | |
Compactor () | |
virtual | ~Compactor () |
void | set_block_size (size_t block_size) |
Set the block size to use for tables in the output database. More... | |
void | set_renumber (bool renumber) |
Set whether to preserve existing document id values. More... | |
void | set_multipass (bool multipass) |
Set whether to merge postlists in multiple passes. More... | |
void | set_compaction_level (compaction_level compaction) |
Set the compaction level. More... | |
void | set_destdir (const std::string &destdir) |
Set where to write the output. More... | |
void | add_source (const std::string &srcdir) |
Add a source database. More... | |
void | compact () |
Perform the actual compaction/merging operation. More... | |
virtual void | set_status (const std::string &table, const std::string &status) |
Update progress. More... | |
virtual std::string | resolve_duplicate_metadata (const std::string &key, size_t num_tags, const std::string tags[]) |
Resolve multiple user metadata entries with the same key. More... | |
Private Member Functions | |
void | set_flags_ (unsigned flags, unsigned mask=0) |
Private Attributes | |
Xapian::Internal::intrusive_ptr< Internal > | internal |
Compact a database, or merge and compact several.
Definition at line 42 of file compactor.h.
Compaction level.
Definition at line 48 of file compactor.h.
Xapian::Compactor::Compactor | ( | ) |
Definition at line 95 of file compactor.cc.
|
virtual |
Definition at line 97 of file compactor.cc.
void Xapian::Compactor::add_source | ( | const std::string & | srcdir | ) |
Add a source database.
srcdir | The path to the source database to add. |
Definition at line 118 of file compactor.cc.
Referenced by DEFINE_TESTCASE().
void Xapian::Compactor::compact | ( | ) |
Perform the actual compaction/merging operation.
Definition at line 124 of file compactor.cc.
References Xapian::Database::add_database(), Xapian::Database::compact(), internal, and srcdir.
Referenced by DEFINE_TESTCASE().
|
virtual |
Resolve multiple user metadata entries with the same key.
When merging, if the same user metadata key is set in more than one input, then this method is called to allow this to be resolving in an appropriate way.
The default implementation just returns tags[0].
For multipass this will currently get called multiple times for the same key if there are duplicates to resolve in each pass, but this may change in the future.
Since 1.4.6, an implementation of this method can return an empty string to indicate that the appropriate result is to not set a value for this user metadata key in the output database. In older versions, you should not return an empty string.
key | The metadata key with duplicate entries. |
num_tags | How many tags there are. |
tags | An array of num_tags strings containing the tags to merge. |
Reimplemented in MyCompactor.
Definition at line 142 of file compactor.cc.
References backend_mismatch().
Referenced by GlassCompact::merge_postlists(), and ChertCompact::merge_postlists().
void Xapian::Compactor::set_block_size | ( | size_t | block_size | ) |
Set the block size to use for tables in the output database.
block_size | The block size to use. Valid block sizes are currently powers of two between 2048 and 65536, with the default being 8192, but the valid sizes and default may change in the future. |
Definition at line 100 of file compactor.cc.
|
inline |
Set the compaction level.
compaction | Available values are:
|
Definition at line 116 of file compactor.h.
References srcdir, tags, and XAPIAN_DEPRECATED.
void Xapian::Compactor::set_destdir | ( | const std::string & | destdir | ) |
Set where to write the output.
destdir | Output path. This can be the same as an input if that input is a stub database (in which case the database(s) listed in the stub will be compacted to a new database and then the stub will be atomically updated to point to this new database). |
Definition at line 112 of file compactor.cc.
Referenced by DEFINE_TESTCASE().
|
private |
Definition at line 106 of file compactor.cc.
|
inline |
Set whether to merge postlists in multiple passes.
multipass | If true and merging more than 3 databases, merge the postlists in multiple passes, which is generally faster but requires more disk space for temporary files. By default we don't do this. |
Definition at line 102 of file compactor.h.
References Xapian::DBCOMPACT_MULTIPASS.
Referenced by DEFINE_TESTCASE().
|
inline |
Set whether to preserve existing document id values.
renumber | The default is true, which means that document ids will be renumbered - currently by applying the same offset to all the document ids in a particular source database. |
If false, then the document ids must be unique over all source databases. Currently the ranges of document ids in each source must not overlap either, though this restriction may be removed in the future.
Definition at line 90 of file compactor.h.
References Xapian::DBCOMPACT_NO_RENUMBER.
Referenced by DEFINE_TESTCASE().
|
virtual |
Update progress.
Subclass this method if you want to get progress updates during compaction. This is called for each table first with empty status, And then one or more times with non-empty status.
The default implementation does nothing.
table | The table currently being compacted. |
status | A status message. |
Reimplemented in MyCompactor.
Definition at line 135 of file compactor.cc.
Referenced by GlassDatabase::compact(), and ChertDatabase::compact().
|
private |