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


##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaTest.java:
##########
@@ -193,6 +206,21 @@ void testStoragePartitionMetaPageId() {
         assertEquals(0, pageIndex(pageId));
     }
 
+    @Test
+    void testWiHead() {
+        StoragePartitionMeta meta = createMeta();
+
+        assertEquals(PageIdUtils.NULL_LINK, meta.wiHeadLink());
+
+        meta.updateWiHead(null, 1234L);

Review Comment:
   Please use a long with non-null high half



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaIoV3.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.pagememory;
+
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+
+/** Storage Io for partition metadata pages (version 3). */
+public class StoragePartitionMetaIoV3 extends StoragePartitionMetaIo {

Review Comment:
   Usually, V3 would extend V2. Is it on purpose that it does not? If yes, at 
least a comment is needed



##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaIoV3.java:
##########
@@ -0,0 +1,57 @@
+/*
+ * 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.pagememory;
+
+import static org.apache.ignite.internal.pagememory.util.PageUtils.getLong;
+import static org.apache.ignite.internal.pagememory.util.PageUtils.putLong;
+
+import org.apache.ignite.internal.pagememory.util.PageIdUtils;
+
+/** Storage Io for partition metadata pages (version 3). */
+public class StoragePartitionMetaIoV3 extends StoragePartitionMetaIo {
+    private static final int WI_HEAD_OFF = ESTIMATED_SIZE_OFF + Long.BYTES;
+
+    /** Constructor. */
+    StoragePartitionMetaIoV3() {
+        super(3);
+    }
+
+    @Override
+    public void initNewPage(long pageAddr, long pageId, int pageSize) {
+        super.initNewPage(pageAddr, pageId, pageSize);
+
+        setWiHead(pageAddr, PageIdUtils.NULL_LINK);
+    }
+
+    /**
+     * Sets the head link of the write intent list in the partition metadata.
+     *
+     * @param pageAddr The address of the page to update.
+     * @param headLink The link value to set as the head of the write intent 
list.
+     */
+    public void setWiHead(long pageAddr, long headLink) {
+        assertPageType(pageAddr);
+
+        putLong(pageAddr, WI_HEAD_OFF, headLink);
+    }
+
+    @Override
+    public long getWiHead(long pageAddr) {
+        return getLong(pageAddr, WI_HEAD_OFF);
+    }
+}

Review Comment:
   If we follow the path of not extending V2, then print method should be 
implemented. But I think the 'to extend or not to extend' question must be 
discussed first



##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaManagerTest.java:
##########
@@ -80,6 +80,16 @@ void testReadWritePartitionMeta(@WorkDirectory Path workDir) 
throws Exception {
         ByteBuffer buffer = allocateBuffer(PAGE_SIZE);
 
         try {
+            long wiHeadLink = Long.MAX_VALUE;
+            long lastAppliedIndex = Long.MAX_VALUE - 1;
+            long lastAppliedTerm = Long.MAX_VALUE - 2;
+            long pageId = Long.MAX_VALUE;

Review Comment:
   No offset?



##########
modules/storage-page-memory/src/test/java/org/apache/ignite/internal/storage/pagememory/StoragePartitionMetaTest.java:
##########
@@ -193,6 +206,21 @@ void testStoragePartitionMetaPageId() {
         assertEquals(0, pageIndex(pageId));
     }
 
+    @Test
+    void testWiHead() {
+        StoragePartitionMeta meta = createMeta();
+
+        assertEquals(PageIdUtils.NULL_LINK, meta.wiHeadLink());
+
+        meta.updateWiHead(null, 1234L);
+
+        assertEquals(1234L, meta.wiHeadLink());
+
+        meta.updateWiHead(UUID.randomUUID(), 5678L);
+
+        assertEquals(5678L, meta.wiHeadLink());
+    }
+

Review Comment:
   Please add a specific test making sure that wi head link does not corrupt 
estimated size



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