[Xapian-discuss] Remote access to database
Olly Betts
olly at survex.com
Thu Jul 14 12:37:37 BST 2005
On Wed, Jul 13, 2005 at 02:38:41AM +0100, Olly Betts wrote:
> I'm not sure where the problem lies though. It really looked like it
> should work - I'll have to think about this...
Aha! I worked it out - converting boolean values to strings was
producing "true" and "false", but the conversion back was using
istream and >> so both of these were taken as 0/false.
The attached patch passes the testsuite at least. It's against SVN
trunk, but I think it should apply cleanly to 0.9.1.
Cheers,
Olly
-------------- next part --------------
Index: matcher/networkmatch.cc
===================================================================
--- matcher/networkmatch.cc (revision 6325)
+++ matcher/networkmatch.cc (working copy)
@@ -38,22 +38,27 @@
const Xapian::RSet & omrset,
Xapian::valueno collapse_key,
Xapian::Enquire::docid_order order,
+ Xapian::valueno sort_key,
+ bool sort_by_relevance,
+ bool sort_value_forward,
int percent_cutoff, Xapian::weight weight_cutoff,
StatsGatherer *gatherer_,
const Xapian::Weight *wtscheme)
: is_prepared(false), db(db_), gatherer(gatherer_)
-{
+{
DEBUGCALL(MATCH, void, "RemoteSubMatch", db_ << ", " << query << ", " <<
- qlen << ", " <<
- omrset << ", " << collapse_key << ", " << int(order) << ", " <<
+ qlen << ", " << omrset << ", " << collapse_key << ", " <<
+ int(order) << ", " << sort_key << ", " <<
+ sort_by_relevance << ", " << sort_value_forward << ", " <<
percent_cutoff << ", " << weight_cutoff << ", " << gatherer_);
Assert(db);
Assert(query);
Assert(gatherer_);
statssource = new NetworkStatsSource(gatherer_, db->link);
- db->link->set_query(query, qlen, collapse_key, order, percent_cutoff,
- weight_cutoff, wtscheme, omrset);
+ db->link->set_query(query, qlen, collapse_key, order,
+ sort_key, sort_by_relevance, sort_value_forward,
+ percent_cutoff, weight_cutoff, wtscheme, omrset);
db->link->register_statssource(statssource);
AutoPtr<RSetI> new_rset(new RSetI(db, omrset));
Index: matcher/multimatch.cc
===================================================================
--- matcher/multimatch.cc (revision 6325)
+++ matcher/multimatch.cc (working copy)
@@ -339,18 +339,14 @@
#ifdef XAPIAN_BUILD_BACKEND_REMOTE
const NetworkDatabase *netdb = subdb->as_networkdatabase();
if (netdb) {
- if (sort_key != Xapian::valueno(-1)) {
- // And neither is sort_value_forward, but that's ignored
- // unless we're sorting on a value.
- throw Xapian::UnimplementedError("sorting on a value is not supported with remote backend");
- }
if (bias_halflife) {
throw Xapian::UnimplementedError("bias_halflife and bias_weight not supported with remote backend");
}
smatch = Xapian::Internal::RefCntPtr<SubMatch>(
new RemoteSubMatch(netdb, query, qlen,
- *subrset, collapse_key,
- order, percent_cutoff, weight_cutoff,
+ *subrset, collapse_key, order,
+ sort_key, sort_by_relevance, sort_value_forward,
+ percent_cutoff, weight_cutoff,
gatherer.get(), weight));
} else {
#endif /* XAPIAN_BUILD_BACKEND_REMOTE */
Index: matcher/networkmatch.h
===================================================================
--- matcher/networkmatch.h (revision 6325)
+++ matcher/networkmatch.h (working copy)
@@ -68,6 +68,8 @@
const Xapian::RSet & omrset,
Xapian::valueno collapse_key,
Xapian::Enquire::docid_order order,
+ Xapian::valueno sort_key,
+ bool sort_by_relevance, bool sort_value_forward,
int percent_cutoff, Xapian::weight weight_cutoff,
StatsGatherer *gatherer_, const Xapian::Weight *wtscheme);
Index: tests/api_db.cc
===================================================================
--- tests/api_db.cc (revision 6326)
+++ tests/api_db.cc (working copy)
@@ -1367,6 +1367,7 @@
{"stubdb1", test_stubdb1},
{"keepalive1", test_keepalive1},
{"termstats", test_termstats},
+ {"sortvalue1", test_sortvalue1},
{0, 0}
};
Index: net/socketserver.cc
===================================================================
--- net/socketserver.cc (revision 6326)
+++ net/socketserver.cc (working copy)
@@ -282,6 +283,8 @@
Xapian::termcount qlen;
Xapian::Enquire::docid_order order;
+ Xapian::valueno sort_key;
+ bool sort_by_relevance, sort_value_forward;
Xapian::valueno collapse_key;
int percent_cutoff;
Xapian::weight weight_cutoff;
@@ -294,7 +297,9 @@
istrstream is(message.data(), message.length());
#endif
int order_int;
- is >> qlen >> collapse_key >> order_int >> percent_cutoff >> weight_cutoff;
+ is >> qlen >> collapse_key >> order_int
+ >> sort_key >> sort_by_relevance >> sort_value_forward
+ >> percent_cutoff >> weight_cutoff;
order = Xapian::Enquire::docid_order(order_int);
}
Index: net/socketclient.cc
===================================================================
--- net/socketclient.cc (revision 6332)
+++ net/socketclient.cc (working copy)
@@ -385,6 +385,8 @@
Xapian::termcount qlen,
Xapian::valueno collapse_key,
Xapian::Enquire::docid_order order,
+ Xapian::valueno sort_key,
+ bool sort_by_relevance, bool sort_value_forward,
int percent_cutoff, Xapian::weight weight_cutoff,
const Xapian::Weight *wtscheme,
const Xapian::RSet &omrset_)
@@ -397,8 +399,10 @@
Assert(conv_state == state_getquery);
// FIXME: no point carefully serialising these all separately...
query_string = query_->serialise();
- optstring = om_tostring(qlen) + ' ' + om_tostring(collapse_key) +
- ' ' + om_tostring(int(order)) + ' ' +
+ optstring = om_tostring(qlen) + ' ' + om_tostring(collapse_key) + ' ' +
+ om_tostring(int(order)) + ' ' + om_tostring(sort_key) + ' ' +
+ om_tostring(sort_by_relevance) + ' ' +
+ om_tostring(sort_value_forward) + ' ' +
om_tostring(percent_cutoff) + ' ' + om_tostring(weight_cutoff);
wtstring = wtscheme->name() + '\n' + wtscheme->serialise();
omrset = omrset_;
Index: common/utils.cc
===================================================================
--- common/utils.cc (revision 6326)
+++ common/utils.cc (working copy)
@@ -92,7 +92,7 @@
string
om_tostring(bool val)
{
- return val ? "true" : "false";
+ return val ? "1" : "0";
}
void
Index: common/socketcommon.h
===================================================================
--- common/socketcommon.h (revision 6325)
+++ common/socketcommon.h (working copy)
@@ -35,7 +35,8 @@
using std::map;
// 18: Removed OP_WEIGHT_CUTOFF
-#define XAPIAN_SOCKET_PROTOCOL_VERSION 18
+// 19: Remote backend now supports sorting on a value
+#define XAPIAN_SOCKET_PROTOCOL_VERSION 19
class Stats;
class OmTime;
Index: common/netclient.h
===================================================================
--- common/netclient.h (revision 6325)
+++ common/netclient.h (working copy)
@@ -76,6 +76,8 @@
Xapian::termcount qlen,
Xapian::valueno collapse_key,
Xapian::Enquire::docid_order order,
+ Xapian::valueno sort_key,
+ bool sort_by_relevance, bool sort_value_forward,
int percent_cutoff, Xapian::weight weight_cutoff,
const Xapian::Weight *wtscheme,
const Xapian::RSet &omrset_) = 0;
Index: common/socketclient.h
===================================================================
--- common/socketclient.h (revision 6325)
+++ common/socketclient.h (working copy)
@@ -194,6 +194,8 @@
Xapian::termcount qlen,
Xapian::valueno collapse_key,
Xapian::Enquire::docid_order order,
+ Xapian::valueno sort_key,
+ bool sort_by_relevance, bool sort_value_forward,
int percent_cutoff, Xapian::weight weight_cutoff,
const Xapian::Weight *wtscheme,
const Xapian::RSet &omrset_);
More information about the Xapian-discuss
mailing list