Commit Graph

74 Commits

Author SHA1 Message Date
Dirk-Jan C. Binnema 810b9643f4 query: exclude some test code from coverage 2022-06-29 22:20:09 +03:00
Dirk-Jan C. Binnema 30e7b5d9ec lib: move 3rd party code to thirdparty; add tabulate.hpp
Move 3rd-party code to their own dir, and add the nice tabulate.hpp
2022-04-30 10:40:45 +03:00
Dirk-Jan C. Binnema 459f6db476 query: update query subsys to use Message 2022-04-30 10:40:45 +03:00
Dirk-Jan C. Binnema 27ebfb3b3c lib+guile: use Mu::Option, not std::optional
We need the extensions, and/or let's use _one_ optional implementation everywhere.
2022-03-28 08:58:04 +03:00
Dirk-Jan C. Binnema f7c84006d7 many: update for lib/message updates
Adapt to the new names / directory. Big commit, but mostly just very boring renaming.
2022-03-26 17:19:10 +02:00
Dirk-Jan C. Binnema 0df7a6959a lib/query,parser: update to use mu-message-fields 2022-03-04 00:06:31 +02:00
Dirk-Jan C. Binnema 5fc8a8f83e store/query: access query only through store
Make Mu::Query only accessible through store, so we can lock the db for the
duration of a (full, multipass) query.
2022-01-30 14:52:41 +02:00
Dirk-Jan C. Binnema 9a2fd441c5 mu-query: honor maxnum in threaded queries 2021-10-23 11:06:45 +03:00
Dirk-Jan C. Binnema 3dd721d5a3 clang-format: update c/cc coding style
Update all cc code using .clang-format; please do so as well for future PRs
etc.; emacs has a handy 'clang-format' mode to make this automatic.

For comparing old changes with git blame, we can disregard this one using
--ignore-rev

(see https://www.moxio.com/blog/43/ignoring-bulk-change-commits-with-git-blame )
2021-10-20 12:26:16 +03:00
Dirk-Jan C. Binnema 49637dbc3a lib: replace CATCH_BLOCK macros with template magic 2021-10-18 21:52:37 +03:00
Nicolas Avrutin ee4bf5664a query: fix include-related.
mu-query.cc:
- make_related_enquire: don't include first query in qvec, we already have all
  thread IDs we need to query in thread_ds.
- run_related: always sort first query by date, explained by the comment.
- run_related: include qflags (in particular ascending vs descending) in
  leader_qflags.
- run_theaded: don't limit results to maxnum, that results in threads
  potentially being cut off.

mu-server.cc:
- output_sexp: don't limit results to maxnum so as to match the behaviour of
  mu find (and avoid cuttong off threads).

Fixes #1924 and #1911.
2021-07-11 16:23:39 -04:00
Dirk-Jan C. Binnema 619509eb56 query-results: remove GatherThreadIds
We can't really do that in the match-decider, since we get _all_ messages
there, not the <n>-limited.

And some whitespace changes.
2021-06-17 20:54:59 +03:00
Dirk-Jan C. Binnema 047c10453a query: gather related ids from mset, not match-decider
Since we only want the (smaller) set from the mset, not the (full) set
that the match-decider sees.
2021-06-04 00:54:28 +03:00
Dirk-Jan C. Binnema 750a9d1626 query: Better debug logging 2021-03-17 18:33:45 +02:00
Dirk-Jan C. Binnema 98a742e5e5 query: honor maxnum in threaded searches 2021-02-15 22:45:33 +02:00
Dirk-Jan C. Binnema 108a33f16e query: avoid expected warning
Remove some debug leftover.
2021-02-15 21:43:47 +02:00
Dirk-Jan C. Binnema 579f841bdd query: filter out docs without query-matches
This avoid including unwanted messages in threaded results.
Also some cleanups.
2021-02-15 19:11:22 +02:00
Dirk-Jan C. Binnema bba8af8d51 mu-query: tweaks threaded/threaded querying 2021-02-13 00:48:07 +02:00
Dirk-Jan C. Binnema ffc809a01e query: improve thread-key-maker
For threading, we still get the _full_ set of messages (since the mset is
limited, but not the enquire); so no need to warn about docids we
haven't seen before.

Also, ensure the unwanted docids are sorted after the wanted ones.

Fixes: #1926.
2021-02-12 19:14:37 +02:00
Dirk-Jan C. Binnema 936fd3f485 mu-query: sort "related" input by date
When doing 'related' searches, sort the initial (bounded) query results
by date, so we get the newest (or oldest)
2021-02-10 22:04:42 +02:00
Dirk-Jan C. Binnema 6ff9829ce1 lib: improve threaded sorting
Improve threaded sorting:
- rework the recursive algo (which should a crash noted earlier)
- sort by thread key (as in 1.5.7)

Fixes: #1923
Fixes: #1922
Fixes: #1911
Fixes: #1916
2021-02-10 12:35:19 +02:00
Dirk-Jan C. Binnema 086999c2d1 query: in related/threaded mode, search all
In the related query, search _all_ messages, not just the amount asked;
this increases the chance of full threads.
2021-01-25 10:12:48 +02:00
Dirk-Jan C. Binnema 95dffb98a6 query: Rework querying/threading machinery
Rewrite the query machinery in c++:
- use an MSet decorator instead of the mu-msg-iter stuff
- use mu-query-decider to mark duplicates/unreadable/related messages
- use mu-query-threader to replace the older container/thread code

Algorithm did not substantially change, but the implementation details
did.
2021-01-20 14:09:04 +02:00
Dirk-Jan C. Binnema ed4a640c39 lib/query: refactor & rework
- Move the lib/query/ stuff up a level into lib/
- Associate directly with the Query object
- Rework the Query object to be C++ rather than mixed with C
- Update all dependencies, tests
2020-11-04 23:35:30 +02:00
Dirk-Jan C. Binnema 69b157a346 lib: improve error handling, cleanups 2020-10-31 09:46:13 +02:00
Dirk-Jan C. Binnema 148c906d8a fix compilation error / clang warnings 2020-07-25 11:26:08 +03:00
Dirk-Jan C. Binnema 3e233cba9a rework logging system
reimplement the old mu-log.[ch] into mu-logging.{cc,hh}

If available (and using an appropriately equipped glib), log to the
systemd journal

Only g_criticals have stderr output, all the other g_* go to the log
file / journal.
2020-05-30 13:29:44 +03:00
Dirk-Jan C. Binnema 46ae663937 mu4e: use faster count queries, document differences
Use faster queries for counting read/unread messages; document why the
results might differ from what you get doing a normal search.
2020-03-15 01:23:01 +02:00
Dirk-Jan C. Binnema 20ce7b7066 lib/parser -> lib/query
And update the names to follow the mu- convention.
2020-02-20 21:53:48 +02:00
Dirk-Jan C. Binnema bdec1fe9c4 mu-query: implement mu_query_count_run
To get the number of matches and nothing else.
2020-01-22 11:42:15 +02:00
Dirk-Jan C. Binnema 97afdd9e3c lib: Use Mu:Error exception
Where applicable.
2020-01-01 13:25:07 +02:00
Dirk-Jan C. Binnema 9f93526884 move parser/utils to utils, Mux->Mu
Move the parser utils to utils/ and rename the Mux namespace into Mu.
2019-12-22 15:26:45 +02:00
Dirk-Jan C. Binnema b55e191421 update for lib/utils split
Update sources with the new paths
2019-12-22 15:26:45 +02:00
Dirk-Jan C. Binnema 83d6484f86 lib/mu-store: rework implementation
* mu-store.h, mu-store-read.cc, mu-store-write.cc, mu-store-priv.hh have been reworked
   in mu-store.{cc,hh}, it the mix of c/c++ improved
 * update all the dependent modules
 * make it easier to upgrade an database in place (without user intervention)
 * remove the xbatch-size option
2019-07-30 08:51:04 +03:00
Nicolas Avrutin eb9bfbb1ca Perform threading calculation on related set instead of entire result.
The current threading algorithm is applied to the entire result of a query, even
if maxnum is specified, and then the result of the threading algorithm is
truncated to maxnum. The improves threading results by returning the entire
thread even when only a single message makes it into the top maxnum results.

This commit applies the threading algorithm to the related message set of the
maxnum-truncated query result instead of to the entire query result. For a given
set of messages, the set of messages which will share threads with any of the
original messages is exactly the related message sets. Put another way, either
any messages returned by the original query but removed by the maxnum truncation
will also be returned by the related message query, or they would not have been
needed anyway because they would not be members of any visible thread.

To maintain backward compatibility and allow threading to be used without
including related messages, the related message set is found for the threading
calculation, but any messages which would not have matched the original query
are then pruned, resulting in a superset of the truncated query, but a subset of
the untruncated query.

This does not improve (or degrade) the run time of a threading calculation when
maxnum is not set, but significant improves it when maxnum is set by making it
scale (roughly) linearly in terms of maxnum. On a maildir with ~200k messages
and maxnum set to 500 (the default), the run time of a threading calculation is
lowered from ~1m to ~0.1s.

Perform threading calculation on related set instead of entire result.

The current threading algorithm is applied to the entire result of a query, even
if maxnum is specified, and then the result of the threading algorithm is
truncated to maxnum. The improves threading results by returning the entire
thread even when only a single message makes it into the top maxnum results.

This commit applies the threading algorithm to the related message set of the
maxnum-truncated query result instead of to the entire query result. For a given
set of messages, the set of messages which will share threads with any of the
original messages is exactly the related message sets. Put another way, either
any messages returned by the original query but removed by the maxnum truncation
will also be returned by the related message query, or they would not have been
needed anyway because they would not be members of any visible thread.

To maintain backward compatibility and allow threading to be used without
including related messages, the related message set is found for the threading
calculation, but any messages which would not have matched the original query
are then pruned, resulting in a superset of the truncated query, but a subset of
the untruncated query.

This does not improve (or degrade) the run time of a threading calculation when
maxnum is not set, but significant improves it when maxnum is set by making it
scale (roughly) linearly in terms of maxnum. On a maildir with ~200k messages
and maxnum set to 500 (the default), the run time of a threading calculation is
lowered from ~1m to ~0.1s.
2018-07-09 02:41:22 -04:00
djcb 620912c62b mu: support 'raw' query (internally)
Allow for passing 'raw' queries to xapian, without any parsing.
2017-12-03 22:16:32 +02:00
djcb d18e0a1d84 query: don't be too eager matching field names
only match shortcuts when the field length was 1.
2017-11-02 08:06:48 +02:00
djcb 6053c1ec1f mu: fix clang build
casting error
2017-10-30 08:25:43 +02:00
djcb 509500a9d2 server: update query processing
fix quoting issues with mu4e
2017-10-27 18:43:33 +03:00
djcb aa07c4a27c update commands for new query parser 2017-10-25 23:50:17 +03:00
djcb 5e9cafea59 integrate new query parser 2017-10-25 23:50:17 +03:00
djcb 78275278cf mu: fix some compiler warnings 2016-12-11 18:33:31 +02:00
Stig Brautaset e9c6568a57 mu: swap begin and end if begin is _numerically_ bigger than end
The old behaviour would compare the strings, so would swap the start and end
ranges if start was 3K and end was 2M.

Fixes: 964
2016-12-03 23:19:27 +00:00
djcb baebd53fb8 Fix a core dump under OpenBSD
Based on a patch by StAlphonsos
2015-03-06 00:12:34 +02:00
djcb 13bad9a889 * better error message for some broken queries 2013-09-07 09:43:33 +03:00
djcb 312c3a4b20 * cosmetic 2013-07-03 21:56:42 +03:00
djcb 13efc74793 * mu-query: better handle empty lhs/rhs in date intervals 2013-06-03 22:29:50 +03:00
djcb b136ca0411 * try harder to match special strings 2013-05-29 07:33:17 -07:00
djcb 5d069e786f * lib: updates for mu-msg-field / mu-str updates 2013-05-13 00:03:47 +03:00
djcb 5c95a1851d * lib: update comment 2013-05-04 14:14:58 +03:00