* mu-query-xapian.{cc,h}: add batch param, add documentation, cosmetics

This commit is contained in:
Dirk-Jan C. Binnema
2010-01-24 00:51:17 +02:00
parent 74b2cc5e69
commit 0a90c0e350
2 changed files with 19 additions and 10 deletions

View File

@ -169,13 +169,14 @@ mu_query_xapian_destroy (MuQueryXapian *self)
MuMsgIterXapian*
mu_query_xapian_run (MuQueryXapian *self, const char* searchexpr,
const MuMsgField* sortfield, gboolean ascending)
const MuMsgField* sortfield, gboolean ascending,
size_t batchsize)
{
g_return_val_if_fail (self, NULL);
g_return_val_if_fail (searchexpr, NULL);
try {
g_return_val_if_fail (searchexpr, NULL);
g_return_val_if_fail (batchsize>0, NULL);
try {
Xapian::Query q(get_query(self, searchexpr));
Xapian::Enquire enq (*self->_db);
@ -184,10 +185,10 @@ mu_query_xapian_run (MuQueryXapian *self, const char* searchexpr,
(Xapian::valueno)mu_msg_field_id(sortfield),
ascending);
enq.set_query (q);
enq.set_cutoff (0,0);
enq.set_query(q);
enq.set_cutoff(0,0);
return mu_msg_iter_xapian_new (enq, 10000); /* FIXME */
return mu_msg_iter_xapian_new (enq, batchsize);
} MU_XAPIAN_CATCH_BLOCK_RETURN(NULL);
}

View File

@ -67,6 +67,11 @@ char* mu_query_xapian_version (MuQueryXapian *store);
*
* @param self a valid MuQueryXapian instance
* @param expr the search expression
* @param sortfield the field to sort by
* @param ascending if TRUE sort in ascending (A-Z) order, otherwise,
* sort in descending (Z-A) order
* @param batchsize the size of batches to receive; this is mainly for
* reasons - it's best to get the size one wants to show the user at once
*
* @return a MuMsgIterXapian instance you can iterate over, or NULL in
* case of error
@ -74,7 +79,8 @@ char* mu_query_xapian_version (MuQueryXapian *store);
MuMsgIterXapian* mu_query_xapian_run (MuQueryXapian *self,
const char* expr,
const MuMsgField* sortfield,
gboolean ascending)
gboolean ascending,
size_t batchsize)
G_GNUC_WARN_UNUSED_RESULT;
/**
@ -89,7 +95,8 @@ G_GNUC_WARN_UNUSED_RESULT;
* case of error; free with g_free when it's no longer needed
*/
char* mu_query_xapian_combine (const gchar **params,
gboolean connect_or) G_GNUC_WARN_UNUSED_RESULT;
gboolean connect_or)
G_GNUC_WARN_UNUSED_RESULT;
/**
* get a string representation of the Xapian search query
@ -101,7 +108,8 @@ char* mu_query_xapian_combine (const gchar **params,
* error; free the returned value with g_free
*/
char* mu_query_xapian_as_string (MuQueryXapian *self,
const char* searchexpr) G_GNUC_WARN_UNUSED_RESULT;
const char* searchexpr)
G_GNUC_WARN_UNUSED_RESULT;
G_END_DECLS