Skip to content

Commit 8b4c4f3

Browse files
committed
IGNITE-27177 Remove BinaryWriter#typeId seter
1 parent bc1fd21 commit 8b4c4f3

File tree

3 files changed

+29
-258
lines changed

3 files changed

+29
-258
lines changed

modules/benchmarks/src/main/java/org/apache/ignite/internal/benchmarks/jmh/binary/JmhMapSerdesBenchmark.java

Lines changed: 0 additions & 199 deletions
This file was deleted.

modules/binary/api/src/main/java/org/apache/ignite/internal/binary/BinaryWriterExImpl.java

Lines changed: 27 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -61,30 +61,30 @@ class BinaryWriterExImpl implements BinaryWriterEx {
6161
/** Schema. */
6262
private final BinaryWriterSchemaHolder schema;
6363

64-
/** */
65-
private final boolean failIfUnregistered;
66-
6764
/** */
6865
private int typeId;
6966

7067
/** */
71-
private int start;
68+
private final int start;
7269

7370
/** Raw offset position. */
7471
private int rawOffPos;
7572

73+
/** Handles. */
74+
private BinaryWriterHandles handles;
75+
7676
/** Schema ID. */
7777
private int schemaId = BinaryUtils.schemaInitialId();
7878

7979
/** Amount of written fields. */
8080
private int fieldCnt;
8181

82-
/** Handles. */
83-
private BinaryWriterHandles handles;
84-
8582
/** */
8683
private BinaryInternalMapper mapper;
8784

85+
/** */
86+
private final boolean failIfUnregistered;
87+
8888
/**
8989
* @param ctx Context.
9090
* @param out Output stream.
@@ -847,29 +847,16 @@ void writeBooleanField(@Nullable Boolean val) {
847847
if (obj == null)
848848
out.writeByte(GridBinaryMarshaller.NULL);
849849
else {
850-
int typeId0 = this.typeId;
851-
int start0 = this.start;
852-
int rawOffPos0 = this.rawOffPos;
853-
int schemaId0 = this.schemaId;
854-
int fieldCnt0 = this.fieldCnt;
855-
BinaryInternalMapper mapper0 = this.mapper;
856-
857-
this.typeId = 0;
858-
this.start = out.position();
859-
this.rawOffPos = 0;
860-
this.schemaId = BinaryUtils.schemaInitialId();
861-
this.fieldCnt = 0;
862-
this.mapper = null;
863-
// Handles not cleared, because, in this mode it shared down to hierarchy.
864-
865-
marshal(obj);
866-
867-
this.typeId = typeId0;
868-
this.start = start0;
869-
this.rawOffPos = rawOffPos0;
870-
this.schemaId = schemaId0;
871-
this.fieldCnt = fieldCnt0;
872-
this.mapper = mapper0;
850+
BinaryWriterExImpl writer = new BinaryWriterExImpl(
851+
ctx,
852+
out,
853+
schema,
854+
handles(),
855+
failIfUnregistered,
856+
GridBinaryMarshaller.UNREGISTERED_TYPE_ID
857+
);
858+
859+
writer.marshal(obj);
873860
}
874861
}
875862

@@ -878,32 +865,16 @@ void writeBooleanField(@Nullable Boolean val) {
878865
if (obj == null)
879866
out.writeByte(GridBinaryMarshaller.NULL);
880867
else {
881-
int typeId0 = this.typeId;
882-
int start0 = this.start;
883-
int rawOffPos0 = this.rawOffPos;
884-
int schemaId0 = this.schemaId;
885-
int fieldCnt0 = this.fieldCnt;
886-
BinaryInternalMapper mapper0 = this.mapper;
887-
BinaryWriterHandles handles0 = this.handles;
888-
889-
this.typeId = 0;
890-
this.start = out.position();
891-
this.rawOffPos = 0;
892-
this.schemaId = BinaryUtils.schemaInitialId();
893-
this.fieldCnt = 0;
894-
this.mapper = null;
895-
// Handles cleared, because, in this mode it NOT shared down to hierarchy.
896-
this.handles = null;
897-
898-
marshal(obj);
899-
900-
this.typeId = typeId0;
901-
this.start = start0;
902-
this.rawOffPos = rawOffPos0;
903-
this.schemaId = schemaId0;
904-
this.fieldCnt = fieldCnt0;
905-
this.mapper = mapper0;
906-
this.handles = handles0;
868+
BinaryWriterExImpl writer = new BinaryWriterExImpl(
869+
ctx,
870+
out,
871+
schema,
872+
null,
873+
failIfUnregistered,
874+
GridBinaryMarshaller.UNREGISTERED_TYPE_ID
875+
);
876+
877+
writer.marshal(obj);
907878
}
908879
}
909880

modules/core/src/test/java/org/apache/ignite/internal/binary/BinaryMarshallerSelfTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,6 @@
110110
import org.junit.Test;
111111

112112
import static java.nio.charset.StandardCharsets.UTF_8;
113-
import static org.apache.ignite.internal.binary.GridBinaryMarshaller.UNREGISTERED_TYPE_ID;
114113
import static org.junit.Assert.assertArrayEquals;
115114
import static org.junit.Assert.assertNotEquals;
116115

@@ -3020,7 +3019,7 @@ public void testThreadLocalArrayReleased() throws Exception {
30203019

30213020
BinaryMarshaller marsh = binaryMarshaller();
30223021

3023-
try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh), false, UNREGISTERED_TYPE_ID)) {
3022+
try (BinaryWriterEx writer = BinaryUtils.writer(binaryContext(marsh), false, GridBinaryMarshaller.UNREGISTERED_TYPE_ID)) {
30243023
assertEquals(true, BinaryStreamsTestUtils.threadLocalIsAcquired());
30253024

30263025
writer.writeString("Thread local test");
@@ -3310,7 +3309,7 @@ public void testPredefinedTypeIds() throws Exception {
33103309
for (Map.Entry<String, Integer> entry : map.entrySet()) {
33113310
int id = entry.getValue();
33123311

3313-
if (id == UNREGISTERED_TYPE_ID)
3312+
if (id == GridBinaryMarshaller.UNREGISTERED_TYPE_ID)
33143313
continue;
33153314

33163315
BinaryClassDescriptor desc = bCtx.descriptorForTypeId(false, entry.getValue(), null, true);

0 commit comments

Comments
 (0)