rmuir commented on issue #11932:
URL: https://github.com/apache/lucene/issues/11932#issuecomment-1315559541

   Here's a log of the output from the new check: 
[overflow.log](https://github.com/apache/lucene/files/10014404/overflow.log)
   
   I think it is too noisy to worry about fixing all the code. I plan to do a 
single pass through it and fix anything that looks "real". For example places 
where, `int` accumulator is accidentally used to sum up `long` values with 
`+=`. In these cases the wrong type was used but java threw away all safety 
thanks to `+=`.
   
   Example: 
   ```
   
/home/rmuir/workspace/lucene/lucene/core/src/java/org/apache/lucene/codecs/KnnVectorsWriter.java:141:
 warning: [NarrowingCompoundAssignment] Compound assignments from long to int 
hide lossy casts
           totalCost += sub.values.cost();
                     ^
       (see https://errorprone.info/bugpattern/NarrowingCompoundAssignment)
     Did you mean 'totalCost = (int) (totalCost + sub.values.cost());'?
   ```
   In this case KnnVectorsWriter `totalCost` should simply be a `long` instead 
of `int`. 
   
   Another similar one:
   ```
   
/home/rmuir/workspace/lucene/lucene/core/src/java/org/apache/lucene/util/OfflineSorter.java:302:
 warning: [NarrowingCompoundAssignment] Compound assignments from long to int 
hide lossy casts
           sortInfo.lineCount += part.count;
   ```
   In this case we should change `sortInfo.lineCount` to be a `long` instead of 
`int`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to