Jackie-Jiang commented on code in PR #8884:
URL: https://github.com/apache/pinot/pull/8884#discussion_r905551783
##########
pinot-core/src/main/java/org/apache/pinot/core/query/pruner/SegmentPrunerService.java:
##########
@@ -76,18 +115,40 @@ public List<IndexSegment> prune(List<IndexSegment>
segments, QueryContext query)
return segments;
}
- private static List<IndexSegment> removeInvalidSegments(List<IndexSegment>
segments, QueryContext query) {
+ /**
+ * Filters the given list, returning a list that only contains the valid
segments, modifying the list received as
+ * argument.
+ *
+ * <p>
+ * This is a destructive operation. The list received as arguments may be
modified, so only the returned list should
+ * be used.
+ * </p>
+ *
+ * @param segments the list of segments to be pruned. This is a destructive
operation that may modify this list in an
+ * undefined way. Therefore, this list should not be used
after calling this method.
+ * @return the new list with filtered elements. This is the list that have
to be used.
+ */
+ private static List<IndexSegment> removeInvalidSegments(List<IndexSegment>
segments, QueryContext query,
+ SegmentPrunerStatistics stats) {
int selected = 0;
+ int invalid = 0;
for (IndexSegment segment : segments) {
- if (!isInvalidSegment(segment, query)) {
+ boolean isInvalid = isInvalidSegment(segment, query);
Review Comment:
(minor) We can skip the valid check if a segment is empty
```suggestion
if (!isEmptySegment(segment)) {
if (isInvalidSegment(segment, query)) {
invalid++
} else {
segments.set(selected++, segment);
}
}
```
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]