[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [p2-dev] @noimplement and @noextend annotation of IQuery

These are the kinds of problems I was trying to describe in https://bugs.eclipse.org/bugs/show_bug.cgi?id=304130. We have made life much more complicated for these clients in order to solve a problem they don't have. Whether or not these queries can be written as _expression_-based queries isn't really the issue - the problem is that only Thomas seems to be able to write (and debug) non-trivial _expression_ queries and clients who don't have a Thomas on hand will end up having to iterate over an entire queryable anyway to manually collect up the matches they care about.


On Wed, Mar 10, 2010 at 3:03 AM, Thomas Hallgren <thomas@xxxxxxx> wrote:
On 03/10/2010 06:36 AM, Meng Xin Zhu wrote:
For example,

A java service records some deselected IUs, the query should exclude
those IUs in that list.

You can use the function unique(). If given an argument that is a Set, that Set is used as the discriminator.

Set<IInstallableUnit> recordedIUs = ...
QueryUtil.createQuery("unique($0)", recordedIUs);

Another simpler case is querying the IUs whose id starts with specified

Use a SimplePattern. A string like 'my.prefix.*' will match anything starting with 'my.prefix.'

QueryUtil.createMatchQuery("id ~= $0", SimplePattern.parse(prefix + '*'));

For more advanced cases that really cannot be resolved only by use of a query, there is often a benefit to start with a query anyway to benefit from indexing and then perform additional filtering as a next step:

HashSet<IInstallableUnit> collector = new HashSet<IInstallableUnit>();
Iterator<IInstallableUnit> iter = queriable.query(<inital query>, monitor).iterator();
while(iter.hasNext()) {
  IInstallableUnit iu = iter.next();

So far, we have seen very few cases where this has been necessary.

- thomas

p2-dev mailing list