Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ Optimizations

* GITHUB#15742: Optimize int4 dotProduct and squareDistance computations by replacing vector conversions with reinterpret casting + bit manipulation. (Trevor McCulloch, Kaival Parikh)

* GITHUB#15779: Improve BytesRefHash.add performance by optimize rehash operation (tyronecai)

Bug Fixes
---------------------
* GITHUB#15668: Fix UnsupportedOperationException in WeightedSpanTermExtractor by
Expand Down
13 changes: 12 additions & 1 deletion lucene/core/src/java/org/apache/lucene/util/BytesRefHash.java
Original file line number Diff line number Diff line change
Expand Up @@ -441,14 +441,25 @@ private void rehash(final int newSize, boolean hashOnData) {
bytesUsed.addAndGet(Integer.BYTES * (long) newSize);
final int[] newHash = new int[newSize];
Arrays.fill(newHash, -1);

// calculate all hash values sequentially at once,
// which is much faster than out-of-order computation
int[] hashcodes = null;
if (hashOnData) {
hashcodes = new int[count];
for (int i = 0; i < count; i++) {
hashcodes[i] = pool.hash(bytesStart[i]);
}
}

for (int i = 0; i < hashSize; i++) {
int e0 = ids[i];
if (e0 != -1) {
e0 &= hashMask;
final int hashcode;
int code;
if (hashOnData) {
hashcode = code = pool.hash(bytesStart[e0]);
hashcode = code = hashcodes[e0];
} else {
code = bytesStart[e0];
hashcode = 0;
Expand Down
Loading