ibessonov commented on code in PR #1235:
URL: https://github.com/apache/ignite-3/pull/1235#discussion_r1001731046


##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableMessageGroup.java:
##########
@@ -125,4 +125,23 @@ public interface TableMessageGroup {
      * Message type for {@link SnapshotTxDataResponse}.
      */
     short SNAPSHOT_TX_DATA_RESPONSE = 16;
+
+    /**
+     *
+     */
+    public interface Commands {

Review Comment:
   Please add a little comment to the class and for each constant. `Mesage type 
for {@link Foo}.` is enough, like for other messages



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/TableMessageGroup.java:
##########
@@ -125,4 +125,23 @@ public interface TableMessageGroup {
      * Message type for {@link SnapshotTxDataResponse}.
      */
     short SNAPSHOT_TX_DATA_RESPONSE = 16;
+
+    /**
+     *
+     */
+    public interface Commands {
+        short PARTITION = 40;
+
+        short FINISH_TX = 41;
+
+        short TX_CLEANUP = 42;
+
+        short UPDATE_ALL = 43;
+
+        short UPDATE = 44;
+
+        short HYBRID_TIMESTAMP = 60;
+
+        short ROW_ID = 61;

Review Comment:
   RowId can be encoded as a UUID. Partition id can be ignored, it matches the 
id of the raft group.



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/command/HybridTimestampMessage.java:
##########
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.table.distributed.command;
+
+import org.apache.ignite.hlc.HybridTimestamp;
+import org.apache.ignite.internal.table.distributed.TableMessageGroup;
+import org.apache.ignite.network.NetworkMessage;
+import org.apache.ignite.network.annotations.Transferable;
+
+/**
+ *
+ */
+@Transferable(value = TableMessageGroup.Commands.HYBRID_TIMESTAMP)
+public interface HybridTimestampMessage extends NetworkMessage {
+    /**
+     *

Review Comment:
   Don't forget to add comments



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/command/UpdateAllCommand.java:
##########
@@ -17,85 +17,91 @@
 
 package org.apache.ignite.internal.table.distributed.command;
 
+import java.nio.ByteBuffer;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.UUID;
 import org.apache.ignite.internal.schema.BinaryRow;
 import org.apache.ignite.internal.storage.RowId;
+import org.apache.ignite.internal.table.distributed.TableMessageGroup;
 import org.apache.ignite.internal.util.CollectionUtils;
+import org.apache.ignite.network.annotations.Transferable;
 import org.jetbrains.annotations.NotNull;
 
 /**
  * State machine command for updating a batch of entries.
  */
-public class UpdateAllCommand extends PartitionCommand {
-    /** Rows to update. */
-    private transient HashMap<RowId, BinaryRow> rowsToUpdate;
-
-    /** Bytes representation of a row to update map. */
-    private byte[] rowsToUpdateBytes;
-
-    /**
-     * Constructor for batch remove.
-     *
-     * @param removeRows Ids to remove.
-     * @param txId Transaction id.
-     */
-    public UpdateAllCommand(Collection<RowId> removeRows, @NotNull UUID txId) {
-        this(removeRows, null, txId);
-    }
-
-    /**
-     * Constructor for a batch update.
-     *
-     * @param rowsToUpdate Rows to update or insert.
-     * @param txId Transaction id.
-     */
-    public UpdateAllCommand(Map<RowId, BinaryRow> rowsToUpdate, @NotNull UUID 
txId) {
-        this(null, rowsToUpdate, txId);
-    }
-
-    /**
-     * The constructor.
-     *
-     * @param removeRows Ids to remove.
-     * @param rowsToUpdate Rows to update or insert.
-     * @param txId Transaction id.
-     */
-    private UpdateAllCommand(Collection<RowId> removeRows, Map<RowId, 
BinaryRow> rowsToUpdate, @NotNull UUID txId) {
-        super(txId);
-
-        int size = (removeRows == null ? 0 : removeRows.size()) + 
(rowsToUpdate == null ? 0 : rowsToUpdate.size());
-
-        HashMap<RowId, BinaryRow> rows = new HashMap<>(size);
-
-        if (!CollectionUtils.nullOrEmpty(removeRows)) {
-            removeRows.forEach(rowId -> rows.put(rowId, null));
-        }
-
-        if (!CollectionUtils.nullOrEmpty(rowsToUpdate)) {
-            rows.putAll(rowsToUpdate);
-        }
-
-        this.rowsToUpdate = rows;
-
-        rowsToUpdateBytes = CommandUtils.rowMapToBytes(rows);
-    }
-
-
-    /**
-     * Gets rows to update.
-     *
-     * @return Rows to update map.
-     */
-    public HashMap<RowId, BinaryRow> getRowsToUpdate() {
-        if (rowsToUpdate == null) {
-            rowsToUpdate = new HashMap();
-
-            CommandUtils.readRowMap(rowsToUpdateBytes, rowsToUpdate::put);
-        }
-
-        return rowsToUpdate;
-    }
+@Transferable(TableMessageGroup.Commands.UPDATE_ALL)
+public interface UpdateAllCommand extends PartitionCommand {
+//    /** Rows to update. */

Review Comment:
   I see you (maybe) forgot to remove this commented code. Why is it here?



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/command/PartitionCommand.java:
##########
@@ -18,31 +18,19 @@
 package org.apache.ignite.internal.table.distributed.command;
 
 import java.util.UUID;
+
+import org.apache.ignite.internal.table.distributed.TableMessageGroup;
+import org.apache.ignite.network.NetworkMessage;
+import org.apache.ignite.network.annotations.Transferable;
 import org.apache.ignite.raft.client.WriteCommand;
-import org.jetbrains.annotations.NotNull;
 
 /**
  * Partition transactional command.
  */
-public abstract class PartitionCommand implements WriteCommand {
-    /** Transaction id. */
-    private UUID txId;
-
-    /**
-     * The constructor.
-     *
-     * @param txId Transaction id.
-     */
-    public PartitionCommand(@NotNull UUID txId) {
-        this.txId = txId;
-    }
-
+@Transferable(TableMessageGroup.Commands.PARTITION)

Review Comment:
   Can this be transferred by its own? The class used to be abstract, maybe we 
don't need a dedicated message type, no one would use it anyway



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -925,9 +993,18 @@ private CompletableFuture<Object> 
processSingleEntryAction(ReadWriteSingleRowRep
                 CompletableFuture<RowId> lockFut = 
takeLocksForUpsert(searchKey, indexId, txId);
 
                 return lockFut.thenCompose(lockedRowId -> {
-                    CompletableFuture raftFut =
-                            lockedRowId != null ? 
applyCmdWithExceptionHandling(new UpdateCommand(lockedRowId, searchRow, txId)) :
-                                    applyCmdWithExceptionHandling(new 
UpdateCommand(new RowId(partId), searchRow, txId));
+                    RowIdMessage rowIdMsg = lockedRowId != null ? 
RowIdMessage.fromRowId(msgFactory, lockedRowId) :
+                            msgFactory.rowIdMessage()
+                                    .partitionId((short) partId)
+                                    .uuid(Timestamp.nextVersion().toUuid())
+                                    .build();
+
+                    CompletableFuture raftFut = applyCmdWithExceptionHandling(

Review Comment:
   Please add type arguments to raw types when you modify the code. It'll make 
it better



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -1427,4 +1530,15 @@ private CompletableFuture<BinaryRow> 
resolveWriteIntentAsync(
     private String partitionRaftGroupName(UUID tblId, int partition) {
         return tblId + "_part_" + partition;
     }
+
+    /**
+     * @param tmstmp

Review Comment:
   No comment



##########
modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java:
##########
@@ -770,16 +795,28 @@ private CompletableFuture<Object> 
processMultiEntryAction(ReadWriteMultiRowRepli
                         if (lockedRow != null) {
                             result.add(row);
                         } else {
-                            if (rowsToInsert.values().stream().noneMatch(row0 
-> row0.keySlice().equals(row.keySlice()))) {
-                                rowsToInsert.put(new RowId(partId), row);
+                            ByteBuffer keyToCheck = row.keySlice();
+                            if (!uniqueKeys.contains(keyToCheck)) {

Review Comment:
   Is this a fix for something? I see that the code is changed



-- 
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]

Reply via email to