tkalkirill commented on code in PR #7109:
URL: https://github.com/apache/ignite-3/pull/7109#discussion_r2571382214
##########
modules/storage-page-memory/src/main/java/org/apache/ignite/internal/storage/pagememory/mv/AbstractPageMemoryMvPartitionStorage.java:
##########
@@ -962,27 +962,18 @@ public T map(VersionChain treeRow) {
}
@Override
- public @Nullable GcEntry peek(HybridTimestamp lowWatermark) {
- assert THREAD_LOCAL_LOCKER.get() != null;
-
- // Assertion above guarantees that we're in "runConsistently" closure.
- throwExceptionIfStorageNotInRunnableState();
-
- GcRowVersion head = renewableState.gcQueue().getFirst();
-
- // Garbage collection queue is empty.
- if (head == null) {
- return null;
- }
-
- HybridTimestamp rowTimestamp = head.getTimestamp();
+ public List<GcEntry> peek(HybridTimestamp lowWatermark, int count) {
+ return busy(() -> {
+ throwExceptionIfStorageNotInRunnableState();
- // There are no versions in the garbage collection queue before
watermark.
- if (rowTimestamp.compareTo(lowWatermark) > 0) {
- return null;
- }
+ if (count <= 0) {
+ return List.of();
+ } else if (count == 1) {
+ return peekSingleGcEntryBusy(lowWatermark);
+ }
- return head;
+ return peekGcEntriesBusy(lowWatermark, count);
Review Comment:
It's more optimal because it only searches for one record.
When working with a cursor, it loads multiple elements from the page at once
during the first search, which isn't necessary for a single record.
If this looks annoying, I'll remove 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]