Skip to content

Commit 8e337ab

Browse files
committed
LUCENE-9822: Assert that ForUtil.BLOCK_SIZE can be PFOR-encoded in a single byte
For/PFor code has BLOCK_SIZE=128 as a static final constant, with a lot of assumptions and optimizations for that case. For example it will encode 3 exceptions at most and optimizes the exception encoding with a single byte. This would not work at all if you changed the constant in the code to something like 512, but an assertion at an early stage helps make experimentation less painful, and better "documents" the assumption of how the exception encoding currently works.
1 parent 231e3af commit 8e337ab

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lucene/CHANGES.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,8 @@ Other
266266

267267
* LUCENE-9773: Upgrade icu to 68.2 (Robert Muir)
268268

269+
* LUCENE-9822: Add assertion to PFOR exception encoding, documenting the BLOCK_SIZE assumption. (Greg Miller)
270+
269271
======================= Lucene 8.9.0 =======================
270272

271273
API Changes

lucene/core/src/java/org/apache/lucene/codecs/lucene90/PForUtil.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static boolean allEqual(long[] l) {
3737
private final ForUtil forUtil;
3838

3939
PForUtil(ForUtil forUtil) {
40+
assert ForUtil.BLOCK_SIZE <= 256 : "blocksize must fit in one byte. got " + ForUtil.BLOCK_SIZE;
4041
this.forUtil = forUtil;
4142
}
4243

0 commit comments

Comments
 (0)