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

Use Knuth–Morris–Pratt algorithm for delimiter search in TextIO #32398

Merged
merged 6 commits into from
Sep 9, 2024

Conversation

baeminbo
Copy link
Contributor

@baeminbo baeminbo commented Sep 5, 2024

I believe this PR can fix #32251 (it's closed but still not fully fixed. see this case) and #32249.

Fix #32249, #32251.


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Mention the appropriate issue in your description (for example: addresses #123), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, comment fixes #<ISSUE NUMBER> instead.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests
Go tests

See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.

@github-actions github-actions bot added the java label Sep 5, 2024
@baeminbo baeminbo changed the title [WIP] Use a finite state machine for delimiter search in TextIO Use a finite state machine for delimiter search in TextIO Sep 5, 2024
@baeminbo
Copy link
Contributor Author

baeminbo commented Sep 5, 2024

R: @scwhittle, @Abacn

Hi @scwhittle, I see you're working on the PR #32258 for fixing the issue #32241. I created this PR to fix the issue #32251 , but I believe it can also fix #32249.

Hi @Abacn, I see you approved the PR #32298, but it cannot fix all the cases of #32241. Could you check it again?

Copy link
Contributor

github-actions bot commented Sep 5, 2024

Stopping reviewer notifications for this pull request: review requested by someone other than the bot, ceding control. If you'd like to restart, comment assign set of reviewers

Copy link
Contributor

@scwhittle scwhittle left a comment

Choose a reason for hiding this comment

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

Thanks for putting this together, I got bogged down in trying to make startReading correct as well but it is probably best to fix separately.

startReading is incorrect in cases where the offset is smaller than the delimiter length, or smaller than where the headers end, where there is a BOM and headers etc which I uncovered when adding integration test of longer delimiters to sdks/java/core/src/test/java/org/apache/beam/sdk/io/TextIOReadTest.java

@baeminbo baeminbo changed the title Use a finite state machine for delimiter search in TextIO Use Knuth–Morris–Pratt algorithm for delimiter search in TextIO Sep 6, 2024
@baeminbo baeminbo force-pushed the baeminbo-textio-delimiter branch from 03eb22d to 5b827b7 Compare September 6, 2024 02:56
@baeminbo baeminbo force-pushed the baeminbo-textio-delimiter branch from 5b827b7 to 8e5a6cd Compare September 6, 2024 02:57
@baeminbo
Copy link
Contributor Author

baeminbo commented Sep 6, 2024

@scwhittle Could you continue to review? I added a commit to change the delimiter search algorithm. Thanks.

Copy link
Contributor

@scwhittle scwhittle left a comment

Choose a reason for hiding this comment

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

Just some minor cleanup comments. Thanks!

@scwhittle
Copy link
Contributor

Run Java_IOs_Direct PreCommit

@scwhittle
Copy link
Contributor

Waiting on tests to complete to merge

@baeminbo baeminbo force-pushed the baeminbo-textio-delimiter branch from 79ed964 to 4ad8e27 Compare September 7, 2024 02:24
@baeminbo
Copy link
Contributor Author

baeminbo commented Sep 9, 2024

@scwhittle I fixed a bug at a commit which made the test failed. Could you continue to review this? Thanks.

@scwhittle scwhittle merged commit 2a7755b into apache:master Sep 9, 2024
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants