Skip to content

Commit c17420c

Browse files
authored
Merge main into develop (eclipse-rdf4j#5705)
2 parents ea54c51 + 17411b7 commit c17420c

File tree

384 files changed

+49348
-13744
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

384 files changed

+49348
-13744
lines changed

core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/IndexReportingIterator.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,16 @@ public interface IndexReportingIterator {
2121

2222
String getIndexName();
2323

24+
default long getSourceRowsScannedActual() {
25+
return -1;
26+
}
27+
28+
default long getSourceRowsMatchedActual() {
29+
return -1;
30+
}
31+
32+
default long getSourceRowsFilteredActual() {
33+
return -1;
34+
}
35+
2436
}

core/common/iterator/src/main/java/org/eclipse/rdf4j/common/iteration/UnionIteration.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
*
99
* SPDX-License-Identifier: BSD-3-Clause
1010
*******************************************************************************/
11+
// Some portions generated by Codex
1112

1213
package org.eclipse.rdf4j.common.iteration;
1314

@@ -16,12 +17,13 @@
1617
import java.util.Arrays;
1718
import java.util.Iterator;
1819
import java.util.List;
20+
import java.util.function.ToLongFunction;
1921

2022
/**
2123
* An Iteration that returns the bag union of the results of a number of Iterations. 'Bag union' means that the
2224
* UnionIteration does not filter duplicate objects.
2325
*/
24-
public class UnionIteration<E> extends LookAheadIteration<E> {
26+
public class UnionIteration<E> extends LookAheadIteration<E> implements IndexReportingIterator {
2527

2628
/*-----------*
2729
* Variables *
@@ -31,6 +33,8 @@ public class UnionIteration<E> extends LookAheadIteration<E> {
3133

3234
private CloseableIteration<? extends E> currentIter;
3335

36+
private final List<IndexReportingIterator> indexReporters;
37+
3438
/*--------------*
3539
* Constructors *
3640
*--------------*/
@@ -51,7 +55,16 @@ public UnionIteration(CloseableIteration<? extends E>... args) {
5155
* @param args The Iterations containing the elements to iterate over.
5256
*/
5357
public UnionIteration(Iterable<? extends CloseableIteration<? extends E>> args) {
54-
argIter = args.iterator();
58+
List<CloseableIteration<? extends E>> iterations = new ArrayList<>();
59+
List<IndexReportingIterator> reporters = new ArrayList<>();
60+
for (CloseableIteration<? extends E> arg : args) {
61+
iterations.add(arg);
62+
if (arg instanceof IndexReportingIterator) {
63+
reporters.add((IndexReportingIterator) arg);
64+
}
65+
}
66+
argIter = iterations.iterator();
67+
indexReporters = reporters;
5568

5669
// Initialize with empty iteration
5770
currentIter = new EmptyIteration<>();
@@ -112,4 +125,43 @@ protected void handleClose() {
112125
}
113126

114127
}
128+
129+
@Override
130+
public String getIndexName() {
131+
for (IndexReportingIterator indexReporter : indexReporters) {
132+
String indexName = indexReporter.getIndexName();
133+
if (indexName != null && !indexName.isEmpty()) {
134+
return indexName;
135+
}
136+
}
137+
return "";
138+
}
139+
140+
@Override
141+
public long getSourceRowsScannedActual() {
142+
return aggregateMetric(IndexReportingIterator::getSourceRowsScannedActual);
143+
}
144+
145+
@Override
146+
public long getSourceRowsMatchedActual() {
147+
return aggregateMetric(IndexReportingIterator::getSourceRowsMatchedActual);
148+
}
149+
150+
@Override
151+
public long getSourceRowsFilteredActual() {
152+
return aggregateMetric(IndexReportingIterator::getSourceRowsFilteredActual);
153+
}
154+
155+
private long aggregateMetric(ToLongFunction<IndexReportingIterator> metricSupplier) {
156+
long total = 0L;
157+
boolean found = false;
158+
for (IndexReportingIterator indexReporter : indexReporters) {
159+
long value = metricSupplier.applyAsLong(indexReporter);
160+
if (value >= 0L) {
161+
total += value;
162+
found = true;
163+
}
164+
}
165+
return found ? total : -1L;
166+
}
115167
}

core/query/src/main/java/org/eclipse/rdf4j/query/Query.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,9 @@ enum QueryType {
9292
*
9393
* @param level The explanation level that should be used to create the explanation. Choose between: Unoptimized (as
9494
* parsed without optimizations) , Optimized (as is actually going to be used), Executed (as was
95-
* executed/evaluated, including some real performance metrics), Timed (as was executed/evaluated
96-
* including all real performance metrics). Executed and Timed level can potentially be slow.
95+
* executed/evaluated with actual result sizes), Telemetry (as was executed/evaluated, including
96+
* runtime telemetry metrics), Timed (as was executed/evaluated including timing for each plan node).
97+
* Executed, Telemetry and Timed levels can potentially be slow.
9798
* @return The explanation that we generated, which can be viewed in a human readable format with toString(), as
9899
* JSON or as a simplified query plan object structure.
99100
*/

core/query/src/main/java/org/eclipse/rdf4j/query/explanation/Explanation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ enum Level {
3434
Unoptimized, // simple parsed
3535
Optimized, // parsed and optimized, which includes cost estimated
3636
Executed, // plan as it was executed, which includes resultSizeActual
37+
Telemetry, // plan as it was executed with runtime telemetry metrics (without node timing)
3738
Timed, // plan as it was executed, including resultSizeActual and where each node has been timed
3839
}
3940

0 commit comments

Comments
 (0)