Public Types | Public Member Functions | List of all members
Xapian::Compactor Class Reference

Compact a database, or merge and compact several. More...

Public Types

enum  compaction_level { STANDARD = 0, FULL = 1, FULLER = 2 }
 Compaction level. More...
 

Public Member Functions

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...
 

Detailed Description

Compact a database, or merge and compact several.

Member Enumeration Documentation

◆ compaction_level

Compaction level.

Enumerator
STANDARD 

Don't split items unnecessarily.

FULL 

Split items whenever it saves space (the default).

FULLER 

Allow oversize items to save more space (not recommended if you ever plan to update the compacted database).

Member Function Documentation

◆ add_source()

void Xapian::Compactor::add_source ( const std::string &  srcdir)

Add a source database.

Deprecated:
Use Database::compact(destdir[, compactor]) instead.
Parameters
srcdirThe path to the source database to add.

◆ compact()

void Xapian::Compactor::compact ( )

Perform the actual compaction/merging operation.

Deprecated:
Use Database::compact(destdir[, compactor]) instead.

◆ resolve_duplicate_metadata()

virtual std::string Xapian::Compactor::resolve_duplicate_metadata ( const std::string &  key,
size_t  num_tags,
const std::string  tags[] 
)
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.

Parameters
keyThe metadata key with duplicate entries.
num_tagsHow many tags there are.
tagsAn array of num_tags strings containing the tags to merge.

◆ set_block_size()

void Xapian::Compactor::set_block_size ( size_t  block_size)

Set the block size to use for tables in the output database.

Parameters
block_sizeThe 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.

◆ set_compaction_level()

void Xapian::Compactor::set_compaction_level ( compaction_level  compaction)
inline

Set the compaction level.

Parameters
compactionAvailable values are:

◆ set_destdir()

void Xapian::Compactor::set_destdir ( const std::string &  destdir)

Set where to write the output.

Deprecated:
Use Database::compact(destdir[, compactor]) instead.
Parameters
destdirOutput 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).

◆ set_multipass()

void Xapian::Compactor::set_multipass ( bool  multipass)
inline

Set whether to merge postlists in multiple passes.

Parameters
multipassIf 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.

References Xapian::DBCOMPACT_MULTIPASS.

◆ set_renumber()

void Xapian::Compactor::set_renumber ( bool  renumber)
inline

Set whether to preserve existing document id values.

Parameters
renumberThe 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.

References Xapian::DBCOMPACT_NO_RENUMBER.

◆ set_status()

virtual void Xapian::Compactor::set_status ( const std::string &  table,
const std::string &  status 
)
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.

Parameters
tableThe table currently being compacted.
statusA status message.

The documentation for this class was generated from the following file:

Documentation for Xapian (version 1.4.9).
Generated on Sat Nov 3 2018 by Doxygen 1.8.13.