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

Remove usages of Stream #74

Merged
merged 1 commit into from
Mar 21, 2023

Conversation

mdedetrich
Copy link
Contributor

Completely removes usages of Stream, making #71 redudnant.

Resolves: #71

@mdedetrich
Copy link
Contributor Author

Hmm ByteString.apply is being a bit funny, will check this out after lunch.

private def readStream(stream: InputStream): ByteString = {
val reader = new BufferedInputStream(stream)
try ByteString(Stream.continually(reader.read).takeWhile(_ != -1).map(_.toByte).toArray)
try ByteString(Iterator.continually(reader.read).takeWhile(_ != -1).map(_.toByte).toArray)
Copy link
Contributor Author

@mdedetrich mdedetrich Mar 21, 2023

Choose a reason for hiding this comment

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

So I realized what the underlying problem was, it turns out that specifically for Scala 2.12, ByteString is missing the apply method for an Iterator where as this exists in Scala 2.13. This is likely an oversight and a PR at Pekk was created at apache/pekko#257 to resolve this.

When that PR lands its possible to remove the .toArray, in any case both variants are equivalent to eachother because internally in the ByteString.apply it converts it to an Array anyways.

@mdedetrich
Copy link
Contributor Author

@pjfanning PR is now ready

Copy link
Contributor

@nvollmar nvollmar left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@pjfanning pjfanning left a comment

Choose a reason for hiding this comment

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

lgtm

@mdedetrich mdedetrich merged commit bd2860a into apache:main Mar 21, 2023
@mdedetrich mdedetrich deleted the remove-usages-of-stream branch March 21, 2023 12:53
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.

use LazyList instead of Stream in S3Stream
3 participants