Cyrill commented on code in PR #6309: URL: https://github.com/apache/ignite-3/pull/6309#discussion_r2239002909
########## modules/table/src/main/java/org/apache/ignite/internal/table/distributed/replicator/PartitionReplicaListener.java: ########## @@ -882,55 +883,82 @@ private CompletableFuture<List<BinaryRow>> retrieveExactEntriesUntilCursorEmpty( FullyQualifiedResourceId cursorId, int count ) { - PartitionTimestampCursor cursor = - remotelyTriggeredResourceRegistry.<CursorResource>register( - cursorId, - txCoordinatorId, - () -> new CursorResource( - mvDataStorage.scan(readTimestamp == null ? HybridTimestamp.MAX_VALUE : readTimestamp) - ) - ).cursor(); + var result = new ArrayList<BinaryRow>(count); - var resolutionFuts = new ArrayList<CompletableFuture<TimedBinaryRow>>(count); + return retrieveExactEntriesUntilCursorEmpty(txId, txCoordinatorId, readTimestamp, cursorId, count, result) + .thenApply(v -> { + closeCursorIfBatchNotFull(result, count, cursorId); - while (resolutionFuts.size() < count && cursor.hasNext()) { - ReadResult readResult = cursor.next(); - HybridTimestamp newestCommitTimestamp = readResult.newestCommitTimestamp(); + return result; + }); + } - TimedBinaryRow candidate; - if (newestCommitTimestamp == null || !readResult.isWriteIntent()) { - candidate = null; - } else { - BinaryRow committedRow = cursor.committed(newestCommitTimestamp); + private CompletableFuture<Void> retrieveExactEntriesUntilCursorEmpty( + UUID txId, + UUID txCoordinatorId, + @Nullable HybridTimestamp readTimestamp, + FullyQualifiedResourceId cursorId, + int count, + List<BinaryRow> result + ) { + CursorResource resource = remotelyTriggeredResourceRegistry.register( + cursorId, + txCoordinatorId, + () -> new CursorResource(mvDataStorage.scan(readTimestamp == null ? HybridTimestamp.MAX_VALUE : readTimestamp)) + ); - candidate = committedRow == null ? null : new TimedBinaryRow(committedRow, newestCommitTimestamp); - } + PartitionTimestampCursor cursor = resource.cursor(); - resolutionFuts.add(resolveReadResult(readResult, txId, readTimestamp, () -> candidate)); Review Comment: My assumption is that such change will boost the performance of RO scans. Now we create a few futures per row. They're completed futures if it is not a write intent. Feels like we can improve the code by creating fewer futures, for the whole scan, for example -- 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: notifications-unsubscr...@ignite.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org