The bitsRequired passed during NodeHash rehash (when building an FST) (#12545)

This commit is contained in:
Michael McCandless 2023-09-09 19:14:18 -04:00 committed by GitHub
parent a7202e2e6f
commit 57dd5a4bda
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -146,7 +146,7 @@ final class NodeHash<T> {
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<T> {
}
}
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);