-
Notifications
You must be signed in to change notification settings - Fork 90
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
IGNITE-17874 Added List and ByteBuffer support to message serialization #1189
Conversation
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
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.
Needs tests, byte buffer writing seems to be broken
...ache/ignite/internal/network/processor/serialization/MessageCollectionItemTypeConverter.java
Show resolved
Hide resolved
.../network/src/main/java/org/apache/ignite/internal/network/direct/DirectMarshallingUtils.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
...les/network/src/main/java/org/apache/ignite/internal/network/direct/DirectMessageReader.java
Outdated
Show resolved
Hide resolved
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
modules/network/src/test/java/org/apache/ignite/internal/network/messages/AllTypesMessage.java
Show resolved
Hide resolved
@@ -1363,8 +1541,7 @@ public <C extends Collection<?>> C readCollection(MessageCollectionItemType item | |||
* @return Whether array was fully written. | |||
*/ | |||
boolean writeArray(Object arr, long off, int len, int bytes) { | |||
assert arr != null; | |||
assert arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); | |||
assert arr == null || arr.getClass().isArray() && arr.getClass().getComponentType().isPrimitive(); |
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.
I don't think this change was necessary
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.
It was, I pass "null" here for direct buffers
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.
Ok, didn't notice that, thanks for the explanation. Please add @Nullable
here, then
if (val.isDirect()) { | ||
long address = GridUnsafe.bufferAddress(val); | ||
|
||
lastFinished = writeArray(null, address, length, length); |
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.
I don't understand, why do we bother with all this GridUnsafe shenanigans when writing an array or a ByteBuffer into another ByteBuffer. What's wrong with simply calling put(ByteBuffer)
?
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.
This way I reused code from writeArray, otherwise I'd have to copy it, basically. It does more than just copying, it also manages last position, finished flag and so on
byteBufferPosition = readInt(); | ||
} | ||
|
||
if (!lastFinished) { |
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.
maybe this if
should be moved to closer to the readInt
call
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.
Ok
...main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
Outdated
Show resolved
Hide resolved
|
||
lastFinished = writeArray(null, address, length, length); | ||
} else { | ||
byte[] array = val.array(); |
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.
hm, didn't we agree that we should transfer only (limit - position) bytes?
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.
Would be weird, imo. What if receiver wants to set position to 0? These two numbers are just extra values
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
Signed-off-by: ibessonov <bessonov.ip@gmail.com>
https://issues.apache.org/jira/browse/IGNITE-17874