This is an automated email from the ASF dual-hosted git repository. ibessonov 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 bf86c96589 IGNITE-18193 Removed transactions dependency from storage-api (#1355) bf86c96589 is described below commit bf86c96589be2c09061d56038fe0b9a6d601d80b Author: Ivan Bessonov <bessonov...@gmail.com> AuthorDate: Fri Nov 18 15:37:33 2022 +0300 IGNITE-18193 Removed transactions dependency from storage-api (#1355) --- modules/storage-api/build.gradle | 2 -- modules/storage-api/pom.xml | 5 ----- .../java/org/apache/ignite/internal/storage/RowId.java | 8 +++++--- .../storage/AbstractMvPartitionStorageTest.java | 17 ++++++++++++----- .../storage/rocksdb/RocksDbMvPartitionStorage.java | 6 ++++-- 5 files changed, 21 insertions(+), 17 deletions(-) diff --git a/modules/storage-api/build.gradle b/modules/storage-api/build.gradle index bf1f54f725..6c5c2bf263 100644 --- a/modules/storage-api/build.gradle +++ b/modules/storage-api/build.gradle @@ -24,7 +24,6 @@ dependencies { annotationProcessor project(":ignite-configuration-annotation-processor") implementation project(':ignite-api') implementation project(':ignite-schema') - implementation project(':ignite-transactions') implementation project(':ignite-configuration') implementation project(":ignite-core") implementation libs.jetbrains.annotations @@ -46,7 +45,6 @@ dependencies { testFixturesImplementation project(':ignite-configuration') testFixturesImplementation project(':ignite-schema') testFixturesImplementation(testFixtures(project(':ignite-schema'))) - testFixturesImplementation project(':ignite-transactions') testFixturesImplementation project(':ignite-api') testFixturesImplementation libs.jetbrains.annotations testFixturesImplementation libs.hamcrest.core diff --git a/modules/storage-api/pom.xml b/modules/storage-api/pom.xml index dfb64594f7..640c722770 100644 --- a/modules/storage-api/pom.xml +++ b/modules/storage-api/pom.xml @@ -43,11 +43,6 @@ <artifactId>ignite-schema</artifactId> </dependency> - <dependency> - <groupId>org.apache.ignite</groupId> - <artifactId>ignite-transactions</artifactId> - </dependency> - <!-- Test dependencies --> <dependency> <groupId>org.apache.ignite</groupId> diff --git a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/RowId.java b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/RowId.java index e38e3759fa..627ea03347 100644 --- a/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/RowId.java +++ b/modules/storage-api/src/main/java/org/apache/ignite/internal/storage/RowId.java @@ -19,8 +19,8 @@ package org.apache.ignite.internal.storage; import java.io.Serializable; import java.util.UUID; -import org.apache.ignite.internal.tx.Timestamp; import org.jetbrains.annotations.Nullable; +import org.jetbrains.annotations.TestOnly; /** * Class that represents row ID in primary index of the table. Contains a timestamp-based UUID and a partition ID. @@ -39,12 +39,14 @@ public final class RowId implements Serializable, Comparable<RowId> { } /** - * Create a row ID with the UUID value based on {@link Timestamp}. + * Create a row ID with the UUID value based on {@link UUID#randomUUID()}. + * Intended for tests only, because random UUIDs are very slow when it comes to frequent usages. * * @param partitionId Partition ID. */ + @TestOnly public RowId(int partitionId) { - this(partitionId, Timestamp.nextVersion().toUuid()); + this(partitionId, UUID.randomUUID()); } /** diff --git a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvPartitionStorageTest.java b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvPartitionStorageTest.java index 4539c29bff..cd0f94b8ee 100644 --- a/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvPartitionStorageTest.java +++ b/modules/storage-api/src/testFixtures/java/org/apache/ignite/internal/storage/AbstractMvPartitionStorageTest.java @@ -45,9 +45,9 @@ import org.apache.ignite.internal.hlc.HybridClock; import org.apache.ignite.internal.hlc.HybridClockImpl; import org.apache.ignite.internal.hlc.HybridTimestamp; import org.apache.ignite.internal.schema.BinaryRow; -import org.apache.ignite.internal.tx.Timestamp; import org.apache.ignite.internal.util.Cursor; import org.apache.ignite.lang.IgniteBiTuple; +import org.jetbrains.annotations.Nullable; import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.EnumSource; @@ -95,7 +95,14 @@ public abstract class AbstractMvPartitionStorageTest extends BaseMvStoragesTest * Inserts a row inside of consistency closure. */ protected RowId insert(BinaryRow binaryRow, UUID txId) { - RowId rowId = new RowId(PARTITION_ID); + return insert(binaryRow, txId, null); + } + + /** + * Inserts a row inside of consistency closure. + */ + protected RowId insert(BinaryRow binaryRow, UUID txId, @Nullable UUID explicitRowId) { + RowId rowId = explicitRowId == null ? new RowId(PARTITION_ID) : new RowId(PARTITION_ID, explicitRowId); storage.runConsistently(() -> storage.addWrite(rowId, binaryRow, txId, UUID.randomUUID(), 0)); @@ -143,7 +150,7 @@ public abstract class AbstractMvPartitionStorageTest extends BaseMvStoragesTest * Creates a new transaction id. */ private static UUID newTransactionId() { - return Timestamp.nextVersion().toUuid(); + return UUID.randomUUID(); } /** @@ -1307,11 +1314,11 @@ public abstract class AbstractMvPartitionStorageTest extends BaseMvStoragesTest @ParameterizedTest @EnumSource(ScanTimestampProvider.class) void committedMethodCallDoesNotInterfereWithIteratingOverScanCursor(ScanTimestampProvider scanTsProvider) throws Exception { - RowId rowId1 = insert(binaryRow, txId); + RowId rowId1 = insert(binaryRow, txId, new UUID(0, 0)); HybridTimestamp commitTs1 = clock.now(); commitWrite(rowId1, commitTs1); - insert(binaryRow2, txId); + insert(binaryRow2, txId, new UUID(0, 1)); try (PartitionTimestampCursor cursor = scan(scanTsProvider.scanTimestamp(clock))) { cursor.next(); diff --git a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java index e940477bc6..e8c4aa2be4 100644 --- a/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java +++ b/modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java @@ -1190,7 +1190,8 @@ public class RocksDbMvPartitionStorage implements MvPartitionStorage { // - R1 > R0, this means that we found next row and T1 is either missing (pending row) or represents the latest // version of the row. It doesn't matter in this case, because this row id will be reused to find its value // at time T0. Additional "seek" will be required to do it. - it.seek(seekKeyBuf.array()); + //TODO IGNITE-18201 Remove copying. + it.seek(copyOf(seekKeyBuf.array(), ROW_PREFIX_SIZE)); // Finish scan if nothing was found. if (invalid(it)) { @@ -1291,7 +1292,8 @@ public class RocksDbMvPartitionStorage implements MvPartitionStorage { ByteBuffer directBuffer = MV_KEY_BUFFER.get().position(0); while (true) { - it.seek(seekKeyBuf.array()); + //TODO IGNITE-18201 Remove copying. + it.seek(copyOf(seekKeyBuf.array(), ROW_PREFIX_SIZE)); if (invalid(it)) { return false;