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 ByteStringInputStream #309

Merged
merged 4 commits into from
May 21, 2024
Merged

use ByteStringInputStream #309

merged 4 commits into from
May 21, 2024

Conversation

pjfanning
Copy link
Contributor

follow up to #308

Copy link
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

Lgtm

Co-Authored-By: João Ferreira <[email protected]>
Comment on lines 38 to 47
def apply(bs: ByteString): InputStream = bs match {
case cs: ByteString1C =>
getInputStreamUnsafe(cs)
case _ =>
if (byteStringInputStreamMethodTypeOpt.isDefined) {
byteStringInputStreamMethodTypeOpt.get.invoke(bs).asInstanceOf[InputStream]
} else {
legacyConvert(bs)
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

and what about:

Suggested change
def apply(bs: ByteString): InputStream = bs match {
case cs: ByteString1C =>
getInputStreamUnsafe(cs)
case _ =>
if (byteStringInputStreamMethodTypeOpt.isDefined) {
byteStringInputStreamMethodTypeOpt.get.invoke(bs).asInstanceOf[InputStream]
} else {
legacyConvert(bs)
}
}
def apply(bs: ByteString): InputStream = {
if (byteStringInputStreamMethodTypeOpt.isDefined) {
byteStringInputStreamMethodTypeOpt.get.invoke(bs).asInstanceOf[InputStream]
} else {
legacyConvert(bs)
}
}

Copy link
Contributor

Choose a reason for hiding this comment

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

another improvement could be the use of null instead of None in byteStringInputStreamMethodTypeOpt

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll check it again but when I was benchmarking the changes before - having the ByteString1C case seemed to help performance. I can't track down the benchmarks that I used, I may need to write them again.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually - the benchmark code that I used a few weeks ago is at https://github.com/pjfanning/pekko-test/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With your optimised version of legacyConvert, we may not need the MethodHandle. That code is basically what adInputStream does anyway.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I checked in the simpler version. It seems good enough and Pekko 1.0 users benefit with this version.

Co-Authored-By: João Ferreira <[email protected]>
@pjfanning pjfanning marked this pull request as ready for review May 20, 2024 18:19
@pjfanning
Copy link
Contributor Author

@He-Pin I reworked the code. Are you still happy with this change?

@pjfanning
Copy link
Contributor Author

@jtjeferreira It isn't strictly necessary but could you consider supplying an iCLA (if you haven't done so already)?

https://www.apache.org/licenses/contributor-agreements.html

Copy link
Member

@He-Pin He-Pin left a comment

Choose a reason for hiding this comment

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

lgtm, checked the new SequenceInputStream

@laglangyue
Copy link
Contributor

lgtm

Copy link

@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

@pjfanning pjfanning merged commit 6221aa6 into apache:main May 21, 2024
19 checks passed
@pjfanning pjfanning deleted the gzip-stream branch May 21, 2024 07:53
@pjfanning pjfanning added this to the v1.1.0-M1 milestone May 22, 2024
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.

5 participants