xapian-core  2.0.0
result.h
Go to the documentation of this file.
1 
4 /* Copyright 2017,2019 Olly Betts
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License as
8  * published by the Free Software Foundation; either version 2 of the
9  * License, or (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_RESULT_H
22 #define XAPIAN_INCLUDED_RESULT_H
23 
24 #include "backends/multi.h"
25 #include "xapian/types.h"
26 
27 #include <string>
28 
30 class Result {
31  double weight;
32 
34 
36 
37  std::string collapse_key;
38 
39  std::string sort_key;
40 
41  public:
42  Result& operator=(const Result&) = delete;
43 
44  Result(const Result&) = delete;
45 
47  Result(Result&&) = default;
48 
50  Result& operator=(Result&&) = default;
51 
53  Result(double weight_, Xapian::docid did_)
54  : weight(weight_), did(did_) {}
55 
57  Result(double weight_, Xapian::docid did_,
58  std::string&& collapse_key_,
59  Xapian::doccount collapse_count_,
60  std::string&& sort_key_)
61  : weight(weight_), did(did_),
62  collapse_count(collapse_count_),
63  collapse_key(std::move(collapse_key_)),
64  sort_key(std::move(sort_key_)) {}
65 
66  void swap(Result& o);
67 
68  Xapian::docid get_docid() const { return did; }
69 
70  double get_weight() const { return weight; }
71 
73 
74  const std::string& get_collapse_key() const { return collapse_key; }
75 
76  const std::string& get_sort_key() const { return sort_key; }
77 
78  void set_weight(double weight_) { weight = weight_; }
79 
81 
82  void set_collapse_key(const std::string& k) { collapse_key = k; }
83 
84  void set_sort_key(const std::string& k) { sort_key = k; }
85 
87  did = unshard(did, shard, n_shards);
88  }
89 
90  std::string get_description() const;
91 };
92 
93 #endif // XAPIAN_INCLUDED_RESULT_H
A result in an MSet.
Definition: result.h:30
const std::string & get_sort_key() const
Definition: result.h:76
void set_weight(double weight_)
Definition: result.h:78
double get_weight() const
Definition: result.h:70
std::string get_description() const
Definition: result.cc:31
Xapian::docid did
Definition: result.h:33
void swap(Result &o)
void set_collapse_key(const std::string &k)
Definition: result.h:82
double weight
Definition: result.h:31
Result & operator=(const Result &)=delete
void set_collapse_count(Xapian::doccount c)
Definition: result.h:80
Result(const Result &)=delete
std::string sort_key
Definition: result.h:39
Result(double weight_, Xapian::docid did_)
Constructor.
Definition: result.h:53
void set_sort_key(const std::string &k)
Definition: result.h:84
Result & operator=(Result &&)=default
Move assignment.
std::string collapse_key
Definition: result.h:37
Xapian::doccount get_collapse_count() const
Definition: result.h:72
Result(double weight_, Xapian::docid did_, std::string &&collapse_key_, Xapian::doccount collapse_count_, std::string &&sort_key_)
Constructor used by MSet::Internal::unserialise().
Definition: result.h:57
void unshard_docid(Xapian::doccount shard, Xapian::doccount n_shards)
Definition: result.h:86
Result(Result &&)=default
Move constructor.
Xapian::doccount collapse_count
Definition: result.h:35
const std::string & get_collapse_key() const
Definition: result.h:74
Xapian::docid get_docid() const
Definition: result.h:68
Multi-database support functions.
Xapian::docid unshard(Xapian::docid shard_did, Xapian::doccount shard, Xapian::doccount n_shards)
Convert shard number and shard docid to docid in multi-db.
Definition: multi.h:64
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
typedefs for Xapian