tkalkirill commented on code in PR #947:
URL: https://github.com/apache/ignite-3/pull/947#discussion_r928617474


##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStore.java:
##########
@@ -17,122 +17,108 @@
 
 package org.apache.ignite.internal.pagememory.persistence.store;
 
-import static java.nio.ByteOrder.nativeOrder;
-import static java.nio.file.StandardOpenOption.CREATE;
-import static java.nio.file.StandardOpenOption.READ;
-import static java.nio.file.StandardOpenOption.WRITE;
-import static org.apache.ignite.internal.util.IgniteUtils.hexInt;
-import static org.apache.ignite.internal.util.IgniteUtils.hexLong;
-import static org.apache.ignite.internal.util.IgniteUtils.toHexString;
-import static org.apache.ignite.lang.IgniteSystemProperties.getBoolean;
+import static org.apache.ignite.internal.pagememory.util.PageIdUtils.pageIndex;
 
 import java.io.IOException;
+import java.lang.invoke.MethodHandles;
+import java.lang.invoke.VarHandle;
 import java.nio.ByteBuffer;
-import java.nio.channels.ClosedByInterruptException;
-import java.nio.channels.ClosedChannelException;
-import java.nio.file.Files;
 import java.nio.file.Path;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.locks.ReadWriteLock;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.function.Supplier;
 import org.apache.ignite.internal.fileio.FileIo;
-import org.apache.ignite.internal.fileio.FileIoFactory;
-import org.apache.ignite.internal.pagememory.io.PageIo;
-import org.apache.ignite.internal.pagememory.persistence.FastCrc;
-import 
org.apache.ignite.internal.pagememory.persistence.IgniteInternalDataIntegrityViolationException;
-import org.apache.ignite.internal.pagememory.util.PageIdUtils;
 import org.apache.ignite.lang.IgniteInternalCheckedException;
 import org.jetbrains.annotations.Nullable;
 
 /**
  * FilePageStore is a {@link PageStore} implementation that uses regular files 
to store pages.
  *
- * <p>Actual read and write operations are performed with {@link FileIo} 
abstract interface, list of its implementations is a good source
- * of information about functionality in Ignite Native Persistence.
+ * <p>It consists of the main file page store and delta file page stores, when 
reading the page at the beginning, the page is searched in
+ * the delta files and only then in the main file.
  *
  * <p>On a physical level each instance of {@code FilePageStore} corresponds 
to a partition file assigned to the local node.
  *
- * <p>Consists of:
- * <ul>
- *     <li>Header - {@link FilePageStoreHeader}. </li>
- *     <li>Body - data pages are multiples of {@link 
FilePageStoreHeader#pageSize() pageSize}.</li>
- * </ul>
+ * <p>Actual read and write operations are performed with {@link FileIo} 
abstract interface, list of its implementations is a good source
+ * of information about functionality in Ignite Native Persistence.
+ *
+ * <p>To create a delta file first invoke {@link 
#getOrCreateNewDeltaFile(Supplier)} then fill it and then invoke {@link
+ * #completeNewDeltaFile()}.
  */
 public class FilePageStore implements PageStore {
-    /** File version. */
-    public static final int VERSION_1 = 1;
+    private static final VarHandle PAGE_COUNT;
 
-    /** Skip CRC calculation flag. */
-    // TODO: IGNITE-17011 Move to config
-    private final boolean skipCrc = getBoolean("IGNITE_PDS_SKIP_CRC");
+    private static final VarHandle NEW_DELTA_FILE_PAGE_STORE_IO_FUTURE;
 
-    /** File page store version. */
-    private final int version;
+    static {
+        try {
+            PAGE_COUNT = 
MethodHandles.lookup().findVarHandle(FilePageStore.class, "pageCount", 
int.class);
 
-    /** Page size in bytes. */
-    private final int pageSize;
+            NEW_DELTA_FILE_PAGE_STORE_IO_FUTURE = 
MethodHandles.lookup().findVarHandle(
+                    FilePageStore.class,
+                    "newDeltaFilePageStoreIoFuture",
+                    CompletableFuture.class
+            );
+        } catch (ReflectiveOperationException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
 
-    /** Header size in bytes. Should be aligned to the {@link #pageSize}. */
-    private final int headerSize;
+    /** File page store version. */
+    public static final int VERSION_1 = 1;
 
-    /** File page store path. */
-    private final Path filePath;
+    /** Delta file page store IO version. */
+    public static final int DELTA_FILE_VERSION_1 = 1;
 
-    /** {@link FileIo} factory. */
-    private final FileIoFactory ioFactory;
+    /** File page store IO. */
+    private final FilePageStoreIo filePageStoreIo;
 
     /** Page count. */
-    private final AtomicInteger pageCount = new AtomicInteger();
+    private volatile int pageCount;
 
-    private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+    /** New page allocation listener. */
+    private volatile @Nullable PageAllocationListener pageAllocationListener;
 
-    /** Caches the existence state of storage file. After it is initialized, 
it will be not {@code null} during lifecycle. */
-    private volatile Boolean fileExists;
+    /** Delta file page store IOs. */
+    private final List<DeltaFilePageStoreIo> deltaFilePageStoreIos;
 
-    /** {@link FileIo} for read/write operations with file. */
-    private volatile FileIo fileIo;
+    /** Future with a new delta file page store. */
+    private volatile @Nullable CompletableFuture<DeltaFilePageStoreIo> 
newDeltaFilePageStoreIoFuture;
 
-    /** Initialized file page store. */
-    private volatile boolean initialized;
+    /** {@link DeltaFilePageStoreIo} factory. */
+    private volatile @Nullable DeltaFilePageStoreIoFactory 
deltaFilePageStoreIoFactory;
 
-    /** New page allocation listener. */
-    private volatile @Nullable PageAllocationListener pageAllocationListener;
+    /** Callback on completion of delta file page store creation. */
+    private volatile @Nullable CompleteCreationDeltaFilePageStoreIoCallback 
completeCreationDeltaFilePageStoreIoCallback;

Review Comment:
   We personally decided that I would delete it.



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