From 57dd5a4bda89d417174f3e672a657b1176c6fbeb Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Sat, 9 Sep 2023 19:14:18 -0400 Subject: [PATCH] The bitsRequired passed during NodeHash rehash (when building an FST) (#12545) --- .../src/java/org/apache/lucene/util/fst/NodeHash.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java b/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java index 4732bc07771..92a878b1fbb 100644 --- a/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java +++ b/lucene/core/src/java/org/apache/lucene/util/fst/NodeHash.java @@ -146,7 +146,7 @@ final class NodeHash { table.set(pos, node); // Rehash at 2/3 occupancy: if (count > 2 * table.size() / 3) { - rehash(); + rehash(node); } return node; } else if (nodesEqual(nodeIn, v)) { @@ -174,12 +174,15 @@ final class NodeHash { } } - private void rehash() throws IOException { + private void rehash(long lastNodeAddress) throws IOException { final PagedGrowableWriter oldTable = table; table = new PagedGrowableWriter( - 2 * oldTable.size(), 1 << 30, PackedInts.bitsRequired(count), PackedInts.COMPACT); + 2 * oldTable.size(), + 1 << 27, + PackedInts.bitsRequired(lastNodeAddress), + PackedInts.COMPACT); mask = table.size() - 1; for (long idx = 0; idx < oldTable.size(); idx++) { final long address = oldTable.get(idx);