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 ByteString.toArrayUnsafe #308

Merged
merged 1 commit into from
May 18, 2024
Merged

Conversation

pjfanning
Copy link
Contributor

avoids array copying

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

@raboof raboof merged commit 2ef115e into apache:main May 18, 2024
20 checks passed
@pjfanning pjfanning deleted the use-toArrayUnsafe branch May 18, 2024 10:57
finally gzos.close()
ByteString.fromArrayUnsafe(baos.toByteArray)
}

override def uncompress(compressed: ByteString): ByteString = {
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArray))
val gzis = new GZIPInputStream(new ByteArrayInputStream(compressed.toArrayUnsafe()))
Copy link
Contributor

Choose a reason for hiding this comment

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

could we have used compressed.asInputStream? because toArrayUnsafe can still create a new array in case the byteString is a rope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).

Something like https://github.com/apache/pekko-http/pull/539/files (this was reverted because of a bug in the hpack code - twitter/hpack#43).

Copy link
Contributor

Choose a reason for hiding this comment

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

We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).

thats unfortunate

this was reverted because of a bug in the hpack code - twitter/hpack#43

last commit of that library was 5 years ago. also it seems to be deprecated

Copy link
Member

Choose a reason for hiding this comment

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

May be we can the netty 's Hpack?

Copy link
Member

Choose a reason for hiding this comment

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

We need to use MethodHandles to still support Pekko 1.0 (asInputStream is only in Pekko 1.1).

IMHO we could just require Pekko 1.1 in Pekko gRPC 1.1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@raboof I got rid of the MethodHandle in #309

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.

4 participants