51 MatchSpy::~MatchSpy() {}
54 MatchSpy::clone()
const {
55 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - clone() method unimplemented");
60 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - name() method unimplemented");
64 MatchSpy::serialise()
const {
65 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - serialise() method unimplemented");
69 MatchSpy::unserialise(
const string &,
const Registry &)
const {
70 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - unserialise() method unimplemented");
74 MatchSpy::serialise_results()
const {
75 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - serialise_results() method unimplemented");
79 MatchSpy::merge_results(
const string &) {
80 throw UnimplementedError(
"MatchSpy not suitable for use with remote searches - merge_results() method unimplemented");
84 MatchSpy::get_description()
const {
85 return "Xapian::MatchSpy()";
96 map<string, Xapian::doccount>::const_iterator
it;
131 while (it != spy->
values.end() && it->first < term) {
140 return it == spy->
values.end();
160 : str(str_), frequency(frequency_) {}
192 vector<StringAndFrequency>::const_iterator
it;
208 return it->get_string();
214 return it->get_frequency();
228 while (it != values.end() && it->get_string() < term) {
237 return it == values.end();
266 const map<string, doccount> & items,
270 result.reserve(maxitems);
274 for (map<string, doccount>::const_iterator i = items.begin();
275 i != items.end(); ++i) {
276 Assert(result.size() <= maxitems);
278 if (result.size() > maxitems) {
282 push_heap(result.begin(), result.end(), cmpfn);
285 make_heap(result.begin(), result.end(), cmpfn);
288 pop_heap(result.begin(), result.end(), cmpfn);
294 sort_heap(result.begin(), result.end(), cmpfn);
296 sort(result.begin(), result.end(), cmpfn);
301 ValueCountMatchSpy::operator()(
const Document &doc,
double) {
304 string val(doc.
get_value(internal->slot));
305 if (!val.empty()) ++(internal->values[val]);
309 ValueCountMatchSpy::values_begin()
const 316 ValueCountMatchSpy::top_values_begin(
size_t maxvalues)
const 326 ValueCountMatchSpy::clone()
const {
333 return "Xapian::ValueCountMatchSpy";
337 ValueCountMatchSpy::serialise()
const {
345 ValueCountMatchSpy::unserialise(
const string & s,
const Registry &)
const 347 const char * p = s.data();
348 const char * end = p + s.size();
353 throw NetworkError(
"Junk at end of serialised ValueCountMatchSpy");
360 ValueCountMatchSpy::serialise_results()
const {
361 LOGCALL(REMOTE,
string,
"ValueCountMatchSpy::serialise_results", NO_ARGS);
366 for (map<string, doccount>::const_iterator i = internal->values.begin();
367 i !=
internal->values.end(); ++i) {
376 ValueCountMatchSpy::merge_results(
const string & s) {
377 LOGCALL_VOID(REMOTE,
"ValueCountMatchSpy::merge_results", s);
379 const char * p = s.data();
380 const char * end = p + s.size();
384 internal->total += n;
386 map<string, doccount>::size_type items;
391 string val(p, vallen);
395 internal->values[val] += freq;
399 throw NetworkError(
"Junk at end of serialised ValueCountMatchSpy " 405 ValueCountMatchSpy::get_description()
const {
406 string d =
"ValueCountMatchSpy(";
407 if (
internal.
get()) {
408 d +=
str(internal->total);
409 d +=
" docs seen, looking in ";
410 d +=
str(internal->values.size());
The Xapian namespace contains public interfaces for the Xapian library.
Define the XAPIAN_NORETURN macro.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
A termlist iterator over a vector of StringAndFrequency objects.
length encoded as a string
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
TermList * skip_to(const string &term)
Skip forward to the specified term.
string get_termname() const
Return the termname at the current position.
Xapian::PositionIterator positionlist_begin() const
Return a PositionIterator for the current position.
Xapian::doccount get_frequency() const
Return the frequency.
InvalidOperationError indicates the API was used in an invalid way.
A string with a corresponding frequency.
Abstract base class for match spies.
A termlist iterator over the contents of a ValueCountMatchSpy.
ValueCountTermList(ValueCountMatchSpy::Internal *spy_)
intrusive_ptr< Xapian::ValueCountMatchSpy::Internal > spy
#define LOGCALL_VOID(CATEGORY, FUNC, PARAMS)
Abstract base class for termlists.
Convert types to std::string.
std::string get_string() const
Return the string.
std::string encode_length(T len)
Encode a length as a variable-length string.
static void unsupported_method()
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
Hierarchy of classes which Xapian can throw as exceptions.
Class for iterating over a list of terms.
unsigned XAPIAN_TERMCOUNT_BASE_TYPE termcount
A counts of terms.
string get_termname() const
Return the termname at the current position.
map< string, Xapian::doccount >::const_iterator it
bool operator()(const StringAndFrequency &a, const StringAndFrequency &b) const
Return true if a has a higher frequency than b.
std::map< std::string, Xapian::doccount > values
The values seen so far, together with their frequency.
Registry for user subclasses.
vector< StringAndFrequency >::const_iterator it
string str(int value)
Convert int to std::string.
Xapian::PositionIterator positionlist_begin() const
Return a PositionIterator for the current position.
StringAndFrequency(const std::string &str_, Xapian::doccount frequency_)
Construct a StringAndFrequency object.
TermList * next()
Advance the current position to the next term in the termlist.
Xapian::doccount frequency
Class for iterating over term positions.
bool at_end() const
Return true if the current position is past the last term in this list.
static void get_most_frequent_items(vector< StringAndFrequency > &result, const map< string, doccount > &items, size_t maxitems)
Get the most frequent items from a map from string to frequency.
StringAndFreqCmpByFreq()
Default constructor.
Xapian::doccount get_termfreq() const
Return the term frequency for the term at the current position.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Class for counting the frequencies of values in the matching documents.
bool at_end() const
Return true if the current position is past the last term in this list.
Xapian::termcount get_wdf() const
Return the wdf for the term at the current position.
void decode_length_and_check(const char **p, const char *end, unsigned &out)
Decode a length encoded by encode_length.
unsigned XAPIAN_DOCID_BASE_TYPE doccount
A count of documents.
Xapian::termcount get_approx_size() const
Return approximate size of this termlist.
Indicates a problem communicating with a remote database.
unsigned valueno
The number for a value slot in a document.
Various handy helpers which std::string really should provide.
Abstract base class for termlists.
void init()
init should be called after the values have been set, but before iteration begins.
TermList * skip_to(const string &term)
Skip forward to the specified term.
Various assertion macros.
Xapian::termcount positionlist_count() const
Return the length of the position list for the current position.
API for working with documents.
A smart pointer that uses intrusive reference counting.
TermList * next()
Advance the current position to the next term in the termlist.
std::string get_value(Xapian::valueno slot) const
Get value by number.
void decode_length(const char **p, const char *end, unsigned &out)
Decode a length encoded by encode_length.
A handle representing a document in a Xapian database.
Compare two StringAndFrequency objects.
Wrapper around standard unique_ptr template.
#define LOGCALL(CATEGORY, TYPE, FUNC, PARAMS)
UnimplementedError indicates an attempt to use an unimplemented feature.
Class for looking up user subclasses during unserialisation.
vector< StringAndFrequency > values
parsing a user query string to build a Xapian::Query object