[ 
https://issues.apache.org/jira/browse/LUCENE-8890?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16874750#comment-16874750
 ] 

ASF subversion and git services commented on LUCENE-8890:
---------------------------------------------------------

Commit 7c3d6c7214b3ee4f1216fc626551607186962043 in lucene-solr's branch 
refs/heads/master from Sven Amann
[ https://gitbox.apache.org/repos/asf?p=lucene-solr.git;h=7c3d6c7 ]

LUCENE-8890: Improve parallel iteration of two lists of same length. (#446)

The class `BooleanWeight` takes a `BooleanQuery` (a list of `BooleanClause`s) 
as input and maintains a list of weights corresponding to the clauses. The 
clauses and the weights are iterated in parallel in various places throughout 
the class. At these code locations, it is not obvious that these two lists 
always have the same length, i.e., that the parallel iteration is safe. 
Moreover, the parallel iteration is not well supported by the Java language, 
which is why this operation is implemented differently throughout the code.

This patch joins the two lists to enable parallel iteration without managing 
two separate lists. This makes the code’s intent more obvious and prevents bugs 
due to the lists getting out of sync by a future change.

> Parallel Iteration of Lists
> ---------------------------
>
>                 Key: LUCENE-8890
>                 URL: https://issues.apache.org/jira/browse/LUCENE-8890
>             Project: Lucene - Core
>          Issue Type: Task
>            Reporter: Sven Amann
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Solr/contrib/analysis-extras contains the class `BooleanWeight`, which 
> maintains two lists that are repeatedly iterated over in parallel. While both 
> lists do have the same length, this is not immediately obvious from the 
> locations the iterate them. A future change may lead to the lists getting our 
> of sync, which would break the iterations. Moreover, there is no established 
> language feature for iterating two lists, which is why the iteration is 
> implemented differently in various locations throughout the class.
> I created a patch that joins the two lists into one, which simplifies the 
> iteration, unifies the implementation in all places, and prevents that the 
> two lists get out of sync without becoming aware of the parallel iterations.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org
For additional commands, e-mail: dev-h...@lucene.apache.org

Reply via email to