MINOR: [perl] skip bytes and fixed relative to current position in decoder - #3964
Open
arib06 wants to merge 1 commit into
Open
MINOR: [perl] skip bytes and fixed relative to current position in decoder#3964arib06 wants to merge 1 commit into
arib06 wants to merge 1 commit into
Conversation
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.
What is the purpose of the change
Avro::BinaryDecoderskips a writer field it does not need with$reader->seek($n, 0), but whence0isSEEK_SET(absolute) rather thanSEEK_CUR(relative).skip_bytes(also used forskip_string) andskip_fixedtherefore jump to an absolute offset equal to the field length instead of advancing past the field.When a reader schema projects away a
bytes/string/fixedfield that is not the last writer field, the stream position is left wrong and every following field is decoded from the wrong offset, silently yielding wrong values (or a later marker-mismatch error on data files). The siblingdecode_bytes/decode_fixedconsume exactly the field bytes, so this only affects the skip path. UsingFcntl->SEEK_CURmakes the skip advance from the current position.Verifying this change
This change added tests and can be verified as follows:
t/03_bin_decode.tthat decode a record with a projecting reader schema where a skippedbytesfield and a skippedfixedfield are each followed by another field. The trailing field now decodes correctly; on the current code it reads a wrong value.Documentation