2 * @brief Compact a database, or merge and compact several.
4 /* Copyright (C) 2003,2004,2005,2006,2007,2008,2009,2010,2011,2013,2014,2015,2018 Olly Betts
5 * Copyright (C) 2008 Lemur Consulting Ltd
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
23 #ifndef XAPIAN_INCLUDED_COMPACTOR_H
24 #define XAPIAN_INCLUDED_COMPACTOR_H
26 #if !defined XAPIAN_IN_XAPIAN_H && !defined XAPIAN_LIB_BUILD
27 # error Never use <xapian/compactor.h> directly; include <xapian.h> instead.
30 #include <xapian/constants.h>
31 #include <xapian/visibility.h>
38 /** Compact a database, or merge and compact several.
40 class XAPIAN_VISIBILITY_DEFAULT Compactor
{
42 /** Compaction level. */
44 /** Don't split items unnecessarily. */
46 /** Split items whenever it saves space (the default). */
48 /** Allow oversize items to save more space (not recommended if you
49 * ever plan to update the compacted database). */
59 * Subclass this method if you want to get progress updates during
60 * compaction. This is called for each table first with empty status,
61 * And then one or more times with non-empty status.
63 * The default implementation does nothing.
65 * @param table The table currently being compacted.
66 * @param status A status message.
69 set_status(const std::string
& table
, const std::string
& status
);
71 /** Resolve multiple user metadata entries with the same key.
73 * When merging, if the same user metadata key is set in more than one
74 * input, then this method is called to allow this to be resolving in
77 * The default implementation just returns tags[0].
79 * For multipass this will currently get called multiple times for the
80 * same key if there are duplicates to resolve in each pass, but this
81 * may change in the future.
83 * Since 1.4.6, an implementation of this method can return an empty
84 * string to indicate that the appropriate result is to not set a value
85 * for this user metadata key in the output database. In older versions,
86 * you should not return an empty string.
88 * @param key The metadata key with duplicate entries.
89 * @param num_tags How many tags there are.
90 * @param tags An array of num_tags strings containing the tags to
94 resolve_duplicate_metadata(const std::string
& key
,
95 size_t num_tags
, const std::string tags
[]);
100 #endif /* XAPIAN_INCLUDED_COMPACTOR_H */