mirror of https://github.com/apache/lucene.git
Change `set.removeAll(list)` to `list.forEach(set::remove)` (#13052)
This commit is contained in:
parent
d988f91aba
commit
39c10a2929
|
@ -228,6 +228,8 @@ Optimizations
|
|||
this will help boolean queries that consist of a mix OF FILTER clauses and
|
||||
SHOULD clauses. (Adrien Grand)
|
||||
|
||||
* GITHUB#13052: Avoid set.removeAll(list) O(n^2) performance trap in the UpgradeIndexMergePolicy (Dmitry Cherniachenko)
|
||||
|
||||
Bug Fixes
|
||||
---------------------
|
||||
* GITHUB#12866: Prevent extra similarity computation for single-level HNSW graphs. (Kaival Parikh)
|
||||
|
|
|
@ -106,7 +106,11 @@ public class UpgradeIndexMergePolicy extends FilterMergePolicy {
|
|||
// the resulting set contains all segments that are left over
|
||||
// and will be merged to one additional segment:
|
||||
for (final OneMerge om : spec.merges) {
|
||||
oldSegments.keySet().removeAll(om.segments);
|
||||
// om.segments.forEach(::remove) is used here instead of oldSegments.keySet().removeAll()
|
||||
// for performance reasons; when om.segments.size() == oldSegments.size()
|
||||
// the AbstractSet#removeAll() implementation will iterate the set elements
|
||||
// calling list.contains() for each of them, resulting in O(n^2) performance
|
||||
om.segments.forEach(oldSegments::remove);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue