Bug 56142 - PIM API: limit number of search results
Summary: PIM API: limit number of search results
Status: RESOLVED FIXED
Alias: None
Product: SyncEvolution
Classification: Unclassified
Component: SyncEvolution (show other bugs)
Version: unspecified
Hardware: Other All
: medium enhancement
Assignee: Patrick Ohly
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 56141
  Show dependency treegraph
 
Reported: 2012-10-18 14:37 UTC by Patrick Ohly
Modified: 2012-11-30 14:22 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description Patrick Ohly 2012-10-18 14:37:15 UTC
A natural and useful extension of the API is a way to limit the number of search results. FilteredView then can stop checking more candidates, which avoids excessive CPU (and to some extend, memory) usage when many contacts match a filter.

One corner case is when one of the matched contacts falls out of the result list (removed, updated): then the number of results is reduced and more candidates must be checked to reach the desired number again.
Comment 1 Patrick Ohly 2012-11-28 09:04:58 UTC
Implemented, pending review and further testing:

A 'limit' search term with a number as parameter (formatted as string)
can be added to a 'phone' or 'any-contains' search term to truncate the
search results after a certain number of contacts. Example:
  Search([['any-contains', 'Joe'], ['limit', '10']])
  => return the first 10 Joes.

As with any other search, the resulting view will be updated if
contact data changes.

The limit must not be changed in a RefineSearch(). A 'limit' term may
(but doesn't have to) be given. If it is given, its value must match
the value set when creating the search. This limitation simplifies the
implementation and its testing. The limitation could be removed if
there is sufficient demand.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.