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


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java:
##########
@@ -100,9 +100,9 @@
  * <p>All pages in the tree are divided into levels. Leaves are always at the 
level {@code 0}. Levels of inner pages are thus positive.
  * Each
  * level represents a singly linked list - each page has a link to the 
<i>forward</i> page at the same level. It can be retrieved by calling
- * {@link BplusIo#getForward(long)}. This link must be a zero if there's no 
forward page. Forward links on level {@code 0} allow iterating
- * tree's keys and values effectively without traversing any inner nodes 
({@code AbstractForwardCursor}). Forward links in inner nodes have
- * different purpose, more on that later.
+ * {@link BplusIo#getForwardPageId(long, int)}. This link must be a zero if 
there's no forward page. Forward links on level {@code 0} allow

Review Comment:
   Old name was good enough, why did you rename it? Please change it back.



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/tree/BplusTree.java:
##########
@@ -113,8 +113,8 @@
  * </code></pre>
  * There are {@code N} items and {@code N+1} links. Each link points to page 
of a lower level. For example, pages on level {@code 2} always
  * point to pages of level {@code 1}. For an item {@code i} left subtree is 
defined by {@code link(i)} and right subtree is defined by
- * {@code link(i+1)} ({@link BplusInnerIo#getLeft(long, int)} and {@link 
BplusInnerIo#getRight(long, int)}). All items in the left subtree
- * are less or equal to the original item (basic property for the trees).
+ * {@code link(i+1)} ({@link BplusInnerIo#getLeftPageId(long, int, int)} and 
{@link BplusInnerIo#getRightPageId(long, int, int)}).

Review Comment:
   Same for these two. Please also return the old formatting back after 
renaming, if it fits



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/util/PartitionlessLinks.java:
##########
@@ -92,4 +100,45 @@ public static void writeToBuffer(ByteBuffer buffer, long 
link) {
 
         buffer.putInt(pageIndex(link));
     }
+
+    /**
+     * Reads a partitionless page ID from the memory.
+     *
+     * @param addr Address in memory.
+     * @param off Offset from {@code addr} in bytes.
+     * @param partId Partition ID.
+     * @return Page ID with partition ID.
+     */
+    public static long readPartitionlessPageId(long addr, int off, int partId) 
{
+        long rotationId = getByte(addr, off) & 0xFF;
+
+        byte flag = getByte(addr, off + Byte.BYTES);
+
+        int pageIdx = getInt(addr, off + Byte.BYTES + Byte.BYTES);
+
+        return pageId(partId, flag, pageIdx, rotationId);
+    }
+
+    /**
+     * Writes a partitionless page ID to memory.
+     * <ul>
+     *     <li>{@link PageIdUtils#rotationId} - 1 byte;</li>
+     *     <li>{@link PageIdUtils#flag Flag} - 1 byte;</li>
+     *     <li>{@link PageIdUtils#pageIndex Page index} - 4 bytes.</li>
+     * </ul>
+     *
+     * @param addr Address in memory.
+     * @param off Offset from {@code addr} in bytes.
+     * @param pageId Page ID.
+     * @return Number of bytes written (equal to {@link 
#PARTITIONLESS_PAGE_ID_SIZE_BYTES}).
+     */
+    public static long writePartitionlessPageId(long addr, int off, long 
pageId) {

Review Comment:
   Remove this method as well



##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/util/PartitionlessLinks.java:
##########
@@ -92,4 +100,45 @@ public static void writeToBuffer(ByteBuffer buffer, long 
link) {
 
         buffer.putInt(pageIndex(link));
     }
+
+    /**
+     * Reads a partitionless page ID from the memory.
+     *
+     * @param addr Address in memory.
+     * @param off Offset from {@code addr} in bytes.
+     * @param partId Partition ID.
+     * @return Page ID with partition ID.
+     */
+    public static long readPartitionlessPageId(long addr, int off, int partId) 
{

Review Comment:
   What's the difference between this and `readPartitionlessLink`?
   There should be no difference. Not only this implementation is buggy, it's 
also a copy-paste.
   Please make a single method and update comment in it. Renaming here would be 
fine



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