1 /** @file multivaluelist.h
2 * @brief Class for merging ValueList objects from subdatabases.
4 /* Copyright (C) 2007,2008,2009 Olly Betts
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef XAPIAN_INCLUDED_MULTIVALUELIST_H
22 #define XAPIAN_INCLUDED_MULTIVALUELIST_H
24 #include "valuelist.h"
33 /// Class for merging ValueList objects from subdatabases.
34 class MultiValueList
: public ValueList
{
35 /// Don't allow assignment.
36 void operator=(const MultiValueList
&);
38 /// Don't allow copying.
39 MultiValueList(const MultiValueList
&);
41 /// Current docid (or 0 if we haven't started yet).
42 Xapian::docid current_docid
;
44 /// Vector of sub-valuelists which we use as a heap.
45 std::vector
<SubValueList
*> valuelists
;
47 /// The value slot we're iterating over.
54 MultiValueList(const std::vector
<Xapian::Internal::intrusive_ptr
<Xapian::Database::Internal
> > & dbs
,
55 Xapian::valueno slot_
);
60 /// Return the docid at the current position.
61 Xapian::docid
get_docid() const;
63 /// Return the value at the current position.
64 std::string
get_value() const;
66 /// Return the value slot for the current position/this iterator.
67 Xapian::valueno
get_valueno() const;
69 /// Return true if the current position is past the last entry in this list.
72 /** Advance the current position to the next document in the value stream.
74 * The list starts before the first entry in the list, so next()
75 * must be called before any methods which need the context of
76 * the current position.
80 /** Skip forward to the specified docid.
82 * If the specified docid isn't in the list, position ourselves on the
83 * first document after it (or at_end() if no greater docids are present).
85 void skip_to(Xapian::docid
);
87 /** Check if the specified docid occurs in this valuestream.
89 * The caller is required to ensure that the specified @a docid actually
90 * exists in the database.
92 * This method acts like skip_to() if that can be done at little extra
93 * cost, in which case it then sets @a valid to true.
95 * Otherwise it simply checks if a particular docid is present. If it
96 * is, it returns true. If it isn't, it returns false, and leaves the
97 * position unspecified (and hence the result of calling methods which
98 * depends on the current position, such as get_docid(), are also
99 * unspecified). In this state, next() will advance to the first matching
100 * position after @a docid, and skip_to() will act as it would if the
101 * position was the first matching position after @a docid.
103 * The default implementation calls skip_to().
105 bool check(Xapian::docid did
);
107 /// Return a string description of this object.
108 std::string
get_description() const;
111 #endif // XAPIAN_INCLUDED_MULTIVALUELIST_H