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.
This commit is contained in:
Robert Muir 2021-03-04 18:58:12 -05:00
parent 231e3afe06
commit 8e337ab63f
No known key found for this signature in database
GPG Key ID: 817AE1DD322D7ECA
2 changed files with 3 additions and 0 deletions

View File

@ -266,6 +266,8 @@ Other
* LUCENE-9773: Upgrade icu to 68.2 (Robert Muir)
* LUCENE-9822: Add assertion to PFOR exception encoding, documenting the BLOCK_SIZE assumption. (Greg Miller)
======================= Lucene 8.9.0 =======================
API Changes

View File

@ -37,6 +37,7 @@ final class PForUtil {
private final ForUtil forUtil;
PForUtil(ForUtil forUtil) {
assert ForUtil.BLOCK_SIZE <= 256 : "blocksize must fit in one byte. got " + ForUtil.BLOCK_SIZE;
this.forUtil = forUtil;
}