Apache Lucene open-source search software
Address compile errors due to MatchingDocs conversion to a record
Luca Cavannad3130e2e9e1c
diff --git a/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollectorManager.java b/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollectorManager.javaindex ab327fc612b..34ce3ab6697 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollectorManager.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/FacetsCollectorManager.java@@ -101,7 +101,7 @@ public class FacetsCollectorManager implements CollectorManager<FacetsCollector,for (FacetsCollector facetsCollector : facetsCollectors) {for (FacetsCollector.MatchingDocs matchingDocs : facetsCollector.getMatchingDocs()) {matchingDocsMap.compute(- matchingDocs.context,+ matchingDocs.context(),(leafReaderContext, existing) -> {if (existing == null) {return matchingDocs;@@ -115,40 +115,41 @@ public class FacetsCollectorManager implements CollectorManager<FacetsCollector,private static FacetsCollector.MatchingDocs merge(FacetsCollector.MatchingDocs matchingDocs1, FacetsCollector.MatchingDocs matchingDocs2) {- assert matchingDocs1.context == matchingDocs2.context;+ assert matchingDocs1.context() == matchingDocs2.context();final float[] scores;// scores array is null when keepScores is true, and may be null when there are no matches for a// segment partition, despite keepScores is true.- if (matchingDocs1.scores == null && matchingDocs2.scores == null) {+ if (matchingDocs1.scores() == null && matchingDocs2.scores() == null) {scores = new float[0];} else {- if (matchingDocs2.scores == null) {- scores = matchingDocs1.scores;- } else if (matchingDocs1.scores == null) {- scores = matchingDocs2.scores;+ if (matchingDocs2.scores() == null) {+ scores = matchingDocs1.scores();+ } else if (matchingDocs1.scores() == null) {+ scores = matchingDocs2.scores();} else {- int length = Math.max(matchingDocs1.scores.length, matchingDocs2.scores.length);+ int length = Math.max(matchingDocs1.scores().length, matchingDocs2.scores().length);// merge the arrays if both have values, their size is bound to the highest collected docidscores = new float[length];for (int i = 0; i < length; i++) {- float firstScore = i < matchingDocs1.scores.length ? matchingDocs1.scores[i] : 0;- float secondScore = i < matchingDocs2.scores.length ? matchingDocs2.scores[i] : 0;+ float firstScore = i < matchingDocs1.scores().length ? matchingDocs1.scores()[i] : 0;+ float secondScore = i < matchingDocs2.scores().length ? matchingDocs2.scores()[i] : 0;assert (firstScore > 0 && secondScore > 0) == false;scores[i] = Math.max(firstScore, secondScore);}}}- DocIdSetBuilder docIdSetBuilder = new DocIdSetBuilder(matchingDocs1.context.reader().maxDoc());+ DocIdSetBuilder docIdSetBuilder =+ new DocIdSetBuilder(matchingDocs1.context().reader().maxDoc());try {- docIdSetBuilder.add(matchingDocs1.bits.iterator());- docIdSetBuilder.add(matchingDocs2.bits.iterator());+ docIdSetBuilder.add(matchingDocs1.bits().iterator());+ docIdSetBuilder.add(matchingDocs2.bits().iterator());} catch (IOException e) {throw new UncheckedIOException(e);}- int totalHits = matchingDocs1.totalHits + matchingDocs2.totalHits;+ int totalHits = matchingDocs1.totalHits() + matchingDocs2.totalHits();return new FacetsCollector.MatchingDocs(- matchingDocs1.context, docIdSetBuilder.build(), totalHits, scores);+ matchingDocs1.context(), docIdSetBuilder.build(), totalHits, scores);}/**diff --git a/lucene/facet/src/java/org/apache/lucene/facet/range/DynamicRangeUtil.java b/lucene/facet/src/java/org/apache/lucene/facet/range/DynamicRangeUtil.javaindex 700f3b75b00..b6ae71217f2 100644--- a/lucene/facet/src/java/org/apache/lucene/facet/range/DynamicRangeUtil.java+++ b/lucene/facet/src/java/org/apache/lucene/facet/range/DynamicRangeUtil.java@@ -62,7 +62,8 @@ public final class DynamicRangeUtil {throws IOException {List<FacetsCollector.MatchingDocs> matchingDocsList = facetsCollector.getMatchingDocs();- int totalDoc = matchingDocsList.stream().mapToInt(matchingDoc -> matchingDoc.totalHits).sum();+ int totalDoc =+ matchingDocsList.stream().mapToInt(FacetsCollector.MatchingDocs::totalHits).sum();long[] values = new long[totalDoc];long[] weights = new long[totalDoc];long totalWeight = 0;@@ -71,8 +72,8 @@ public final class DynamicRangeUtil {List<Future<?>> futures = new ArrayList<>();List<SegmentTask> tasks = new ArrayList<>();for (FacetsCollector.MatchingDocs matchingDocs : matchingDocsList) {- if (matchingDocs.totalHits > 0) {- SegmentOutput segmentOutput = new SegmentOutput(matchingDocs.totalHits);+ if (matchingDocs.totalHits() > 0) {+ SegmentOutput segmentOutput = new SegmentOutput(matchingDocs.totalHits());// [1] retrieve values and associated weights concurrentlySegmentTask task =@@ -134,7 +135,7 @@ public final class DynamicRangeUtil {SegmentOutput segmentOutput)throws IOException {this.matchingDocs = matchingDocs;- this.matchingParentDocsItr = matchingDocs.bits.iterator();+ this.matchingParentDocsItr = matchingDocs.bits().iterator();this.fieldValueSource = fieldValueSource;this.weightValueSource = weightValueSource;this.segmentOutput = segmentOutput;@@ -142,8 +143,8 @@ public final class DynamicRangeUtil {@Overridepublic Void call() throws Exception {- LongValues fieldValue = fieldValueSource.getValues(matchingDocs.context, null);- LongValues weightValue = weightValueSource.getValues(matchingDocs.context, null);+ LongValues fieldValue = fieldValueSource.getValues(matchingDocs.context(), null);+ LongValues weightValue = weightValueSource.getValues(matchingDocs.context(), null);for (int doc = matchingParentDocsItr.nextDoc();doc != DocIdSetIterator.NO_MORE_DOCS;doc = matchingParentDocsItr.nextDoc()) {