ibessonov commented on code in PR #2696:
URL: https://github.com/apache/ignite-3/pull/2696#discussion_r1360760969
##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStore.java:
##########
@@ -285,27 +280,46 @@ public CompletableFuture<DeltaFilePageStoreIo>
getOrCreateNewDeltaFile(
return newDeltaFilePageStoreIoFuture;
}
- int nextIndex = deltaFilePageStoreIos.isEmpty() ? 0 :
deltaFilePageStoreIos.get(0).fileIndex() + 1;
+ DeltaFilePageStoreIo newDeltaFilePageStoreIo =
addNewDeltaFilePageStoreIoToHead(pageIndexesSupplier.get(),
deltaFilPathFunction);
- DeltaFilePageStoreIoHeader header = new DeltaFilePageStoreIoHeader(
- LATEST_DELTA_FILE_PAGE_STORE_VERSION,
- nextIndex,
- filePageStoreIo.pageSize(),
- pageIndexesSupplier.get()
- );
+ future.complete(newDeltaFilePageStoreIo);
- DeltaFilePageStoreIo deltaFilePageStoreIo = new DeltaFilePageStoreIo(
- filePageStoreIo.ioFactory,
- deltaFilPathFunction.apply(nextIndex),
- header
- );
+ return future;
+ }
- // Should add to the head, since read operations should always start
from the most recent.
- deltaFilePageStoreIos.add(0, deltaFilePageStoreIo);
+ private DeltaFilePageStoreIo addNewDeltaFilePageStoreIoToHead(int[]
pageIndexes, IntFunction<Path> deltaFilPathFunction) {
+ List<DeltaFilePageStoreIo> previousValue;
+ List<DeltaFilePageStoreIo> newValue;
- future.complete(deltaFilePageStoreIo);
+ DeltaFilePageStoreIo newDeltaFilePageStoreIo;
- return future;
+ do {
+ previousValue = deltaFilePageStoreIos;
+
+ int nextIndex = previousValue.isEmpty() ? 0 :
previousValue.get(0).fileIndex() + 1;
+
+ var header = new DeltaFilePageStoreIoHeader(
+ LATEST_DELTA_FILE_PAGE_STORE_VERSION,
+ nextIndex,
+ filePageStoreIo.pageSize(),
+ pageIndexes
+ );
+
+ newDeltaFilePageStoreIo = new DeltaFilePageStoreIo(
+ filePageStoreIo.ioFactory,
+ deltaFilPathFunction.apply(nextIndex),
+ header
+ );
+
+ newValue = new ArrayList<>(previousValue);
+
+ // Should add to the head, since read operations should always
start from the most recent.
+ newValue.add(0, newDeltaFilePageStoreIo);
Review Comment:
With this code, you're inserting `previousValue` twice - in the beginning
and then shifted to the right. This is slower than it needs to be
##########
modules/page-memory/src/main/java/org/apache/ignite/internal/pagememory/persistence/store/FilePageStore.java:
##########
@@ -285,27 +280,46 @@ public CompletableFuture<DeltaFilePageStoreIo>
getOrCreateNewDeltaFile(
return newDeltaFilePageStoreIoFuture;
}
- int nextIndex = deltaFilePageStoreIos.isEmpty() ? 0 :
deltaFilePageStoreIos.get(0).fileIndex() + 1;
+ DeltaFilePageStoreIo newDeltaFilePageStoreIo =
addNewDeltaFilePageStoreIoToHead(pageIndexesSupplier.get(),
deltaFilPathFunction);
Review Comment:
Please rename `deltaFilPathFunction`, there's a letter missing
--
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]