XiaoHongbo-Hope commented on code in PR #9050:
URL: https://github.com/apache/paimon/pull/9050#discussion_r3721991954
##########
paimon-common/src/main/java/org/apache/paimon/globalindex/GlobalIndexEvaluator.java:
##########
@@ -165,40 +175,64 @@ private CompletableFuture<Optional<GlobalIndexResult>>
visitCompoundAsync(
return CompletableFuture.allOf(childFutures.toArray(new
CompletableFuture[0]))
.thenApply(
v -> {
- List<Optional<GlobalIndexResult>> results = new
ArrayList<>();
- for
(CompletableFuture<Optional<GlobalIndexResult>> f : childFutures) {
+ List<Optional<Evaluation>> results = new
ArrayList<>();
+ for (CompletableFuture<Optional<Evaluation>> f :
childFutures) {
results.add(f.join());
}
return combineResults(results, predicate);
});
}
- private Optional<GlobalIndexResult> combineResults(
- List<Optional<GlobalIndexResult>> results, CompoundPredicate
predicate) {
+ private Optional<Evaluation> combineResults(
+ List<Optional<Evaluation>> results, CompoundPredicate predicate) {
+ Set<Integer> fieldIds = new HashSet<>();
if (predicate.function() instanceof Or) {
GlobalIndexResult compoundResult = GlobalIndexResult.createEmpty();
- for (Optional<GlobalIndexResult> childResult : results) {
- if (!childResult.isPresent()) {
+ for (Optional<Evaluation> child : results) {
+ if (!child.isPresent()) {
return Optional.empty();
}
- compoundResult = compoundResult.or(childResult.get());
+ compoundResult = compoundResult.or(child.get().result());
+ fieldIds.addAll(child.get().fieldIds());
}
- return Optional.of(compoundResult);
+ return Optional.of(new Evaluation(compoundResult, fieldIds));
} else {
Optional<GlobalIndexResult> compoundResult = Optional.empty();
- for (Optional<GlobalIndexResult> childResult : results) {
- if (childResult.isPresent()) {
+ for (Optional<Evaluation> child : results) {
+ if (child.isPresent()) {
if (compoundResult.isPresent()) {
- compoundResult =
Optional.of(compoundResult.get().and(childResult.get()));
+ compoundResult =
+
Optional.of(compoundResult.get().and(child.get().result()));
} else {
- compoundResult = childResult;
+ compoundResult = Optional.of(child.get().result());
}
+ fieldIds.addAll(child.get().fieldIds());
}
if (compoundResult.isPresent() &&
compoundResult.get().results().isEmpty()) {
- return compoundResult;
+ break;
}
}
- return compoundResult;
+ return compoundResult.map(result -> new Evaluation(result,
fieldIds));
+ }
+ }
+
+ /** Global-index matches and the fields which produced them. */
+ public static final class Evaluation {
+
+ private final GlobalIndexResult result;
+ private final Set<Integer> fieldIds;
Review Comment:
> Non-blocking: could we rename `fieldIds` to `contributingFieldIds` (and
keep the Python field/method names in sync)? This set intentionally excludes
unsupported or discarded branches; it is not the full predicate field set or
every field that was evaluated. The provenance distinction is the core contract
of this fix, and these APIs are introduced in this PR, so naming it explicitly
now would make future coverage call sites much harder to misuse. Suggested
contract: “Field IDs whose supported index results were combined into the
returned candidate; unsupported or discarded branches are excluded.”
Updated
--
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]