Ticket #206: serialisationcontext.patch
File serialisationcontext.patch, 27.0 KB (added by , 15 years ago) |
---|
-
xapian-core/tests/internaltest.cc
452 452 Xapian::Query::Internal * qint; 453 453 454 454 s = query->internal->serialise(); 455 map<string, Xapian::PostingSource *> m;456 qint = Xapian::Query::Internal::unserialise(s, m);455 Xapian::SerialisationContext ctx; 456 qint = Xapian::Query::Internal::unserialise(s, ctx); 457 457 458 458 TEST(qint->serialise() == s); 459 459 delete qint; -
xapian-core/include/xapian/query.h
25 25 #ifndef XAPIAN_INCLUDED_QUERY_H 26 26 #define XAPIAN_INCLUDED_QUERY_H 27 27 28 #include <map>29 28 #include <string> 30 29 #include <vector> 31 30 … … 45 44 namespace Xapian { 46 45 47 46 class PostingSource; 47 class SerialisationContext; 48 48 49 49 /** Class representing a query. 50 50 * … … 259 259 std::string serialise() const; 260 260 261 261 /** Unserialise a query from a string produced by serialise(). 262 * FIXME - need to add a way to register posting sources. See ticket #206 262 * 263 * This method will fail if the query contains any external 264 * PostingSource leaf nodes. 265 * 266 * @param s The string representing the serialised query. 263 267 */ 264 268 static Query unserialise(const std::string &s); 265 269 270 /** Unserialise a query from a string produced by serialise(). 271 * 272 * The supplied context will be used to unserialise any external 273 * PostingSource leaf nodes. 274 * 275 * @param s The string representing the serialised query. 276 * @param ctx A context to use when unserialising the query. 277 */ 278 static Query unserialise(const std::string & s, const SerialisationContext & ctx); 279 266 280 /// Return a string describing this object. 267 281 std::string get_description() const; 268 282 … … 434 448 ~Internal(); 435 449 436 450 static Xapian::Query::Internal * unserialise(const std::string &s, 437 const std::map<std::string, Xapian::PostingSource *> &sources);451 const SerialisationContext & ctx); 438 452 439 453 /** Add a subquery. 440 454 */ -
xapian-core/include/xapian/enquire.h
1011 1011 1012 1012 namespace Xapian { 1013 1013 1014 class SerialisationContext; 1015 1014 1016 /// Abstract base class for weighting schemes 1015 1017 class XAPIAN_VISIBILITY_DEFAULT Weight { 1016 1018 friend class Enquire; // So Enquire can clone us 1017 1019 friend class ::RemoteServer; // So RemoteServer can clone us - FIXME 1020 friend class SerialisationContext; 1018 1021 friend class ::ScaleWeight; 1019 1022 public: 1020 1023 class Internal; -
xapian-core/include/xapian/serialisationcontext.h
1 /** @file serialisationcontext.h 2 * @brief Context for looking up objects during unserialisation. 3 */ 4 /* Copyright 2009 Lemur Consulting Ltd 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, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 19 * USA 20 */ 21 22 #ifndef XAPIAN_INCLUDED_SERIALISATIONCONTEXT_H 23 #define XAPIAN_INCLUDED_SERIALISATIONCONTEXT_H 24 25 #include <xapian/base.h> 26 #include <xapian/visibility.h> 27 #include <string> 28 29 namespace Xapian { 30 31 // Forward declarations. 32 class Weight; 33 class PostingSource; 34 35 /** A context for serialisation. 36 * 37 * This context is used to look up weighting schemes and posting sources when 38 * unserialising. 39 */ 40 class XAPIAN_VISIBILITY_DEFAULT SerialisationContext { 41 public: 42 /// Class holding details of the context. 43 class Internal; 44 45 private: 46 /// @private @internal Reference counted internals. 47 Xapian::Internal::RefCntPtr<Internal> internal; 48 49 public: 50 /** Copy the context - the copy is shallow. 51 */ 52 SerialisationContext(const SerialisationContext & other); 53 54 /** Assign to the context - the copy is shallow. 55 */ 56 SerialisationContext & operator=(const SerialisationContext & other); 57 58 /** Default constructor: makes a context with default settings. 59 * 60 * The context will contain all hardcoded weighting schemes and 61 * posting sources. 62 */ 63 SerialisationContext(); 64 65 /** Destructor. 66 * 67 * This is essentially the same as the default destructor, but 68 * needs to be explicitly defined because the definition of the 69 * internals is not visible externally, which results in an error 70 * if when the compiler tries to generate a default destructor. 71 */ 72 ~SerialisationContext(); 73 74 /** Clear all registered weighting schemes from the context. 75 */ 76 void clear_weighting_schemes(); 77 78 /** Register a weighting scheme with the context. 79 */ 80 void register_weighting_scheme(const Xapian::Weight &wt); 81 82 /** Get a weighting scheme given a name. 83 * 84 * The returned weighting scheme is owned by the context object. 85 * 86 * Returns NULL if the weighting scheme could not be found. 87 */ 88 const Xapian::Weight * 89 get_weighting_scheme(const std::string & name) const; 90 91 /** Clear all registered posting sources from the context. 92 */ 93 void clear_posting_sources(); 94 95 /** Register a user-defined posting source class. 96 */ 97 void register_posting_source(const Xapian::PostingSource &source); 98 99 /** Get a posting source given a name. 100 * 101 * The returned posting source is owned by the context object. 102 * 103 * Returns NULL if the posting source could not be found. 104 */ 105 const Xapian::PostingSource * 106 get_posting_source(const std::string & name) const; 107 }; 108 109 } 110 111 #endif /* XAPIAN_INCLUDED_SERIALISATIONCONTEXT_H */ -
xapian-core/include/Makefile.mk
Property changes on: xapian-core/include/xapian/serialisationcontext.h ___________________________________________________________________ Name: svn:eol-style + native
25 25 include/xapian/query.h\ 26 26 include/xapian/queryparser.h\ 27 27 include/xapian/replication.h\ 28 include/xapian/serialisationcontext.h\ 28 29 include/xapian/sorter.h\ 29 30 include/xapian/stem.h\ 30 31 include/xapian/termgenerator.h\ -
xapian-core/include/xapian.h
54 54 // Stemming 55 55 #include <xapian/stem.h> 56 56 57 // Serialisation support 58 #include <xapian/serialisationcontext.h> 59 57 60 // Unicode support 58 61 #include <xapian/unicode.h> 59 62 -
xapian-core/net/remoteserver.cc
32 32 #include <stdlib.h> 33 33 34 34 #include "autoptr.h" 35 #include "serialisationcontextinternal.h" 35 36 #include "multimatch.h" 36 37 #include "omassert.h" 37 38 #include "omtime.h" … … 105 106 message += encode_length(uuid.size()); 106 107 message += uuid; 107 108 send_message(REPLY_GREETING, message); 108 109 // Register weighting schemes.110 Xapian::Weight * weight;111 weight = new Xapian::BM25Weight;112 wtschemes[weight->name()] = weight;113 weight = new Xapian::BoolWeight;114 wtschemes[weight->name()] = weight;115 weight = new Xapian::TradWeight;116 wtschemes[weight->name()] = weight;117 118 Xapian::PostingSource * source;119 source = new Xapian::ValueWeightPostingSource(0);120 postingsources[source->name()] = source;121 source = new Xapian::ValueMapPostingSource(0);122 postingsources[source->name()] = source;123 source = new Xapian::FixedWeightPostingSource(0.0);124 postingsources[source->name()] = source;125 109 } 126 110 127 111 RemoteServer::~RemoteServer() 128 112 { 129 113 delete db; 130 114 // wdb is either NULL or equal to db, so we shouldn't delete it too! 131 132 {133 map<string, Xapian::Weight*>::const_iterator i;134 for (i = wtschemes.begin(); i != wtschemes.end(); ++i) {135 delete i->second;136 }137 }138 139 {140 map<string, Xapian::PostingSource *>::const_iterator i;141 for (i = postingsources.begin(); i != postingsources.end(); ++i) {142 delete i->second;143 }144 }145 115 } 146 116 147 117 message_type … … 382 352 383 353 // Unserialise the Query. 384 354 len = decode_length(&p, p_end, true); 385 AutoPtr<Xapian::Query::Internal> query(Xapian::Query::Internal::unserialise(string(p, len), postingsources));355 AutoPtr<Xapian::Query::Internal> query(Xapian::Query::Internal::unserialise(string(p, len), ctx)); 386 356 p += len; 387 357 388 358 // Unserialise assorted Enquire settings. … … 421 391 422 392 // Unserialise the Weight object. 423 393 len = decode_length(&p, p_end, true); 424 map<string, Xapian::Weight *>::const_iterator i; 425 i = wtschemes.find(string(p, len)); 426 if (i == wtschemes.end()) { 394 const Xapian::Weight * wttype = ctx.get_weighting_scheme(string(p, len)); 395 if (wttype == NULL) { 427 396 throw Xapian::InvalidArgumentError("Weighting scheme " + string(p, len) + " not registered"); 428 397 } 429 398 p += len; 430 399 431 400 len = decode_length(&p, p_end, true); 432 AutoPtr<Xapian::Weight> wt( i->second->unserialise(string(p, len)));401 AutoPtr<Xapian::Weight> wt(wttype->unserialise(string(p, len))); 433 402 p += len; 434 403 435 404 // Unserialise the RSet object. … … 627 596 628 597 send_message(REPLY_ADDDOCUMENT, encode_length(did)); 629 598 } 630 631 632 void633 RemoteServer::register_posting_source(const Xapian::PostingSource &source)634 {635 if (source.name().empty()) {636 throw Xapian::InvalidOperationError("Unable to register posting source - name() method returns empty string.");637 }638 Xapian::PostingSource * sourceclone = source.clone();639 if (!sourceclone) {640 throw Xapian::InvalidOperationError("Unable to register posting source - clone() method returns NULL.");641 }642 try {643 postingsources[source.name()] = sourceclone;644 } catch(...) {645 delete sourceclone;646 throw;647 }648 } -
xapian-core/common/Makefile.mk
50 50 common/safeuuid.h\ 51 51 common/safewindows.h\ 52 52 common/safewinsock2.h\ 53 common/serialisationcontextinternal.h\ 53 54 common/serialise-double.h\ 54 55 common/serialise.h\ 55 56 common/socket_utils.h\ -
xapian-core/common/remoteserver.h
22 22 #ifndef XAPIAN_INCLUDED_REMOTESERVER_H 23 23 #define XAPIAN_INCLUDED_REMOTESERVER_H 24 24 25 #include "xapian/serialisationcontext.h" 25 26 #include "xapian/database.h" 26 27 #include "xapian/enquire.h" 27 28 #include "xapian/postingsource.h" … … 65 66 */ 66 67 Xapian::timeout idle_timeout; 67 68 68 /// Registered weighting schemes. 69 map<string, Xapian::Weight *> wtschemes; 69 /** The context, used for registering weight schemes and posting 70 * sources. 71 */ 72 Xapian::SerialisationContext ctx; 70 73 71 /// Registered external posting sources.72 map<string, Xapian::PostingSource *> postingsources;73 74 74 /// Accept a message from the client. 75 75 message_type get_message(Xapian::timeout timeout, string & result, 76 76 message_type required_type = MSG_MAX); … … 172 172 173 173 /// Register a user-defined weighting scheme class. 174 174 void register_weighting_scheme(const Xapian::Weight &wt) { 175 wtschemes[wt.name()] = wt.clone();175 ctx.register_weighting_scheme(wt); 176 176 } 177 177 178 178 /** Register a user-defined posting source class. 179 179 */ 180 void register_posting_source(const Xapian::PostingSource &source); 180 void register_posting_source(const Xapian::PostingSource &source) { 181 ctx.register_posting_source(source); 182 } 181 183 }; 182 184 183 185 #endif // XAPIAN_INCLUDED_REMOTESERVER_H -
xapian-core/common/serialisationcontextinternal.h
1 /** @file serialisationcontextinternal.h 2 * @brief Internals of SerialisationContext object. 3 */ 4 /* Copyright 2009 Lemur Consulting Ltd 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, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #ifndef XAPIAN_INCLUDED_SERIALISATIONCONTEXTINTERNAL_H 22 #define XAPIAN_INCLUDED_SERIALISATIONCONTEXTINTERNAL_H 23 24 #include "xapian/base.h" 25 #include "xapian/serialisationcontext.h" 26 27 #include <map> 28 #include <string> 29 30 class Xapian::Weight; 31 class Xapian::PostingSource; 32 33 class Xapian::SerialisationContext::Internal 34 : public Xapian::Internal::RefCntBase { 35 /// Registered weighting schemes. 36 std::map<std::string, Xapian::Weight *> wtschemes; 37 38 /// Registered external posting sources. 39 std::map<std::string, Xapian::PostingSource *> postingsources; 40 41 /** Add the hardcoded default weighting schemes and posting sources. 42 */ 43 void add_defaults(); 44 45 public: 46 Internal(); 47 48 /** Clear all registered weighting schemes from the context. 49 */ 50 void clear_weighting_schemes(); 51 52 /** Register a weighting scheme with the context. 53 */ 54 void register_weighting_scheme(const Xapian::Weight &wt); 55 56 /** Get a weighting scheme given a name. 57 * 58 * The returned weighting scheme is owned by the context object. 59 * 60 * Returns NULL if the weighting scheme could not be found. 61 */ 62 const Xapian::Weight * 63 get_weighting_scheme(const std::string & name) const; 64 65 /** Clear all registered posting sources from the context. 66 */ 67 void clear_posting_sources(); 68 69 /** Register a user-defined posting source class. 70 */ 71 void register_posting_source(const Xapian::PostingSource &source); 72 73 /** Get a posting source given a name. 74 * 75 * The returned posting source is owned by the context object. 76 * 77 * Returns NULL if the posting source could not be found. 78 */ 79 const Xapian::PostingSource * 80 get_posting_source(const std::string & name) const; 81 }; 82 83 #endif // XAPIAN_INCLUDED_SERIALISATIONCONTEXTINTERNAL_H -
xapian-core/api/Makefile.mk
Property changes on: xapian-core/common/serialisationcontextinternal.h ___________________________________________________________________ Name: svn:eol-style + native
25 25 api/postingsource.cc\ 26 26 api/postlist.cc\ 27 27 api/replication.cc\ 28 api/serialisationcontext.cc\ 28 29 api/sortable-serialise.cc\ 29 30 api/sorter.cc\ 30 31 api/termlist.cc\ -
xapian-core/api/serialisationcontext.cc
1 /** @file serialisationcontext.cc 2 * @brief Context for looking up objects during unserialisation. 3 */ 4 /* Copyright (C) 2009 Lemur Consulting Ltd 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, write to the Free Software 18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 19 */ 20 21 #include <config.h> 22 #include "xapian/serialisationcontext.h" 23 24 #include "xapian/enquire.h" 25 #include "xapian/error.h" 26 #include "xapian/postingsource.h" 27 #include "serialisationcontextinternal.h" 28 #include "omdebug.h" 29 30 namespace Xapian { 31 32 SerialisationContext::SerialisationContext(const SerialisationContext & other) 33 : internal(other.internal) 34 { 35 LOGCALL_CTOR(API, "Xapian::SerialisationContext::SerialisationContext", other); 36 } 37 38 SerialisationContext & 39 SerialisationContext::operator=(const SerialisationContext & other) 40 { 41 LOGCALL(API, Xapian::SerialisationContext &, 42 "Xapian::SerialisationContext::operator=", other); 43 internal = other.internal; 44 RETURN(*this); 45 } 46 47 SerialisationContext::SerialisationContext() 48 : internal(new SerialisationContext::Internal()) 49 { 50 LOGCALL_CTOR(API, "Xapian::SerialisationContext::SerialisationContext", 51 ""); 52 } 53 54 SerialisationContext::~SerialisationContext() 55 { 56 LOGCALL_DTOR(API, "Xapian::SerialisationContext::~SerialisationContext"); 57 } 58 59 void 60 SerialisationContext::clear_weighting_schemes() 61 { 62 LOGCALL_VOID(API, 63 "Xapian::SerialisationContext::clear_weighting_schemes", 64 ""); 65 internal->clear_weighting_schemes(); 66 } 67 68 void 69 SerialisationContext::register_weighting_scheme(const Xapian::Weight &wt) 70 { 71 LOGCALL_VOID(API, 72 "Xapian::SerialisationContext::register_weighting_scheme", 73 wt); 74 internal->register_weighting_scheme(wt); 75 } 76 77 const Xapian::Weight * 78 SerialisationContext::get_weighting_scheme(const std::string & name) const 79 { 80 LOGCALL(API, 81 const Xapian::Weight *, 82 "Xapian::SerialisationContext::get_weighting_scheme", 83 name); 84 RETURN(internal->get_weighting_scheme(name)); 85 } 86 87 void 88 SerialisationContext::clear_posting_sources() 89 { 90 LOGCALL_VOID(API, "Xapian::SerialisationContext::clear_posting_sources", ""); 91 internal->clear_posting_sources(); 92 } 93 94 void 95 SerialisationContext::register_posting_source(const Xapian::PostingSource &source) 96 { 97 LOGCALL_VOID(API, "Xapian::SerialisationContext::register_posting_source", source); 98 internal->register_posting_source(source); 99 } 100 101 const Xapian::PostingSource * 102 SerialisationContext::get_posting_source(const std::string & name) const 103 { 104 LOGCALL(API, 105 const Xapian::PostingSource *, 106 "Xapian::SerialisationContext::get_posting_source", 107 name); 108 RETURN(internal->get_posting_source(name)); 109 } 110 111 112 SerialisationContext::Internal::Internal() 113 : Xapian::Internal::RefCntBase(), 114 wtschemes(), 115 postingsources() 116 { 117 add_defaults(); 118 } 119 120 void 121 SerialisationContext::Internal::add_defaults() 122 { 123 Xapian::Weight * weight; 124 weight = new Xapian::BM25Weight; 125 wtschemes[weight->name()] = weight; 126 weight = new Xapian::BoolWeight; 127 wtschemes[weight->name()] = weight; 128 weight = new Xapian::TradWeight; 129 wtschemes[weight->name()] = weight; 130 131 Xapian::PostingSource * source; 132 source = new Xapian::ValueWeightPostingSource(0); 133 postingsources[source->name()] = source; 134 source = new Xapian::ValueMapPostingSource(0); 135 postingsources[source->name()] = source; 136 source = new Xapian::FixedWeightPostingSource(0.0); 137 postingsources[source->name()] = source; 138 } 139 140 void 141 SerialisationContext::Internal::clear_weighting_schemes() 142 { 143 std::map<std::string, Xapian::Weight*>::const_iterator i; 144 for (i = wtschemes.begin(); i != wtschemes.end(); ++i) { 145 delete i->second; 146 } 147 } 148 149 void 150 SerialisationContext::Internal::register_weighting_scheme(const Xapian::Weight &wt) 151 { 152 // FIXME - delete old wtschemes[wt.name()]. 153 wtschemes[wt.name()] = wt.clone(); 154 } 155 156 const Xapian::Weight * 157 SerialisationContext::Internal::get_weighting_scheme(const std::string & name) const 158 { 159 std::map<std::string, Xapian::Weight *>::const_iterator i; 160 i = wtschemes.find(name); 161 if (i == wtschemes.end()) { 162 return NULL; 163 } 164 return i->second; 165 } 166 167 void 168 SerialisationContext::Internal::clear_posting_sources() 169 { 170 std::map<std::string, Xapian::PostingSource *>::const_iterator i; 171 for (i = postingsources.begin(); i != postingsources.end(); ++i) { 172 delete i->second; 173 } 174 } 175 176 void 177 SerialisationContext::Internal::register_posting_source(const Xapian::PostingSource &source) 178 { 179 std::string sourcename = source.name(); 180 if (sourcename.empty()) { 181 throw Xapian::InvalidOperationError("Unable to register posting source - name() method returns empty string."); 182 } 183 Xapian::PostingSource * sourceclone = source.clone(); 184 if (!sourceclone) { 185 throw Xapian::InvalidOperationError("Unable to register posting source - clone() method returns NULL."); 186 } 187 try { 188 // FIXME - delete old postingsources[sourcename]. 189 postingsources[sourcename] = sourceclone; 190 } catch(...) { 191 delete sourceclone; 192 throw; 193 } 194 } 195 196 const Xapian::PostingSource * 197 SerialisationContext::Internal::get_posting_source(const std::string & name) const 198 { 199 std::map<std::string, Xapian::PostingSource *>::const_iterator i; 200 i = postingsources.find(name); 201 if (i == postingsources.end()) { 202 return NULL; 203 } 204 return i->second; 205 } 206 207 } -
xapian-core/api/omqueryinternal.cc
Property changes on: xapian-core/api/serialisationcontext.cc ___________________________________________________________________ Name: svn:eol-style + native
25 25 26 26 #include "omqueryinternal.h" 27 27 28 #include "serialisationcontextinternal.h" 28 29 #include "omdebug.h" 29 30 #include "utils.h" 30 31 #include "serialise.h" … … 391 392 const char *p; 392 393 const char *end; 393 394 Xapian::termpos curpos; 394 const map<string, Xapian::PostingSource *> & sources;395 const Xapian::SerialisationContext & ctx; 395 396 396 397 Xapian::Query::Internal * readquery(); 397 398 Xapian::Query::Internal * readexternal(); … … 399 400 400 401 public: 401 402 QUnserial(const string & s, 402 const map<string, Xapian::PostingSource *> & sources_)403 : p(s.c_str()), end(p + s.size()), curpos(1), sources(sources_) { }403 const Xapian::SerialisationContext & ctx_) 404 : p(s.c_str()), end(p + s.size()), curpos(1), ctx(ctx_) { } 404 405 Xapian::Query::Internal * decode(); 405 406 }; 406 407 … … 457 458 458 459 size_t length = decode_length(&p, end, true); 459 460 string sourcename(p, length); 460 map<string, Xapian::PostingSource *>::const_iterator i;461 i = sources.find(sourcename);462 if (i == sources.end()) { 463 throw Xapian::InvalidArgumentError("PostingSource " + string(p, length) +" not registered");461 const Xapian::PostingSource * source = ctx.get_posting_source(sourcename); 462 if (source == NULL) { 463 throw Xapian::InvalidArgumentError("PostingSource " + sourcename + 464 " not registered"); 464 465 } 465 466 466 467 p += length; … … 468 469 string sourcedata(p, length); 469 470 p += length; 470 471 471 return new Xapian::Query::Internal( i->second->unserialise(sourcedata), true);472 return new Xapian::Query::Internal(source->unserialise(sourcedata), true); 472 473 } 473 474 474 475 static Xapian::Query::Internal * … … 606 607 607 608 Xapian::Query::Internal * 608 609 Xapian::Query::Internal::unserialise(const string &s, 609 const map<string, Xapian::PostingSource *> & sources)610 const Xapian::SerialisationContext & ctx) 610 611 { 611 612 Assert(s.length() > 1); 612 QUnserial u(s, sources);613 QUnserial u(s, ctx); 613 614 Xapian::Query::Internal * qint = u.decode(); 614 615 AssertEq(s, qint->serialise()); 615 616 return qint; … … 617 618 #else 618 619 Xapian::Query::Internal * 619 620 Xapian::Query::Internal::unserialise(const string &, 620 const map<string, Xapian::PostingSource *> & sources)621 const Xapian::SerialisationContext & ctx) 621 622 { 622 623 throw Xapian::InternalError("query serialisation not compiled in"); 623 624 } -
xapian-core/api/omquery.cc
30 30 31 31 #include "xapian/error.h" 32 32 #include "xapian/postingsource.h" 33 #include "xapian/serialisationcontext.h" 33 34 #include "xapian/termiterator.h" 34 35 35 36 #include <vector> … … 216 217 DEBUGAPICALL_STATIC(Xapian::Query, "Xapian::Query::unserialise", s); 217 218 Query result; 218 219 if (!s.empty()) { 219 std::map<std::string, Xapian::PostingSource *> sources;220 result.internal = Xapian::Query::Internal::unserialise(s, sources);220 SerialisationContext ctx; 221 result.internal = Xapian::Query::Internal::unserialise(s, ctx); 221 222 } 222 223 RETURN(result); 223 224 } 224 225 226 Query 227 Query::unserialise(const std::string & s, const SerialisationContext & ctx) 228 { 229 DEBUGAPICALL_STATIC(Xapian::Query, "Xapian::Query::unserialise", 230 s << ", ctx"); 231 Query result; 232 if (!s.empty()) { 233 result.internal = Xapian::Query::Internal::unserialise(s, ctx); 234 } 235 RETURN(result); 236 } 237 238 225 239 std::string 226 240 Query::get_description() const 227 241 { -
xapian-bindings/csharp/Makefile.am
44 44 SWIGTYPE_p_std__string.cs \ 45 45 SWIGTYPE_p_std__vectorT_std__string_t.cs \ 46 46 SWIGTYPE_p_std__vectorT_Xapian__Query_t.cs \ 47 SerialisationContext.cs \ 47 48 SimpleStopper.cs \ 48 49 Sorter.cs \ 49 50 Stem.cs \ -
xapian-bindings/xapian.i
812 812 %include <xapian/replication.h> 813 813 %include <xapian/valuesetmatchdecider.h> 814 814 815 %ignore Xapian::SerialisationContext::operator=; 816 %include <xapian/serialisationcontext.h> 817 815 818 namespace Xapian { 816 819 817 820 #if defined SWIGPYTHON