frzhanguber opened a new issue, #12200: URL: https://github.com/apache/lucene/issues/12200
### Description when loading with a dense graph with M=64 and beamWidth=400, the following part graphOffsetsByLevel calculation overflows, since both M, Integer.BYTES and numNodesOnLevel0 are integer, it assumes the result is an integer as well, which is a long (offset) ``` graphOffsetsByLevel[level] = (1 + (M * 2)) * Integer.BYTES * numNodesOnLevel0; ``` A fix could be ``` graphOffsetsByLevel[level] = (1 + (M * 2)) * Integer.BYTES * (long) numNodesOnLevel0; ``` The code snippet: ``` // calculate for each level the start offsets in vectorIndex file from where to read // neighbours graphOffsetsByLevel = new long[numLevels]; for (int level = 0; level < numLevels; level++) { if (level == 0) { graphOffsetsByLevel[level] = 0; } else if (level == 1) { int numNodesOnLevel0 = size; graphOffsetsByLevel[level] = (1 + (M * 2)) * Integer.BYTES * numNodesOnLevel0; } else { int numNodesOnPrevLevel = nodesByLevel[level - 1].length; graphOffsetsByLevel[level] = graphOffsetsByLevel[level - 1] + (1 + M) * Integer.BYTES * numNodesOnPrevLevel; } } } ``` ### Version and environment details Lucene 9.4.1 -- 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.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