JingsongLi commented on code in PR #6794:
URL: https://github.com/apache/paimon/pull/6794#discussion_r2608996394
##########
paimon-core/src/main/java/org/apache/paimon/globalindex/GlobalIndexScanBuilder.java:
##########
@@ -18,21 +18,77 @@
package org.apache.paimon.globalindex;
-import org.apache.paimon.data.BinaryRow;
+import org.apache.paimon.Snapshot;
+import org.apache.paimon.partition.PartitionPredicate;
+import org.apache.paimon.predicate.Predicate;
+import org.apache.paimon.utils.IOUtils;
import org.apache.paimon.utils.Range;
-import java.util.Set;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+import static
org.apache.paimon.utils.ManifestReadThreadPool.randomlyExecuteSequentialReturn;
/** Builder for scanning global indexes. */
public interface GlobalIndexScanBuilder {
GlobalIndexScanBuilder withSnapshot(long snapshotId);
- GlobalIndexScanBuilder withPartition(BinaryRow binaryRow);
+ GlobalIndexScanBuilder withSnapshot(Snapshot snapshot);
+
+ GlobalIndexScanBuilder withPartitionPredicate(PartitionPredicate
partitionPredicate);
GlobalIndexScanBuilder withRowRange(Range rowRange);
RowRangeGlobalIndexScanner build();
- Set<Range> shardList();
+ // Return sorted and no overlap ranges
+ List<Range> shardList();
+
+ static Optional<GlobalIndexResult> parallelScan(
+ final List<Range> ranges,
+ final GlobalIndexScanBuilder globalIndexScanBuilder,
+ final Predicate filter) {
+ List<RowRangeGlobalIndexScanner> scanners =
+ ranges.stream()
+ .map(globalIndexScanBuilder::withRowRange)
+ .map(GlobalIndexScanBuilder::build)
+ .collect(Collectors.toList());
+
+ try {
+ List<Optional<GlobalIndexResult>> rowsResults = new ArrayList<>();
+ Iterator<Optional<GlobalIndexResult>> resultIterators =
+ randomlyExecuteSequentialReturn(
+ scanner -> {
+ Optional<GlobalIndexResult> result =
scanner.scan(filter);
+ return Collections.singletonList(result);
+ },
+ scanners,
+ null);
Review Comment:
Introduce an option `global-index.thread-num`.
--
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]