[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
Re: [p2-dev] @noimplement and @noextend annotation of IQuery
|
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
string.
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();
if(mySpecialMatch(iu))
collector.add(iu);
}
So far, we have seen very few cases where this has been necessary.
HTH,
- thomas