rpuch commented on code in PR #1038:
URL: https://github.com/apache/ignite-3/pull/1038#discussion_r957300303


##########
modules/storage-api/src/main/java/org/apache/ignite/internal/storage/MvPartitionStorage.java:
##########
@@ -85,6 +86,21 @@ public interface MvPartitionStorage extends AutoCloseable {
      */
     long persistedIndex();
 
+    /**
+     * Converts {@link Timestamp} into {@link HybridTimestamp} with preserving 
local node time order.

Review Comment:
   ```suggestion
        * Converts {@link Timestamp} to {@link HybridTimestamp} preserving 
local node time order.
   ```



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/RowVersion.java:
##########
@@ -17,41 +17,39 @@
 
 package org.apache.ignite.internal.storage.pagememory.mv;
 
+import static org.apache.ignite.hlc.HybridTimestamp.HYBRID_TIMESTAMP_SIZE;
+
 import java.nio.ByteBuffer;
 import java.util.Objects;
+import org.apache.ignite.hlc.HybridTimestamp;
 import org.apache.ignite.internal.pagememory.Storable;
 import org.apache.ignite.internal.pagememory.io.AbstractDataPageIo;
 import org.apache.ignite.internal.pagememory.io.IoVersions;
 import org.apache.ignite.internal.storage.pagememory.mv.io.RowVersionDataIo;
 import org.apache.ignite.internal.tostring.IgniteToStringExclude;
 import org.apache.ignite.internal.tostring.S;
-import org.apache.ignite.internal.tx.Timestamp;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * Represents row version inside row version chain.
  */
-public class RowVersion implements Storable {
-    /** A 'timestamp' representing absense of a timestamp. */
-    public static final Timestamp NULL_TIMESTAMP = new 
Timestamp(Long.MIN_VALUE, Long.MIN_VALUE);
-
+public final class RowVersion implements Storable {
     /** Represents an absent partitionless link. */
     public static final long NULL_LINK = 0;
 
-    private static final int TIMESTAMP_STORE_SIZE_BYTES = 2 * Long.BYTES;
     private static final int NEXT_LINK_STORE_SIZE_BYTES = 
PartitionlessLinks.PARTITIONLESS_LINK_SIZE_BYTES;
     private static final int VALUE_SIZE_STORE_SIZE_BYTES = Integer.BYTES;
 
     public static final int TIMESTAMP_OFFSET = 0;
-    public static final int NEXT_LINK_OFFSET = TIMESTAMP_STORE_SIZE_BYTES;
+    public static final int NEXT_LINK_OFFSET = HYBRID_TIMESTAMP_SIZE;

Review Comment:
   ```suggestion
       public static final int NEXT_LINK_OFFSET = TIMESTAMP_OFFSET + 
HYBRID_TIMESTAMP_SIZE;
   ```
   
   I should have probably done this myself for consistency: prev field offet 
plus prev field size



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/Timestamps.java:
##########
@@ -17,62 +17,72 @@
 
 package org.apache.ignite.internal.storage.pagememory.mv;
 
+import static org.apache.ignite.hlc.HybridTimestamp.HYBRID_TIMESTAMP_SIZE;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
 import java.nio.ByteBuffer;
-import org.apache.ignite.internal.tx.Timestamp;
+import org.apache.ignite.hlc.HybridTimestamp;
 import org.jetbrains.annotations.Nullable;
 
 /**
- * Code to work with {@link Timestamp}s.
+ * Code to work with {@link HybridTimestamp}s.
  */
 public class Timestamps {

Review Comment:
   Should the class be renamed as it now works with `HybridTimestamp`s, not 
with `Timestamp`s?



##########
modules/storage-rocksdb/src/main/java/org/apache/ignite/internal/storage/rocksdb/RocksDbMvPartitionStorage.java:
##########
@@ -807,14 +814,12 @@ private ByteBuffer prepareHeapKeyBuf(RowId rowId) {
     /**
      * Writes a timestamp into a byte buffer, in descending lexicographical 
bytes order.
      */
-    private static void putTimestamp(ByteBuffer buf, Timestamp ts) {
+    private static void putTimestamp(ByteBuffer buf, HybridTimestamp ts) {
         assert buf.order() == BIG_ENDIAN;
 
-        // Two things to note here:
-        //  - "xor" with a single sign bit makes long values comparable 
according to RocksDB convention, where bytes are unsigned.

Review Comment:
   Why is this xoring removed? Do we rely on the fact that both components are 
non-negative?



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/Timestamps.java:
##########
@@ -17,62 +17,72 @@
 
 package org.apache.ignite.internal.storage.pagememory.mv;
 
+import static org.apache.ignite.hlc.HybridTimestamp.HYBRID_TIMESTAMP_SIZE;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getInt;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putInt;
 import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
 
 import java.nio.ByteBuffer;
-import org.apache.ignite.internal.tx.Timestamp;
+import org.apache.ignite.hlc.HybridTimestamp;
 import org.jetbrains.annotations.Nullable;
 
 /**
- * Code to work with {@link Timestamp}s.
+ * Code to work with {@link HybridTimestamp}s.
  */
 public class Timestamps {
     /**
-     * Reads a {@link Timestamp} value from memory.
+     * Reads a {@link HybridTimestamp} value from memory.
      *
      * @param pageAddr Address where page data starts.
      * @param offset Offset to the timestamp value relative to pageAddr.
      */
-    static @Nullable Timestamp readTimestamp(long pageAddr, int offset) {
-        long nodeId = getLong(pageAddr, offset);
-        long localTimestamp = getLong(pageAddr, offset + Long.BYTES);
+    static @Nullable HybridTimestamp readTimestamp(long pageAddr, int offset) {
+        long physical = getLong(pageAddr, offset);
+        int logical = getInt(pageAddr, offset + Long.BYTES);
 
-        Timestamp timestamp = new Timestamp(localTimestamp, nodeId);
-        if (timestamp.equals(RowVersion.NULL_TIMESTAMP)) {
-            timestamp = null;
+        if (physical == 0L && logical == 0) {

Review Comment:
   I suggest to extract these zeroes as constants and use them in writing 
methods as well. Just a little more connectivity in the code seems to be a good 
thing.



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