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


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/AddWriteCommittedResultStatus.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.storage;
+
+/** Status of result {@link MvPartitionStorage#addWriteCommitted} add} write 
intent committed. */
+public enum AddWriteCommittedResultStatus {
+    /** Successfully add write intent committed. */

Review Comment:
   ```suggestion
       /** Successfully add write committed. */
   ```



##########
modules/partition-replicator/src/main/java/org/apache/ignite/internal/partition/replicator/raft/snapshot/PartitionDataStorage.java:
##########
@@ -133,37 +134,53 @@ default CompletableFuture<Void> flush() {
      */
     @Nullable RaftGroupConfiguration committedGroupConfiguration();
 
+    // TODO: https://issues.apache.org/jira/browse/IGNITE-22522 - remove 
mentions of commit *table*.
     /**
-     * Creates (or replaces) an uncommitted (aka pending) version, assigned to 
the given transaction id.
-     * In details:
-     * - if there is no uncommitted version, a new uncommitted version is added
-     * - if there is an uncommitted version belonging to the same transaction, 
it gets replaced by the given version
-     * - if there is an uncommitted version belonging to a different 
transaction, {@link TxIdMismatchException} is thrown
+     * Creates (or replaces) an uncommitted (aka pending) version, assigned to 
the given transaction ID.
+     * <p>In details:</p>
+     * <ul>
+     * <li>If there is no uncommitted version, a new uncommitted version is 
added.</li>
+     * <li>If there is an uncommitted version belonging to the same 
transaction, it gets replaced by the given version.</li>
+     * <li>If there is an uncommitted version belonging to a different 
transaction, nothing will happen.</li>
+     * </ul>
      *
-     * <p>This must be called under a lock acquired using {@link 
#acquirePartitionSnapshotsReadLock()}.
-     *
-     * @param rowId Row id.
-     * @param row Table row to update. Key only row means value removal.
-     * @param txId Transaction id.
-     * @param commitTableId Commit table id.
-     * @param commitPartitionId Commit partitionId.
-     * @return Previous uncommitted row version associated with the row id, or 
{@code null} if no uncommitted version
-     *     exists before this call
-     * @throws TxIdMismatchException If there's another pending update 
associated with different transaction id.
+     * @param rowId Row ID.
+     * @param row Table row to update. {@code null} means value removal.
+     * @param txId Transaction ID.
+     * @param commitTableOrZoneId Commit table/zone ID.
+     * @param commitPartitionId Commit partition ID.
+     * @return Result of add write intent.
      * @throws StorageException If failed to write data to the storage.
-     * @see MvPartitionStorage#addWrite(RowId, BinaryRow, UUID, int, int)
+     * @see MvPartitionStorage#addWrite
      */
-    @Nullable BinaryRow addWrite(RowId rowId, @Nullable BinaryRow row, UUID 
txId, int commitTableId, int commitPartitionId)
-            throws TxIdMismatchException, StorageException;
+    AddWriteResult addWrite(
+            RowId rowId,
+            @Nullable BinaryRow row,
+            UUID txId,
+            int commitTableOrZoneId,
+            int commitPartitionId
+    ) throws StorageException;
 
     /**
-     * Write and commit the row in one step.
+     * Creates a committed version.
+     * <p>In details:</p>
+     * <ul>
+     * <li>If there is no uncommitted version, a new committed version is 
added.</li>
+     * <li>f there is an uncommitted version, nothing will happen.</li>

Review Comment:
   ```suggestion
        * <li>If there is an uncommitted version, nothing will happen.</li>
   ```



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/AddWriteResult.java:
##########
@@ -0,0 +1,89 @@
+/*
+ * 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.storage;
+
+import java.util.UUID;
+import org.apache.ignite.internal.hlc.HybridTimestamp;
+import org.apache.ignite.internal.schema.BinaryRow;
+import org.apache.ignite.internal.tostring.S;
+import org.jetbrains.annotations.Nullable;
+
+/** Result of {@link MvPartitionStorage#addWrite add} of write intent. */
+public class AddWriteResult {
+    private final AddWriteResultStatus status;
+
+    private final @Nullable BinaryRow previousWriteIntent;
+
+    private final @Nullable UUID currentWriteIntentTxId;
+
+    private final @Nullable HybridTimestamp previousCommitTimestamp;

Review Comment:
   Word "previous" has different semantics in these fields. I suggest renaming 
`previousWriteIntent` into `currentWriteIntent`, because that's what currently 
in the storage



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/AddWriteCommittedResultStatus.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.storage;
+
+/** Status of result {@link MvPartitionStorage#addWriteCommitted} add} write 
intent committed. */
+public enum AddWriteCommittedResultStatus {
+    /** Successfully add write intent committed. */

Review Comment:
   Intents are always uncommitted, so writing `intent committed` doesn't really 
make sense



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/MvPartitionStorage.java:
##########
@@ -215,17 +220,23 @@ default CompletableFuture<Void> flush() {
 
     /**
      * Creates a committed version.
-     * In details:
-     * - if there is no uncommitted version, a new committed version is added
-     * - if there is an uncommitted version, this method may fail with a 
system exception (this method should not be called if there
-     *   is already something uncommitted for the given row).
+     * <p>In details:</p>
+     * <ul>
+     * <li>If there is no uncommitted version, a new committed version is 
added.</li>
+     * <li>f there is an uncommitted version, nothing will happen.</li>

Review Comment:
   ```suggestion
        * <li>If there is an uncommitted version, nothing will happen.</li>
   ```



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/AddWriteResultStatus.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.storage;
+
+/** Status of result {@link MvPartitionStorage#addWrite add} of write intent. 
*/
+public enum AddWriteResultStatus {
+    /** Successful add of write intent or replace for same transaction. */
+    SUCCESS,
+
+    /** Failed to add write intent because it already exists for another 
transaction. */
+    WRITE_INTENT_EXISTS;

Review Comment:
   Maybe `TX_ID_MISMATCH` would be easier to read, this name is not specific 
enough. It means that **conflicting** write intent exists, but that's too long



##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/AddWriteCommittedResultStatus.java:
##########
@@ -0,0 +1,27 @@
+/*
+ * 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.storage;
+
+/** Status of result {@link MvPartitionStorage#addWriteCommitted} add} write 
intent committed. */
+public enum AddWriteCommittedResultStatus {
+    /** Successfully add write intent committed. */
+    SUCCESS,
+
+    /** Failed to add write intent committed because there is an uncommitted 
write intent is present. */

Review Comment:
   ```suggestion
       /** Failed to add write committed because there is an uncommitted write 
intent present. */
   ```



-- 
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: notifications-unsubscr...@ignite.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to