xapian-core  2.0.0
valuestreamdocument.h
Go to the documentation of this file.
1 
4 /* Copyright (C) 2009,2011,2014,2017 Olly Betts
5  *
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.
10  *
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.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <https://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
22 #define XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
23 
25 #include "backends/multi.h"
27 #include "backends/valuelist.h"
28 #include "omassert.h"
29 #include "xapian/database.h"
30 #include "xapian/types.h"
31 
32 #include <map>
33 
38 
41 
42  mutable std::map<Xapian::valueno, ValueList *> valuelists;
43 
45 
47 
49 
50  mutable Xapian::Document::Internal * doc = NULL;
51 
58  : Internal(n_shards_ == 1 ?
59  db_.internal.get() :
60  static_cast<MultiDatabase*>(db_.internal.get())->shards[0],
61  0),
62  db(db_),
63  n_shards(n_shards_) {}
64 
65  public:
67  : ValueStreamDocument(db_, db_.internal->size()) {}
68 
70 
72 
74  if (did != shard_did) {
75  did = shard_did;
76  delete doc;
77  doc = NULL;
78  }
79  }
80 
84  }
85 
86  // Optimise away the virtual call when the matcher wants to know a value.
87  std::string get_value(Xapian::valueno slot) const {
89  }
90 
91  protected:
93  std::string fetch_value(Xapian::valueno slot) const;
94  void fetch_all_values(std::map<Xapian::valueno, std::string> & values_) const;
95  std::string fetch_data() const;
97 };
98 
99 #endif // XAPIAN_INCLUDED_VALUESTREAMDOCUMENT_H
Sharded database backend.
A document which gets its values from a ValueStreamManager.
Xapian::doccount current
Xapian::Document::Internal * doc
void fetch_all_values(std::map< Xapian::valueno, std::string > &values_) const
Implementation of virtual methods.
void set_shard_document(Xapian::docid shard_did)
std::string fetch_value(Xapian::valueno slot) const
Implementation of virtual methods.
std::string fetch_data() const
Implementation of virtual methods.
void new_shard(Xapian::doccount n)
std::map< Xapian::valueno, ValueList * > valuelists
ValueStreamDocument(const Xapian::Database &db_, Xapian::doccount n_shards_)
Private constructor.
void operator=(const ValueStreamDocument &)
Don't allow assignment.
ValueStreamDocument(const Xapian::Database &db_)
void set_document(Xapian::docid did_)
ValueStreamDocument(const ValueStreamDocument &)
Don't allow copying.
std::string get_value(Xapian::valueno slot) const
Xapian::doccount n_shards
An indexed database of documents.
Definition: database.h:75
Abstract base class for a document.
Xapian::docid did
The document ID this document came from in database.
Internal()
Construct an empty document.
An indexed database of documents.
Abstract base class for a document.
Multi-database support functions.
Xapian::doccount shard_number(Xapian::docid did, Xapian::doccount n_shards)
Convert docid in the multi-db to shard number.
Definition: multi.h:49
Xapian::docid shard_docid(Xapian::docid did, Xapian::doccount n_shards)
Convert docid in the multi-db to the docid in the shard.
Definition: multi.h:35
Sharded database backend.
unsigned valueno
The number for a value slot in a document.
Definition: types.h:90
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Definition: types.h:37
unsigned XAPIAN_DOCID_BASE_TYPE docid
A unique identifier for a document.
Definition: types.h:51
Various assertion macros.
#define AssertEq(A, B)
Definition: omassert.h:124
typedefs for Xapian
Abstract base class for value streams.