apache / apache/lucene

BulkOperationPacked decode() bug

Open
#12,225 3 comments 0 reactions 0 assignees View on GitHub
type:bug
Dominant language
Java
Stars
3.6k
Forks
1.4k
Avg merge
2d 11h
Merged PRs (30d)
88

Description

### Description

public void decode(
byte[] blocks, int blocksOffset, long[] values, int valuesOffset, int iterations) {
long nextValue = 0L;
int bitsLeft = bitsPerValue;
for (int i = 0; i < iterations * byteBlockCount; ++i) {
final long bytes = blocks[blocksOffset++] & 0xFFL;
if (bitsLeft > 8) {
// just buffer
bitsLeft -= 8;
nextValue |= bytes << bitsLeft;
} else {
// flush
int bits = 8 - bitsLeft;
values[valuesOffset++] = nextValue | (bytes >>> bits);
while (bits >= bitsPerValue) {
bits -= bitsPerValue;
values[valuesOffset++] = (bytes >>> bits) & mask;
}
// then buffer
bitsLeft = bitsPerValue - bits;
nextValue = (bytes & ((1L << bits) - 1)) << bitsLeft;
}
}
assert bitsLeft == bitsPerValue;
}
maybe use for 【iterations * byteValueCount】

### Version and environment details

_No response_

Contributor guide

Open the contributing guide

Research direction

Start by locating BulkOperationPacked.decode() and compare its loop bound with the suggested iterations * byteValueCount expression. Verify how byteBlockCount and byteValueCount are defined and reproduce the decoding behavior with the existing Lucene tests; done means the method consumes the correct number of bytes and decodes all requested values correctly.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
search
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.