alamar commented on a change in pull request #8577:
URL: https://github.com/apache/ignite/pull/8577#discussion_r548871960
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
##########
@@ -301,6 +301,9 @@
/** */
protected boolean lastFinished;
+ /** byte-array representation of string */
+ private byte[] byteArr;
Review comment:
Can we perhaps make it a `private volatile` and name smth like
`curStrBackingArr`? I'm not confident that it will be called from the same
thread.
##########
File path:
modules/core/src/main/java/org/apache/ignite/internal/direct/stream/v2/DirectByteBufferStreamImplV2.java
##########
@@ -584,7 +587,17 @@ public DirectByteBufferStreamImplV2(MessageFactory
msgFactory) {
/** {@inheritDoc} */
@Override public void writeString(String val) {
- writeByteArray(val != null ? val.getBytes() : null);
+ if (val != null) {
+ if (byteArr == null)
+ byteArr = val.getBytes();
+
+ writeByteArray(byteArr);
+
+ if (lastFinished)
+ byteArr = null;
+ }
+ else
+ writeByteArray(null);
Review comment:
can we perhaps declare byteArr a local variable, and only assign it to
curStrBackingArr if not lastFinished? This way we will not touch this variable
at all when string fits one frame.
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]