mkhludnev commented on code in PR #16805:
URL: https://github.com/apache/lucene/pull/16805#discussion_r4232327168
##########
lucene/join/src/java/org/apache/lucene/search/join/JoinUtil.java:
##########
@@ -224,94 +216,20 @@ public static Query createJoinQuery(
joinScorer = (joinValue) -> (float)
aggregatedScores.get(joinValue).value;
}
- Collector collector;
- if (multipleValuesPerDocument) {
- collector =
- new SimpleCollector() {
-
- SortedNumericDocValues sortedNumericDocValues;
- Scorable scorer;
-
- @Override
- public void collect(int doc) throws IOException {
- if (sortedNumericDocValues.advanceExact(doc)) {
- for (int i = 0, count =
sortedNumericDocValues.docValueCount(); i < count; i++) {
- long value = sortedNumericDocValues.nextValue();
- joinValues.add(value);
- if (needsScore) {
- scoreAggregator.apply(value, scorer.score());
- }
- }
- }
- }
-
- @Override
- protected void doSetNextReader(LeafReaderContext context) throws
IOException {
- sortedNumericDocValues =
DocValues.getSortedNumeric(context.reader(), fromField);
- }
-
- @Override
- public void setScorer(Scorable scorer) throws IOException {
- this.scorer = scorer;
- }
-
- @Override
- public org.apache.lucene.search.ScoreMode scoreMode() {
- return needsScore
- ? org.apache.lucene.search.ScoreMode.COMPLETE
- : org.apache.lucene.search.ScoreMode.COMPLETE_NO_SCORES;
- }
- };
- } else {
- collector =
- new SimpleCollector() {
-
- NumericDocValues numericDocValues;
- Scorable scorer;
- private int lastDocID = -1;
-
- private boolean docsInOrder(int docID) {
- if (docID < lastDocID) {
- throw new AssertionError(
- "docs out of order: lastDocID=" + lastDocID + " vs docID="
+ docID);
- }
- lastDocID = docID;
- return true;
- }
-
- @Override
- public void collect(int doc) throws IOException {
- assert docsInOrder(doc);
- long value = 0;
- if (numericDocValues.advanceExact(doc)) {
- value = numericDocValues.longValue();
- }
- joinValues.add(value);
- if (needsScore) {
- scoreAggregator.apply(value, scorer.score());
- }
- }
-
- @Override
- protected void doSetNextReader(LeafReaderContext context) throws
IOException {
- numericDocValues = DocValues.getNumeric(context.reader(),
fromField);
- lastDocID = -1;
- }
-
- @Override
- public void setScorer(Scorable scorer) throws IOException {
- this.scorer = scorer;
- }
-
- @Override
- public org.apache.lucene.search.ScoreMode scoreMode() {
- return needsScore
- ? org.apache.lucene.search.ScoreMode.COMPLETE
- : org.apache.lucene.search.ScoreMode.COMPLETE_NO_SCORES;
- }
- };
- }
- fromSearcher.search(fromQuery, collector);
+ CollectorManager<Collector, Object> collectorManager =
+ new CollectorManager<>() {
+ @Override
+ public Collector newCollector() throws IOException {
+ return JoinUtil.newCollector(
+ fromField, multipleValuesPerDocument, joinValues, needsScore,
scoreAggregator);
+ }
+
+ @Override
+ public Object reduce(Collection<Collector> collectors) throws
IOException {
+ return null;
Review Comment:
why? how it yields a result?
--
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]