SammyVimes commented on a change in pull request #523:
URL: https://github.com/apache/ignite-3/pull/523#discussion_r774940058
##########
File path:
modules/network/src/main/java/org/apache/ignite/internal/network/direct/stream/DirectByteBufferStreamImplV1.java
##########
@@ -1343,6 +1362,81 @@ public IgniteUuid readIgniteUuid() {
return map0;
}
+ /** {@inheritDoc} */
+ @Override
+ public <T> void writeMarshallable(T object, MessageWriter writer) {
+ switch (marshallableState) {
+ case 0:
+ if (marshallable == null) {
+ // If object was not serialized to a byte array, serialize
it
+ SerializationResult res =
serializationService.writeMarshallable(object);
+ List<Integer> descriptorIds = res.ids();
+ marshallable = res.array();
+ // Get descriptors that were not previously sent to the
remote node
+ missingDescriptors =
serializationService.createClassDescriptorsMessages(descriptorIds);
+ }
+
+ writeCollection(missingDescriptors,
MessageCollectionItemType.MSG, writer);
+
+ if (!lastFinished) {
+ return;
+ }
+
+ marshallableState++;
+
+ //noinspection fallthrough
+ case 1:
+ writeByteArray(marshallable);
+
+ if (!lastFinished) {
+ return;
+ }
+
+ marshallable = null;
+ missingDescriptors = null;
+ marshallableState = 0;
+ break;
+
+ default:
+ throw new IllegalArgumentException("Unknown marshallableState:
" + marshallableState);
+ }
+ }
+
+ /** {@inheritDoc} */
+ @Override
+ public <T> T readMarshallable(MessageReader reader) {
+ switch (marshallableState) {
+ case 0:
+ missingDescriptors =
readCollection(MessageCollectionItemType.MSG, reader);
Review comment:
That's the way everything works in this class. They're created a-plenty
during serialization de-serialization, so I believe the lesser fields the
better. I also think that it's really neat that the same field can be reused
for writing and reading
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]