|Re: [p2-dev] Contract for compound queryables|
On 03/17/2010 05:40 PM, Ian Bull wrote:
>From what I recall (this is a bit before my time), when the query mechanism was first introduced, it was decided that all query results (then called collectors) would collect things as Sets (unique). Last year, I introduced the notion of List based collectors, but this was never used and I don't think our current infrastructure even supports it.
The reason I'm concerned is that I want to avoid the rather serious performance hit implied by such a contract. A query on a compound queryable must then first bring everything into memory and then deliver an iterator over the unique set to the actual query.
The alternative is to ask the IQueryResult for a set using the toUnmodifiableSet() or toSet() method. If the query result already used a set internally, that operation is free of charge. If not, well, then it has just the matches to consider when building the unique set.
The only time that you would encounter duplicates is probably when you query for all elements and then use the iterator directly.