Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output well-formed UTF-8 bytes in SimpleTextCodec's segmentinfos #12897

Merged
merged 2 commits into from
Jan 11, 2024

Conversation

msfroh
Copy link
Contributor

@msfroh msfroh commented Dec 9, 2023

Description

The SimpleTextSegmentInfoFormat was writing the random byte array used as a segment's ID directly -- not converting to a simple text representation of the byte array. As a result, the segment infos were often malformed (as UTF-8 text).

The included test was failing before the change to write out the text representation of the byte array.

@msfroh
Copy link
Contributor Author

msfroh commented Dec 9, 2023

If needed, I'm happy to add versions of testFileIsUTF8() for the other SimpleTextCodec format unit tests.

Copy link
Contributor

@jpountz jpountz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks good, I just left a minor suggestion about the test.

}
byte[] bytes = new byte[(int) length];
input.readBytes(bytes, 0, bytes.length);
StandardCharsets.UTF_8.newDecoder().decode(ByteBuffer.wrap(bytes));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use Term#toString(BytesRef) which includes such checks already and configures a few more flags on the decoder that look useful?

The SimpleTextSegmentInfoFormat was writing the random byte array used
as a segment's ID directly -- not converting to a simple text
representation of the byte array. As a result, the segment infos were
often malformed.
@msfroh msfroh force-pushed the fix_utf8_simpletextsegmentinfos branch from f103563 to 59c3b8c Compare December 29, 2023 18:08
@msfroh
Copy link
Contributor Author

msfroh commented Dec 29, 2023

I implemented a similar change for binary doc values at #12987

@jpountz jpountz merged commit b7728c5 into apache:main Jan 11, 2024
4 checks passed
jpountz pushed a commit that referenced this pull request Jan 11, 2024
)

The SimpleTextSegmentInfoFormat was writing the random byte array used
as a segment's ID directly -- not converting to a simple text
representation of the byte array. As a result, the segment infos were
often malformed.
slow-J pushed a commit to slow-J/lucene that referenced this pull request Jan 16, 2024
…che#12897)

The SimpleTextSegmentInfoFormat was writing the random byte array used
as a segment's ID directly -- not converting to a simple text
representation of the byte array. As a result, the segment infos were
often malformed.
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.

2 participants