[common] Make BinaryRow.anyNull respect the row offset - #9525
Open
LuciferYang wants to merge 1 commit into
Open
Conversation
anyNull() read the header word and the null-bit words from segments[0] at absolute positions 0 and i, while every other accessor in the class reads through the row's offset. A row pointed at a non-zero offset therefore answered from another row's bytes, and anyNull() could disagree with isNullAt() about the same row. Both reads now add the offset. The four in-repo callers pass rows from BinaryRow.copy(), which re-points the copy at offset 0, so no current code path is affected. Non-zero offsets do occur, from BinaryRowSerializer.pointTo when mapFromPages points a row at the bytes after a length prefix. Assisted-by: GLM-5.3
Contributor
Author
|
The |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
close #9524
BinaryRow.anyNull()read the header word and the null-bit words fromsegments[0]at absolute positions 0 andi, while every other accessor in the class reads through the row'soffset:isNullAtgoes throughbitGet(segments[0], offset, ...), the field getters throughgetFieldOffset(pos), andgetRowKind()readssegments[0].get(offset). A row pointed at a non-zero offset therefore answered from whatever bytes sat at the start of the segment, soanyNull()andisNullAt()could disagree about the same row. Both reads now add the offset.The four in-repo callers, in
FieldNestedUpdateAggandFieldNestedPartialUpdateAgg, each pass a row fromkeyProjection.apply(row).copy(), andBinaryRow.copy()re-points the copy at offset 0, so no current code path is affected. Non-zero offsets do occur:BinaryRowSerializer.pointTogives a row the position after a length prefix whenmapFromPageswalks a page, so the first row in a page sits at offset 4.anyNull(int[] fields)needed no change; it goes throughisNullAt.BinaryArray.anyNull()already reads fromoffset + 4, so this was the last member of that family reading at an absolute index.Tests
Two cases next to the existing
anyNullTestinBinaryRowTest, one per code path in the method, both laying two rows into one segment with a sharedconcathelper and pointing the second one at a non-zero offset.testAnyNullWithNonZeroOffset: arity 1, so only the header read runs. The row starts at offset 20, four bytes of padding plus a 16-byte row, so the offset is not a multiple of eight either, which is the alignmentBinaryRowSerializeractually produces.testAnyNullHighFieldWithNonZeroOffset: arity 60 with the null at field 59, which puts the null bit in the second 8-byte word, so the loop is what has to honor the offset. It also assertsisNullAt(59)first, so a failure cannot be blamed on the fixture.In both cases the row without nulls goes first, so a read that ignores the offset lands on it and reports no null. Both fail against the pre-fix code.
mvn -pl paimon-common teston JDK 8: 12467 tests, 0 failures, 0 errors. checkstyle, spotless, enforcer and rat run clean.