timoninmaxim commented on code in PR #12532:
URL: https://github.com/apache/ignite/pull/12532#discussion_r2580853255
##########
modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java:
##########
@@ -838,16 +838,24 @@ void writeBooleanField(@Nullable Boolean val) {
if (obj == null)
out.writeByte(GridBinaryMarshaller.NULL);
else {
- BinaryWriterExImpl writer = new BinaryWriterExImpl(
- ctx,
- out,
- schema,
- handles(),
- failIfUnregistered,
- GridBinaryMarshaller.UNREGISTERED_TYPE_ID
- );
-
- writer.marshal(obj);
+ int typeId0 = this.typeId;
+ int start0 = this.start;
+ int rawOffPos0 = this.rawOffPos;
+ int schemaId0 = this.schemaId;
+ int fieldCnt0 = this.fieldCnt;
+ BinaryInternalMapper mapper0 = this.mapper;
+
+ clearState();
+ // Handles not cleared, because, in this mode they shared down to
hierarchy.
Review Comment:
It's better to add a param `clearHandles` to `clearState()`, to keep all
logic in one place.
##########
modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java:
##########
@@ -1549,4 +1568,14 @@ boolean tryWriteAsHandle(Object obj) {
@Override public BinaryContext context() {
return ctx;
}
+
+ /** Clears writer state. */
+ private void clearState() {
+ this.typeId = 0;
Review Comment:
UNREGISTERED_TYPE_ID?
##########
modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java:
##########
@@ -856,16 +864,27 @@ void writeBooleanField(@Nullable Boolean val) {
if (obj == null)
out.writeByte(GridBinaryMarshaller.NULL);
else {
- BinaryWriterExImpl writer = new BinaryWriterExImpl(
- ctx,
- out,
- schema,
- null,
- failIfUnregistered,
- GridBinaryMarshaller.UNREGISTERED_TYPE_ID
- );
-
- writer.marshal(obj);
+ int typeId0 = this.typeId;
Review Comment:
AFAIU, the goal of storing this fields is that they are used in `#postWrite`
method that will be called within `marshal(obj)`. I thinks it's worth to
mention that in a comment.
--
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]