2 * @brief A document which gets its values from a ValueStreamManager.
4 /* Copyright (C) 2009,2011,2014 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_VALUESTREAMDOCUMENT_H
22 #define XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
24 #include "backends/document.h"
25 #include "backends/valuelist.h"
27 #include "xapian/database.h"
28 #include "xapian/types.h"
32 /// A document which gets its values from a ValueStreamManager.
33 class ValueStreamDocument
: public Xapian::Document::Internal
{
34 /// Don't allow assignment.
35 void operator=(const ValueStreamDocument
&);
37 /// Don't allow copying.
38 ValueStreamDocument(const ValueStreamDocument
&);
40 mutable std::map
<Xapian::valueno
, ValueList
*> valuelists
;
46 mutable Xapian::Document::Internal
* doc
;
49 explicit ValueStreamDocument(const Xapian::Database
& db_
)
50 : Internal(db_
.internal
[0], 0), db(db_
), current(0), doc(NULL
) { }
52 void new_subdb(int n
);
54 ~ValueStreamDocument();
56 void set_document(Xapian::docid did_
) {
57 // did needs to be the document id in the sub-database.
58 size_t multiplier
= db
.internal
.size();
59 did
= (did_
- 1) / multiplier
+ 1;
60 AssertEq(current
, (did_
- 1) % multiplier
);
65 // Optimise away the virtual call when the matcher wants to know a value.
66 std::string
get_value(Xapian::valueno slot
) const {
67 return ValueStreamDocument::do_get_value(slot
);
71 /** Implementation of virtual methods @{ */
72 std::string
do_get_value(Xapian::valueno slot
) const;
73 void do_get_all_values(std::map
<Xapian::valueno
, std::string
> & values_
) const;
74 std::string
do_get_data() const;
78 #endif // XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H