Skip to content

Fix long byte decoder input position for nonzero offsets - #74

Merged
lemire merged 1 commit into
masterfrom
fix-long-byte-decoder-input-offset
Oct 23, 2026
Merged

lemire merged 1 commit into
masterfrom
fix-long-byte-decoder-input-offset

Conversation

@lemire

@lemire lemire commented Oct 23, 2026

Copy link
Copy Markdown
Member

LongVariableByte.uncompress(byte[]) has the same cursor bug as the int byte decoders in #73. The scan index p already starts at inpos.get(), and inpos.add(p) applies a nonzero offset a second time. Decoding a four-byte block that starts at 1 leaves the cursor at 6 instead of 5, so the next block is read from the wrong place. A zero-length decode also moves a nonzero cursor (5 becomes 10).

Store the absolute end position with inpos.set(p). Offset 0 is unchanged, because p finishes at inlength. The long[] compress and uncompress paths already advance by a length, not by an absolute index.

The new tests fail on the old inpos.add(p) (expected:<5> but was:<6> for a four-byte block at offset 1, and expected:<5> but was:<10> for an empty decode). mvn test passes: 105 tests, 1 existing skip.

The byte-array decoder scans with an absolute index that already starts
at inpos, then added that index to the original offset. A nonzero offset
was applied twice, and a zero-length decode moved a nonzero cursor.
Store the absolute end position, matching the int byte decoders.
@lemire
lemire merged commit 982df74 into master Oct 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant