kkewwei commented on code in PR #17028:
URL: https://github.com/apache/lucene/pull/17028#discussion_r4587586557
##########
lucene/join/src/java/org/apache/lucene/search/join/GlobalOrdinalsWithScoreCollectorManager.java:
##########
@@ -156,48 +167,27 @@ final class OrdinalMapCollector implements LeafCollector {
public void collect(int doc) throws IOException {
if (docTermOrds.advanceExact(doc)) {
final int globalOrd = (int)
segmentOrdToGlobalOrdLookup.get(docTermOrds.ordValue());
- Lock lock = locks[globalOrd / arraySize];
- lock.lock();
- try {
- collectedOrds.set(globalOrd);
- double existingScore = scores.getScore(globalOrd);
- double newScore = scorer.score();
- doScore(globalOrd, existingScore, newScore);
- if (occurrences != null) {
- occurrences.increment(globalOrd);
+ if (locks == null) {
+ collectOrd(globalOrd);
+ } else {
+ Lock lock = locks[globalOrd / arraySize];
+ lock.lock();
+ try {
+ collectOrd(globalOrd);
+ } finally {
+ lock.unlock();
}
- } finally {
- lock.unlock();
}
}
}
- @Override
- public void setScorer(Scorable scorer) throws IOException {
- this.scorer = scorer;
- }
- }
-
- final class SegmentOrdinalCollector implements LeafCollector {
-
- private final SortedDocValues docTermOrds;
- private Scorable scorer;
-
- SegmentOrdinalCollector(SortedDocValues docTermOrds) {
- this.docTermOrds = docTermOrds;
- }
-
- @Override
- public void collect(int doc) throws IOException {
- if (docTermOrds.advanceExact(doc)) {
- int segmentOrd = docTermOrds.ordValue();
- collectedOrds.set(segmentOrd);
- double existingScore = scores.getScore(segmentOrd);
- double newScore = scorer.score();
- doScore(segmentOrd, existingScore, newScore);
- if (occurrences != null) {
- occurrences.increment(segmentOrd);
- }
+ private void collectOrd(int globalOrd) throws IOException {
+ collectedOrds.set(globalOrd);
+ double existingScore = scores.getScore(globalOrd);
+ double newScore = scorer.score();
Review Comment:
I'm not sure it's worth moving`scorer.score()` outside the lock.
--
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]