Skip to content

Commit

Permalink
Avoid unnecessary memory allocation in PackedLongValues#Iterator (#13439
Browse files Browse the repository at this point in the history
)

We always allocate a long array of page size for a new PackedLongValues#Iterator instance, which is not necessary when packing a small number of values. this is more evident in the scenario of high-frequency flush operations
  • Loading branch information
easyice committed Jun 4, 2024
1 parent bff14fb commit e8801bf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion lucene/CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ Improvements

Optimizations
---------------------
(No changes)

* GITHUB#13439: Avoid unnecessary memory allocation in PackedLongValues#Iterator. (Zhang Chao)

Bug Fixes
---------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ public final class Iterator {
int currentCount; // number of entries of the current page

Iterator() {
currentValues = new long[pageMask + 1];
currentValues = new long[(int) Math.min(size, pageMask + 1)];
vOff = pOff = 0;
fillBlock();
}
Expand Down

0 comments on commit e8801bf

Please sign in to comment.