This is an automated email from the ASF dual-hosted git repository.

av pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ignite.git


The following commit(s) were added to refs/heads/master by this push:
     new b172ee33b88 IGNITE-25995 Use MessageSerializer for TxEntryValueHolder 
(#12682)
b172ee33b88 is described below

commit b172ee33b88b8ea806e85fbaacd9a44fecac8027
Author: Dmitry Werner <[email protected]>
AuthorDate: Thu Feb 5 18:03:51 2026 +0500

    IGNITE-25995 Use MessageSerializer for TxEntryValueHolder (#12682)
---
 .../communication/GridIoMessageFactory.java        |   3 +-
 .../cache/transactions/IgniteTxEntry.java          |  16 +--
 .../cache/transactions/TxEntryValueHolder.java     | 132 ++++++---------------
 3 files changed, 48 insertions(+), 103 deletions(-)

diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
index 919f816f62c..e607d42eb0d 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/managers/communication/GridIoMessageFactory.java
@@ -163,6 +163,7 @@ import 
org.apache.ignite.internal.codegen.SnapshotFilesRequestMessageSerializer;
 import 
org.apache.ignite.internal.codegen.TcpInverseConnectionResponseMessageSerializer;
 import 
org.apache.ignite.internal.codegen.TransactionAttributesAwareRequestSerializer;
 import org.apache.ignite.internal.codegen.TxEntriesInfoSerializer;
+import org.apache.ignite.internal.codegen.TxEntryValueHolderSerializer;
 import org.apache.ignite.internal.codegen.TxInfoSerializer;
 import org.apache.ignite.internal.codegen.TxLockListSerializer;
 import org.apache.ignite.internal.codegen.TxLockSerializer;
@@ -434,7 +435,7 @@ public class GridIoMessageFactory implements 
MessageFactoryProvider {
         factory.register((short)97, CacheEvictionEntry::new, new 
CacheEvictionEntrySerializer());
         factory.register((short)98, CacheEntryPredicateAdapter::new, new 
CacheEntryPredicateAdapterSerializer());
         factory.register((short)100, IgniteTxEntry::new);
-        factory.register((short)101, TxEntryValueHolder::new);
+        factory.register((short)101, TxEntryValueHolder::new, new 
TxEntryValueHolderSerializer());
         factory.register((short)102, CacheVersionedValue::new, new 
CacheVersionedValueSerializer());
         factory.register((short)103, GridCacheRawVersionedEntry::new);
         factory.register((short)104, GridCacheVersionEx::new, new 
GridCacheVersionExSerializer());
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
index 2dd67952f08..9eb5115d535 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/IgniteTxEntry.java
@@ -382,7 +382,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
         cp.val = new TxEntryValueHolder();
 
         cp.filters = filters;
-        cp.val.value(val.op(), val.value(), val.hasWriteValue(), 
val.hasReadValue());
+        cp.val.value(val.operation(), val.value(), val.hasWriteValue(), 
val.hasReadValue());
         cp.entryProcessorsCol = entryProcessorsCol;
         cp.ttl = ttl;
         cp.conflictExpireTime = conflictExpireTime;
@@ -485,7 +485,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
      * to further peek operations.
      */
     public void markValid() {
-        prevVal.value(val.op(), val.value(), val.hasWriteValue(), 
val.hasReadValue());
+        prevVal.value(val.operation(), val.value(), val.hasWriteValue(), 
val.hasReadValue());
     }
 
     /**
@@ -720,7 +720,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
      * @return Previous operation to revert entry in case of filter failure.
      */
     @Nullable public GridCacheOperation previousOperation() {
-        return prevVal.op();
+        return prevVal.operation();
     }
 
     /**
@@ -757,7 +757,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
      * @param readVal Read value flag.
      */
     public void value(@Nullable CacheObject val, boolean writeVal, boolean 
readVal) {
-        this.val.value(this.val.op(), val, writeVal, readVal);
+        this.val.value(this.val.operation(), val, writeVal, readVal);
     }
 
     /**
@@ -766,7 +766,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
      * @param val Read value to set.
      */
     public void readValue(@Nullable CacheObject val) {
-        this.val.value(this.val.op(), val, false, true);
+        this.val.value(this.val.operation(), val, false, true);
     }
 
     /**
@@ -782,7 +782,7 @@ public class IgniteTxEntry implements GridPeerDeployAware, 
Message {
         // Must clear transform closure bytes since collection has changed.
         transformClosBytes = null;
 
-        val.op(TRANSFORM);
+        val.operation(TRANSFORM);
     }
 
     /**
@@ -853,14 +853,14 @@ public class IgniteTxEntry implements 
GridPeerDeployAware, Message {
      * @return Cache operation.
      */
     public GridCacheOperation op() {
-        return val.op();
+        return val.operation();
     }
 
     /**
      * @param op Cache operation.
      */
     public void op(GridCacheOperation op) {
-        val.op(op);
+        val.operation(op);
     }
 
     /**
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
index c26840181d6..1774936e2ae 100644
--- 
a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
+++ 
b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/transactions/TxEntryValueHolder.java
@@ -17,10 +17,8 @@
 
 package org.apache.ignite.internal.processors.cache.transactions;
 
-import java.nio.ByteBuffer;
 import org.apache.ignite.IgniteCheckedException;
-import org.apache.ignite.internal.GridDirectTransient;
-import org.apache.ignite.internal.IgniteCodeGeneratingFail;
+import org.apache.ignite.internal.Order;
 import org.apache.ignite.internal.processors.cache.CacheObject;
 import org.apache.ignite.internal.processors.cache.CacheObjectValueContext;
 import org.apache.ignite.internal.processors.cache.GridCacheContext;
@@ -29,8 +27,6 @@ import 
org.apache.ignite.internal.util.tostring.GridToStringExclude;
 import org.apache.ignite.internal.util.tostring.GridToStringInclude;
 import org.apache.ignite.internal.util.typedef.internal.S;
 import org.apache.ignite.plugin.extensions.communication.Message;
-import org.apache.ignite.plugin.extensions.communication.MessageReader;
-import org.apache.ignite.plugin.extensions.communication.MessageWriter;
 import org.jetbrains.annotations.Nullable;
 
 import static 
org.apache.ignite.internal.processors.cache.GridCacheOperation.CREATE;
@@ -42,23 +38,24 @@ import static 
org.apache.ignite.internal.processors.cache.GridCacheOperation.UPD
 /**
  * Auxiliary class to hold value, value-has-been-set flag, value update 
operation, value bytes.
  */
-@IgniteCodeGeneratingFail // Need to handle 'hasWriteVal' flag during write.
 public class TxEntryValueHolder implements Message {
-    /** */
+    /** Stored value. */
+    @Order(value = 0, method = "storedValue")
     @GridToStringInclude(sensitive = true)
-    private CacheObject val;
+    private @Nullable CacheObject val;
 
-    /** */
+    /** Cache operation. */
+    @Order(value = 1, method = "operation")
     @GridToStringInclude
     private GridCacheOperation op = NOOP;
 
     /** Flag indicating that value has been set for write. */
+    @Order(value = 2, method = "hasWriteValue")
     @GridToStringExclude
     private boolean hasWriteVal;
 
     /** Flag indicating that value has been set for read. */
     @GridToStringExclude
-    @GridDirectTransient
     private boolean hasReadVal;
 
     /**
@@ -102,32 +99,53 @@ public class TxEntryValueHolder implements Message {
     }
 
     /**
-     * Gets cache operation.
+     * Used only in serializer.
      *
+     * @return Stored value or null.
+     */
+    public @Nullable CacheObject storedValue() {
+        return hasWriteVal ? val : null;
+    }
+
+    /**
+     * Used only in serializer.
+     *
+     * @param val Stored value.
+     */
+    public void storedValue(@Nullable CacheObject val) {
+        this.val = val;
+    }
+
+    /**
      * @return Cache operation.
      */
-    public GridCacheOperation op() {
+    public GridCacheOperation operation() {
         return op;
     }
 
     /**
-     * Sets cache operation.
-     *
      * @param op Cache operation.
      */
-    public void op(GridCacheOperation op) {
+    public void operation(GridCacheOperation op) {
         this.op = op;
     }
 
     /**
-     * @return {@code True} if write value was set.
+     * @return Flag indicating that value has been set for write.
      */
     public boolean hasWriteValue() {
         return hasWriteVal;
     }
 
     /**
-     * @return {@code True} if read value was set.
+     * @param hasWriteVal Flag indicating that value has been set for write.
+     */
+    public void hasWriteValue(boolean hasWriteVal) {
+        this.hasWriteVal = hasWriteVal;
+    }
+
+    /**
+     * @return Flag indicating that value has been set for read.
      */
     public boolean hasReadValue() {
         return hasReadVal;
@@ -135,10 +153,9 @@ public class TxEntryValueHolder implements Message {
 
     /**
      * @param ctx Cache context.
-     * @throws org.apache.ignite.IgniteCheckedException If marshaling failed.
+     * @throws IgniteCheckedException If marshaling failed.
      */
-    public void marshal(GridCacheContext<?, ?> ctx)
-        throws IgniteCheckedException {
+    public void marshal(GridCacheContext<?, ?> ctx) throws 
IgniteCheckedException {
         if (hasWriteVal && val != null)
             val.prepareMarshal(ctx.cacheObjectContext());
     }
@@ -146,7 +163,7 @@ public class TxEntryValueHolder implements Message {
     /**
      * @param ctx Cache context.
      * @param ldr Class loader.
-     * @throws org.apache.ignite.IgniteCheckedException If unmarshalling 
failed.
+     * @throws IgniteCheckedException If unmarshalling failed.
      */
     public void unmarshal(CacheObjectValueContext ctx, ClassLoader ldr) throws 
IgniteCheckedException {
         if (hasWriteVal && val != null)
@@ -158,79 +175,6 @@ public class TxEntryValueHolder implements Message {
         return S.toString(TxEntryValueHolder.class, this);
     }
 
-    /** {@inheritDoc} */
-    @Override public boolean writeTo(ByteBuffer buf, MessageWriter writer) {
-        writer.setBuffer(buf);
-
-        if (!writer.isHeaderWritten()) {
-            if (!writer.writeHeader(directType()))
-                return false;
-
-            writer.onHeaderWritten();
-        }
-
-        switch (writer.state()) {
-            case 0:
-                if (!writer.writeBoolean(hasWriteVal))
-                    return false;
-
-                writer.incrementState();
-
-            case 1:
-                if (!writer.writeByte(op != null ? (byte)op.ordinal() : -1))
-                    return false;
-
-                writer.incrementState();
-
-            case 2:
-                if (!writer.writeCacheObject(hasWriteVal ? val : null))
-                    return false;
-
-                writer.incrementState();
-
-        }
-
-        return true;
-    }
-
-    /** {@inheritDoc} */
-    @Override public boolean readFrom(ByteBuffer buf, MessageReader reader) {
-        reader.setBuffer(buf);
-
-        switch (reader.state()) {
-            case 0:
-                hasWriteVal = reader.readBoolean();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-            case 1:
-                byte opOrd;
-
-                opOrd = reader.readByte();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                op = GridCacheOperation.fromOrdinal(opOrd);
-
-                reader.incrementState();
-
-            case 2:
-                val = reader.readCacheObject();
-
-                if (!reader.isLastRead())
-                    return false;
-
-                reader.incrementState();
-
-        }
-
-        return true;
-    }
-
     /** {@inheritDoc} */
     @Override public short directType() {
         return 101;

Reply via email to