sashapolo commented on code in PR #1003:
URL: https://github.com/apache/ignite-3/pull/1003#discussion_r945873358


##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/PartitionlessLinks.java:
##########
@@ -38,105 +42,53 @@ public class PartitionlessLinks {
     public static final int PARTITIONLESS_LINK_SIZE_BYTES = 6;
 
     /**
-     * Converts a full link to partitionless link by removing the partition ID 
from it.
+     * Reads a partitionless link from the memory.
      *
-     * @param link full link
-     * @return partitionless link
-     * @see PageIdUtils#link(long, int)
+     * @param pageAddr Page address.
+     * @param offset Data offset.
+     * @return Partitionless link.
      */
-    public static long removePartitionIdFromLink(long link) {
-        return ((link >> PageIdUtils.PART_ID_SIZE) & 0x0000FFFF00000000L)
-                | (link & 0xFFFFFFFFL);
-    }
-
-    /**
-     * Converts a partitionless link to a full link by inserting partition ID 
at the corresponding position.
-     *
-     * @param partitionlessLink link without partition
-     * @param partitionId       partition ID to insert
-     * @return full link
-     * @see PageIdUtils#link(long, int)
-     */
-    public static long addPartitionIdToPartititionlessLink(long 
partitionlessLink, int partitionId) {
-        return (partitionlessLink << PageIdUtils.PART_ID_SIZE) & 
0xFFFF000000000000L
-                | ((((long) partitionId) << PageIdUtils.PAGE_IDX_SIZE) & 
0xFFFF00000000L)
-                | (partitionlessLink & PageIdUtils.PAGE_IDX_MASK);
-    }
-
-    /**
-     * Returns high 16 bits of the 6 bytes representing a partitionless link.
-     *
-     * @param partitionlessLink link without partition info
-     * @return high 16 bits
-     * @see #assemble(short, int)
-     */
-    public static short high16Bits(long partitionlessLink) {
-        return (short) (partitionlessLink >> Integer.SIZE);
-    }
-
-    /**
-     * Returns low 32 bits of the 6 bytes representing a partitionless link.
-     *
-     * @param partitionlessLink link without partition info
-     * @return low 32 bits
-     * @see #assemble(short, int)
-     */
-    public static int low32Bits(long partitionlessLink) {
-        return (int) (partitionlessLink & PageIdUtils.PAGE_IDX_MASK);
-    }
-
-    /**
-     * Assembles a partitionless link from high 16 bits and 32 low bits of its 
representation.
-     *
-     * @param high16    high 16 bits
-     * @param low32     low 32 bits
-     * @return reconstructed partitionless link
-     * @see #high16Bits(long)
-     * @see #low32Bits(long)
-     */
-    public static long assemble(short high16, int low32) {
-        return ((((long) high16) & 0xFFFF) << 32)
-                | (((long) low32) & 0xFFFFFFFFL);
-    }
+    public static long readPartitionlessLink(int partitionId, long pageAddr, 
int offset) {
+        int tag = 0xFFFF & getShort(pageAddr, offset);
+        int pageIdx = getInt(pageAddr, offset + Short.BYTES);
 
-    static long readFromMemory(long pageAddr, int offset) {
-        short nextLinkHigh16 = getShort(pageAddr, offset);
-        int nextLinkLow32 = getInt(pageAddr, offset + Short.BYTES);
+        // Links to metapages are impossible. For the sake of simplicity, 
NULL_LINK is returned in this case.
+        if (pageIdx == 0) {
+            assert tag == 0 : tag;
 
-        return assemble(nextLinkHigh16, nextLinkLow32);
-    }
+            return RowVersion.NULL_LINK;
+        }
 
-    static long readFromBuffer(ByteBuffer buffer) {
-        short nextLinkHigh16 = buffer.getShort();
-        int nextLinkLow32 = buffer.getInt();
+        long pageId = pageId(partitionId, (byte) tag, pageIdx);
 
-        return assemble(nextLinkHigh16, nextLinkLow32);
+        return link(pageId, tag >>> 8);
     }
 
     /**
      * Writes a partitionless link to memory: first high 2 bytes, then low 4 
bytes.
      *
      * @param addr              address in memory where to start
-     * @param partitionlessLink the link to write
+     * @param link the link to write
      * @return number of bytes written (equal to {@link 
#PARTITIONLESS_LINK_SIZE_BYTES})
      */
-    public static long writeToMemory(long addr, long partitionlessLink) {
-        putShort(addr, 0, PartitionlessLinks.high16Bits(partitionlessLink));
-        addr += Short.BYTES;
-        putInt(addr, 0, PartitionlessLinks.low32Bits(partitionlessLink));
+    public static long writePartitionlessLink(long addr, long link) {
+        putShort(addr, 0, (short) tag(link));

Review Comment:
   ok



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