unofficial mirror of notmuch@notmuchmail.org
 help / color / mirror / code / Atom feed
* [PATCH] ruby: Add wrapper for notmuch_query_count_threads
@ 2014-05-10 21:40 Wael M. Nasreddine
  2014-05-10 21:40 ` Wael M. Nasreddine
  2014-05-10 22:28 ` Felipe Contreras
  0 siblings, 2 replies; 5+ messages in thread
From: Wael M. Nasreddine @ 2014-05-10 21:40 UTC (permalink / raw)
  To: notmuch


This patch exposes query.cc::notmuch_query_count_threads to Ruby, the
benchmark on 85k emails is amazing:

                                user     system      total        real
query.count_threads         6.270000   0.240000   6.510000 (  6.507064)
query.search_threads.count 14.040000   3.130000  17.170000 ( 17.172222)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] ruby: Add wrapper for notmuch_query_count_threads
  2014-05-10 21:40 [PATCH] ruby: Add wrapper for notmuch_query_count_threads Wael M. Nasreddine
@ 2014-05-10 21:40 ` Wael M. Nasreddine
  2014-05-10 22:29   ` Felipe Contreras
  2014-05-17 21:45   ` David Bremner
  2014-05-10 22:28 ` Felipe Contreras
  1 sibling, 2 replies; 5+ messages in thread
From: Wael M. Nasreddine @ 2014-05-10 21:40 UTC (permalink / raw)
  To: notmuch

---
 bindings/ruby/defs.h  |  3 +++
 bindings/ruby/init.c  |  1 +
 bindings/ruby/query.c | 19 +++++++++++++++++++
 3 files changed, 23 insertions(+)

diff --git a/bindings/ruby/defs.h b/bindings/ruby/defs.h
index 5b44585..f4901a0 100644
--- a/bindings/ruby/defs.h
+++ b/bindings/ruby/defs.h
@@ -231,6 +231,9 @@ notmuch_rb_query_search_messages (VALUE self);
 VALUE
 notmuch_rb_query_count_messages (VALUE self);
 
+VALUE
+notmuch_rb_query_count_threads (VALUE self);
+
 /* threads.c */
 VALUE
 notmuch_rb_threads_destroy (VALUE self);
diff --git a/bindings/ruby/init.c b/bindings/ruby/init.c
index 663271d..ab3f22d 100644
--- a/bindings/ruby/init.c
+++ b/bindings/ruby/init.c
@@ -271,6 +271,7 @@ Init_notmuch (void)
     rb_define_method (notmuch_rb_cQuery, "search_threads", notmuch_rb_query_search_threads, 0); /* in query.c */
     rb_define_method (notmuch_rb_cQuery, "search_messages", notmuch_rb_query_search_messages, 0); /* in query.c */
     rb_define_method (notmuch_rb_cQuery, "count_messages", notmuch_rb_query_count_messages, 0); /* in query.c */
+    rb_define_method (notmuch_rb_cQuery, "count_threads", notmuch_rb_query_count_threads, 0); /* in query.c */
 
     /*
      * Document-class: Notmuch::Threads
diff --git a/bindings/ruby/query.c b/bindings/ruby/query.c
index 1658ede..a7dacba 100644
--- a/bindings/ruby/query.c
+++ b/bindings/ruby/query.c
@@ -182,3 +182,22 @@ notmuch_rb_query_count_messages (VALUE self)
      */
     return UINT2NUM(notmuch_query_count_messages(query));
 }
+
+/*
+ * call-seq: QUERY.count_threads => Fixnum
+ *
+ * Return an estimate of the number of threads matching a search
+ */
+VALUE
+notmuch_rb_query_count_threads (VALUE self)
+{
+    notmuch_query_t *query;
+
+    Data_Get_Notmuch_Query (self, query);
+
+    /* Xapian exceptions are not handled properly.
+     * (function may return 0 after printing a message)
+     * Thus there is nothing we can do here...
+     */
+    return UINT2NUM(notmuch_query_count_threads(query));
+}
-- 
1.9.1.423.g4596e3a

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* RE: [PATCH] ruby: Add wrapper for notmuch_query_count_threads
  2014-05-10 21:40 [PATCH] ruby: Add wrapper for notmuch_query_count_threads Wael M. Nasreddine
  2014-05-10 21:40 ` Wael M. Nasreddine
@ 2014-05-10 22:28 ` Felipe Contreras
  1 sibling, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-10 22:28 UTC (permalink / raw)
  To: Wael M. Nasreddine, notmuch

Wael M. Nasreddine wrote:
> This patch exposes query.cc::notmuch_query_count_threads to Ruby, the
> benchmark on 85k emails is amazing:

I meant to do this but forgot. Thanks!

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] ruby: Add wrapper for notmuch_query_count_threads
  2014-05-10 21:40 ` Wael M. Nasreddine
@ 2014-05-10 22:29   ` Felipe Contreras
  2014-05-17 21:45   ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: Felipe Contreras @ 2014-05-10 22:29 UTC (permalink / raw)
  To: Wael M. Nasreddine, notmuch

Wael M. Nasreddine wrote:
> ---
>  bindings/ruby/defs.h  |  3 +++
>  bindings/ruby/init.c  |  1 +
>  bindings/ruby/query.c | 19 +++++++++++++++++++
>  3 files changed, 23 insertions(+)

LGTM.

-- 
Felipe Contreras

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] ruby: Add wrapper for notmuch_query_count_threads
  2014-05-10 21:40 ` Wael M. Nasreddine
  2014-05-10 22:29   ` Felipe Contreras
@ 2014-05-17 21:45   ` David Bremner
  1 sibling, 0 replies; 5+ messages in thread
From: David Bremner @ 2014-05-17 21:45 UTC (permalink / raw)
  To: Wael M. Nasreddine, notmuch

"Wael M. Nasreddine" <wael.nasreddine@gmail.com> writes:

> ---
>  bindings/ruby/defs.h  |  3 +++
>  bindings/ruby/init.c  |  1 +
>  bindings/ruby/query.c | 19 +++++++++++++++++++
>  3 files changed, 23 insertions(+)

pushed.  FYI in general we like commit messages a bit more verbose,
although I have to admit I don't what to add here.

d

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-05-17 21:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-10 21:40 [PATCH] ruby: Add wrapper for notmuch_query_count_threads Wael M. Nasreddine
2014-05-10 21:40 ` Wael M. Nasreddine
2014-05-10 22:29   ` Felipe Contreras
2014-05-17 21:45   ` David Bremner
2014-05-10 22:28 ` Felipe Contreras

Code repositories for project(s) associated with this public inbox

	https://yhetil.org/notmuch.git/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).