nfsantos commented on code in PR #1276:
URL: https://github.com/apache/jackrabbit-oak/pull/1276#discussion_r1461868615
##########
oak-search-elastic/src/main/java/org/apache/jackrabbit/oak/plugins/index/elastic/query/async/ElasticResultRowAsyncIterator.java:
##########
@@ -333,16 +339,24 @@ public void onSuccess(SearchResponse<ObjectNode>
searchResponse) {
}
LOG.trace("Emitting {} search hits, for a total of {} scanned
results", searchHits.size(), scannedRows);
+
+ Set<SearchHitListener> listenersWithHits = new HashSet<>();
+
for (Hit<ObjectNode> hit : searchHits) {
for (SearchHitListener l : searchHitListeners) {
- l.on(hit);
+ if (l.on(hit)) {
+ listenersWithHits.add(l);
+ }
}
}
+ // if any listener has not processed any hit, it means we need
to load more data since there could be
+ // listeners waiting for some results before triggering a new
scan
+ boolean areAllListenersProcessed =
listenersWithHits.containsAll(searchHitListeners);
Review Comment:
Nitpick: comparing the size of the sets is more efficient and produces the
same result: if the sets have the same size, then all listeners got a hit.
--
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]