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

ptupitsyn pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git


The following commit(s) were added to refs/heads/main by this push:
     new 5bd71009c8 IGNITE-19794 Remove BinaryTuple slicing in 
ClientMessagePacker (#2290)
5bd71009c8 is described below

commit 5bd71009c820bf402f19d50e7b5df28238a7b846
Author: Pavel Tupitsyn <[email protected]>
AuthorDate: Thu Jul 6 08:11:51 2023 +0300

    IGNITE-19794 Remove BinaryTuple slicing in ClientMessagePacker (#2290)
    
    Trimming (slicing) the key part of the `BinaryTuple` is not necessary: 
methods like `deleteAll` already return key-only tuples. Add an assertion 
instead.
---
 .../ignite/internal/client/proto/ClientMessagePacker.java | 15 ++++-----------
 .../client/handler/requests/table/ClientTableCommon.java  |  9 +++++----
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git 
a/modules/client-common/src/main/java/org/apache/ignite/internal/client/proto/ClientMessagePacker.java
 
b/modules/client-common/src/main/java/org/apache/ignite/internal/client/proto/ClientMessagePacker.java
index 6739e8c8cc..9998f10174 100644
--- 
a/modules/client-common/src/main/java/org/apache/ignite/internal/client/proto/ClientMessagePacker.java
+++ 
b/modules/client-common/src/main/java/org/apache/ignite/internal/client/proto/ClientMessagePacker.java
@@ -26,7 +26,7 @@ import java.nio.ByteBuffer;
 import java.util.BitSet;
 import java.util.UUID;
 import org.apache.ignite.internal.binarytuple.BinaryTupleBuilder;
-import org.apache.ignite.internal.binarytuple.BinaryTupleReader;
+import org.apache.ignite.internal.binarytuple.BinaryTupleParser;
 
 /**
  * ByteBuf-based MsgPack implementation. Replaces {@link 
org.msgpack.core.MessagePacker} to avoid
@@ -609,19 +609,12 @@ public class ClientMessagePacker implements AutoCloseable 
{
     /**
      * Packs binary tuple.
      *
-     * @param binaryTupleReader Binary tuple parser.
-     * @param elementCount Number of elements to pack. When {@code -1} all 
elements are packed.
+     * @param binaryTupleParser Binary tuple parser.
      */
-    public void packBinaryTuple(BinaryTupleReader binaryTupleReader, int 
elementCount) {
-        ByteBuffer buf = binaryTupleReader.byteBuffer();
+    public void packBinaryTuple(BinaryTupleParser binaryTupleParser) {
+        ByteBuffer buf = binaryTupleParser.byteBuffer();
         int len = buf.limit() - buf.position();
 
-        if (elementCount > -1) {
-            binaryTupleReader.seek(elementCount - 1);
-            len = binaryTupleReader.end();
-            buf.limit(len + buf.position());
-        }
-
         packBinaryHeader(len);
         writePayload(buf);
     }
diff --git 
a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
 
b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
index b21764f65d..f347ba20a6 100644
--- 
a/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
+++ 
b/modules/client-handler/src/main/java/org/apache/ignite/client/handler/requests/table/ClientTableCommon.java
@@ -130,13 +130,14 @@ public class ClientTableCommon {
         }
 
         assert tuple instanceof BinaryTupleContainer : "Tuple must be a 
BinaryTupleContainer: " + tuple.getClass();
-
         BinaryTupleReader binaryTuple = ((BinaryTupleContainer) 
tuple).binaryTuple();
-
         assert binaryTuple != null : "Binary tuple must not be null: " + 
tuple.getClass();
 
-        int elementCount = part == TuplePart.KEY ? 
schema.keyColumns().length() : -1;
-        packer.packBinaryTuple(binaryTuple, elementCount);
+        int elementCount = part == TuplePart.KEY ? 
schema.keyColumns().length() : schema.length();
+        assert elementCount == binaryTuple.elementCount() :
+                "Tuple element count mismatch: " + elementCount + " != " + 
binaryTuple.elementCount();
+
+        packer.packBinaryTuple(binaryTuple);
     }
 
     /**

Reply via email to