#include <config.h>
#include <xapian/document.h>
#include <xapian/error.h>
#include <xapian/positioniterator.h>
#include <xapian/termiterator.h>
#include <xapian/valueiterator.h>
#include "omassert.h"
#include "omenquireinternal.h"
#include "serialise.h"
#include "serialise-double.h"
#include "stats.h"
#include "utils.h"
#include <string>
#include <string.h>
#include <xapian/errordispatch.h>
Include dependency graph for serialise.cc:
Go to the source code of this file.
Functions | |
string | encode_length (size_t len) |
Encode a length as a variable-length string. | |
size_t | decode_length (const char **p, const char *end, bool check_remaining) |
Decode a length encoded by encode_length. | |
string | serialise_error (const Xapian::Error &e) |
Serialise a Xapian::Error object to a string. | |
void | unserialise_error (const string &serialised_error, const string &prefix, const string &new_context) |
string | serialise_stats (const Stats &stats) |
Serialise a Stats object. | |
Stats | unserialise_stats (const string &s) |
string | serialise_mset_pre_30_5 (const Xapian::MSet &mset) |
Serialise a Xapian::MSet object for remote protocol < 30.5. | |
string | serialise_mset (const Xapian::MSet &mset) |
Serialise a Xapian::MSet object. | |
Xapian::MSet | unserialise_mset (const string &s) |
string | serialise_rset (const Xapian::RSet &rset) |
Serialise a Xapian::RSet object. | |
Xapian::RSet | unserialise_rset (const string &s) |
string | serialise_document (const Xapian::Document &doc) |
Serialise a Xapian::Document object. | |
Xapian::Document | unserialise_document (const string &s) |
string encode_length | ( | size_t | len | ) |
Encode a length as a variable-length string.
The encoding specifies its own length.
len | The length to encode. |
Definition at line 42 of file serialise.cc.
Referenced by RemoteDatabase::delete_document(), RemoteDatabase::get_doclength(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteServer::RemoteServer(), RemoteDatabase::replace_document(), RemoteDatabase::send_global_stats(), Xapian::Query::Internal::serialise(), serialise_document(), serialise_error(), serialise_mset(), serialise_mset_pre_30_5(), serialise_rset(), serialise_stats(), RemoteDatabase::set_query(), test_serialiselength1(), and test_serialiselength2().
size_t decode_length | ( | const char ** | p, | |
const char * | end, | |||
bool | check_remaining | |||
) |
Decode a length encoded by encode_length.
p | Pointer to a pointer to the string, which will be advanced past the encoded length. | |
end | Pointer to the end of the string. | |
check_remaining | Check the result against the amount of data remaining after the length has been decoded. |
Definition at line 64 of file serialise.cc.
Referenced by RemoteDatabase::add_document(), RemoteDatabase::get_collection_freq(), RemoteDatabase::get_termfreq(), NetworkPostList::next(), RemoteDatabase::open_allterms(), RemoteDatabase::open_document(), RemoteDatabase::open_position_list(), RemoteDatabase::open_term_list(), RemoteDatabase::read_post_list(), QUnserial::readcompound(), QUnserial::readquery(), RemoteDatabase::RemoteDatabase(), RemoteDatabase::replace_document(), test_serialiselength1(), test_serialiselength2(), unserialise_document(), unserialise_error(), unserialise_mset(), unserialise_rset(), unserialise_stats(), and RemoteDatabase::update_stats().
string serialise_error | ( | const Xapian::Error & | e | ) |
Serialise a Xapian::Error object to a string.
e | The Xapian::Error object to serialise. |
Definition at line 91 of file serialise.cc.
References encode_length(), Xapian::Error::get_context(), Xapian::Error::get_error_string(), Xapian::Error::get_msg(), and Xapian::Error::get_type().
Referenced by RemoteServer::RemoteServer(), RemoteServer::run(), and test_serialiseerror1().
void unserialise_error | ( | const string & | serialised_error, | |
const string & | prefix, | |||
const string & | new_context | |||
) |
Definition at line 107 of file serialise.cc.
References decode_length().
Referenced by RemoteDatabase::get_message(), and test_serialiseerror1().
string serialise_stats | ( | const Stats & | stats | ) |
Serialise a Stats object.
stats | The Stats object to serialise. |
Definition at line 144 of file serialise.cc.
References Stats::average_length, Stats::collection_size, encode_length(), Stats::reltermfreq, Stats::rset_size, serialise_double(), and Stats::termfreq.
Referenced by RemoteDatabase::send_global_stats().
Stats unserialise_stats | ( | const string & | s | ) |
Definition at line 171 of file serialise.cc.
References decode_length(), stat(), and unserialise_double().
string serialise_mset_pre_30_5 | ( | const Xapian::MSet & | mset | ) |
Serialise a Xapian::MSet object for remote protocol < 30.5.
mset | The object to serialise. |
Definition at line 201 of file serialise.cc.
References Xapian::MSet::begin(), encode_length(), Xapian::MSet::end(), Xapian::MSet::get_firstitem(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::MSet::get_max_attained(), Xapian::MSet::get_max_possible(), Xapian::MSet::internal, serialise_double(), and Xapian::MSet::size().
string serialise_mset | ( | const Xapian::MSet & | mset | ) |
Serialise a Xapian::MSet object.
mset | The object to serialise. |
Definition at line 235 of file serialise.cc.
References Xapian::MSet::begin(), encode_length(), Xapian::MSet::end(), Xapian::MSet::get_firstitem(), Xapian::MSet::get_matches_estimated(), Xapian::MSet::get_matches_lower_bound(), Xapian::MSet::get_matches_upper_bound(), Xapian::MSet::get_max_attained(), Xapian::MSet::get_max_possible(), Xapian::MSet::internal, serialise_double(), and Xapian::MSet::size().
Xapian::MSet unserialise_mset | ( | const string & | s | ) |
Definition at line 272 of file serialise.cc.
References decode_length(), Xapian::MSet::size(), Xapian::MSet::Internal::TermFreqAndWeight::termfreq, Xapian::MSet::Internal::TermFreqAndWeight::termweight, and unserialise_double().
string serialise_rset | ( | const Xapian::RSet & | omrset | ) |
Serialise a Xapian::RSet object.
rset | The object to serialise. |
Definition at line 319 of file serialise.cc.
References encode_length(), and Xapian::RSet::internal.
Referenced by RemoteDatabase::set_query().
Xapian::RSet unserialise_rset | ( | const string & | s | ) |
Definition at line 334 of file serialise.cc.
References Xapian::RSet::add_document(), decode_length(), and Xapian::RSet::size().
string serialise_document | ( | const Xapian::Document & | doc | ) |
Serialise a Xapian::Document object.
doc | The object to serialise. |
Definition at line 351 of file serialise.cc.
References Assert, encode_length(), Xapian::Document::get_data(), Xapian::Document::termlist_begin(), Xapian::Document::termlist_count(), Xapian::Document::termlist_end(), Xapian::Document::values_begin(), Xapian::Document::values_count(), and Xapian::Document::values_end().
Referenced by RemoteDatabase::add_document(), RemoteDatabase::replace_document(), and test_serialisedoc1().
Xapian::Document unserialise_document | ( | const string & | s | ) |
Definition at line 395 of file serialise.cc.
References Xapian::Document::add_posting(), Xapian::Document::add_term(), Xapian::Document::add_value(), decode_length(), and Xapian::Document::set_data().