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

Character line size limit #996

Merged
merged 6 commits into from
Nov 28, 2024
Merged

Conversation

Jacob-Eliat-Eliat
Copy link
Contributor

@Jacob-Eliat-Eliat Jacob-Eliat-Eliat commented Nov 25, 2024

There is a debate between using byte size and character size.

This is my preferred approach because:

  • while it's easy for a customer to check the byte size of a file, it's less straightforwards with a line, because it depends on encoding, and the file won't report it to them directly.
  • it avoids unnecessary processing and uses ready-made fs2 methods

here is a draft of the alternative to give you an idea of what the flow would be like:
#995

(not if the alternative is preferred, the processing code needs a heavy coat of cleanup but the main idea is there)

Copy link

codecov bot commented Nov 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.30%. Comparing base (fdfe8f2) to head (996c0da).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #996      +/-   ##
==========================================
+ Coverage   83.27%   83.30%   +0.02%     
==========================================
  Files          47       47              
  Lines        3145     3150       +5     
  Branches      483      432      -51     
==========================================
+ Hits         2619     2624       +5     
  Misses        526      526              
Files with missing lines Coverage Δ
...n/scala/cognite/spark/v1/FileContentRelation.scala 95.23% <100.00%> (+1.48%) ⬆️

@Jacob-Eliat-Eliat Jacob-Eliat-Eliat marked this pull request as ready for review November 25, 2024 16:05
@Jacob-Eliat-Eliat Jacob-Eliat-Eliat requested a review from a team as a code owner November 25, 2024 16:05
@github-actions github-actions bot requested a review from mr-celo November 25, 2024 16:05
@@ -114,7 +118,15 @@ class FileContentRelation(config: RelationConfig, fileExternalId: String, inferS
byteStream
.through(enforceSizeLimit)
.through(fs2.text.utf8.decode)
.through(fs2.text.lines)
.through(fs2.text.linesLimited(lineSizeLimitCharacters))
.handleErrorWith {
Copy link
Contributor

Choose a reason for hiding this comment

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

there's .zipWithIndex method that can expose indexes, not sure if we can attach it to error message though 🤔
But that's only a nice to have extra error detail

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is possible, but then we cannot use linesLimited, we'd need to do a second pass with indexes and limit there. Not very hard, how much do you think this is important?

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