-
Notifications
You must be signed in to change notification settings - Fork 4k
protobuf, api, core, netty: zero copy into protobuf #7330
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
Changes from 1 commit
9936df1
aa93e1d
454e224
3f47d5e
b3c9974
2ede525
3dca312
6249353
29dce67
22ea6c3
53e347c
27801fe
eb71a68
5d3c657
9fd8d3c
e3afe50
e2fdd07
033270b
0622d51
0e8caee
ba4e91b
69618b2
437857d
1363505
c46eb73
7b4e070
772b3ba
b1c99e5
692076c
10c13b8
f13c165
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -143,19 +143,19 @@ public interface ReadableBuffer extends Closeable { | |
| boolean canUseByteBuffer(); | ||
|
||
|
|
||
| /** | ||
| * Gets a {@link ByteBuffer} that contains up to {@code length} bytes of this buffer's content, | ||
| * or {@code null} if this buffer has been exhausted. The position of this buffer is unchanged | ||
| * after calling this method. The returned buffer's content should not be modified, but the | ||
| * position, limit, and mark may be changed. Operations for changing the position, limit, and | ||
| * mark of the returned {@link ByteBuffer} does not affect the position, limit, and mark of | ||
| * this buffer. {@link ByteBuffer}s returned by this method have independent position, limit | ||
| * and mark. This is an optional method, so callers should first check {@link #canUseByteBuffer}. | ||
| * Gets a {@link ByteBuffer} that contains some bytes of the content next to be read, or {@code | ||
| * null} if this buffer has been exhausted. The number of bytes contained in the returned buffer | ||
| * is implementation specific. The position of this buffer is unchanged after calling this | ||
| * method. The returned buffer's content should not be modified, but the position, limit, and | ||
| * mark may be changed. Operations for changing the position, limit, and mark of the returned | ||
| * buffer does not affect the position, limit, and mark of this buffer. Buffers returned by this | ||
| * method have independent position, limit and mark. This is an optional method, so callers | ||
| * should first check {@link #canUseByteBuffer}. | ||
| * | ||
| * @param length the maximum number of bytes to contain in returned {@link ByteBuffer}. | ||
| * @throws UnsupportedOperationException the buffer does not support this method. | ||
| */ | ||
| @Nullable | ||
| ByteBuffer getByteBuffer(int length); | ||
| ByteBuffer getByteBuffer(); | ||
|
|
||
| /** | ||
| * Closes this buffer and releases any resources. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -110,8 +110,8 @@ public boolean canUseByteBuffer() { | |
| } | ||
|
|
||
| @Override | ||
| public ByteBuffer getByteBuffer(int length) { | ||
| return buffer.nioBuffers(buffer.readerIndex(), length)[0]; | ||
| public ByteBuffer getByteBuffer() { | ||
| return buffer.nioBuffers()[0]; | ||
|
||
| } | ||
|
|
||
| /** | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the API cleaner how about having this return
nullfor not supported and a (constant) emptyByteBufferfor EOS?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The semantics of returning
nullfor operation not supported isn't strong enough. Most existing Java APIs (e.g.,java.nio.ByteBufferuseshasArray()andarray()) throw anUnsupportedOperationExceptionfor unsupported optional APIs. I think the current approach is cleaner.