Apache Solr open-source search software
Make use of diamond operator in join module.
Martijn van Groningen3bd885f1e7bd
diff --git a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.javaindex a1b8c008477..a27be0cd9c4 100644--- a/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java+++ b/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java@@ -80,7 +80,7 @@ public class ToParentBlockJoinCollector extends Collector {// Maps each BlockJoinQuery instance to its "slot" in// joinScorers and in OneGroup's cached doc/scores/count:- private final Map<Query,Integer> joinQueryID = new HashMap<Query,Integer>();+ private final Map<Query,Integer> joinQueryID = new HashMap<>();private final int numParentHits;private final FieldValueHitQueue<OneGroup> queue;private final FieldComparator[] comparators;@@ -138,7 +138,7 @@ public class ToParentBlockJoinCollector extends Collector {int[][] docs;float[][] scores;int[] counts;- };+ }@Overridepublic void collect(int parentDoc) throws IOException {@@ -470,7 +470,7 @@ public class ToParentBlockJoinCollector extends Collector {final TopDocs topDocs = collector.topDocs(withinGroupOffset, numDocsInGroup);- groups[groupIDX-offset] = new GroupDocs<Integer>(og.score,+ groups[groupIDX-offset] = new GroupDocs<>(og.score,topDocs.getMaxScore(),numChildDocs,topDocs.scoreDocs,@@ -478,9 +478,9 @@ public class ToParentBlockJoinCollector extends Collector {groupSortValues);}- return new TopGroups<Integer>(new TopGroups<Integer>(sort.getSort(),- withinGroupSort == null ? null : withinGroupSort.getSort(),- 0, totalGroupedHitCount, groups, maxScore),+ return new TopGroups<>(new TopGroups<>(sort.getSort(),+ withinGroupSort == null ? null : withinGroupSort.getSort(),+ 0, totalGroupedHitCount, groups, maxScore),totalHitCount);}diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.javaindex cd3fe5a2de7..ab9fb420d90 100644--- a/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java@@ -162,13 +162,13 @@ public class TestBlockJoin extends LuceneTestCase {final Directory dir = newDirectory();final RandomIndexWriter w = new RandomIndexWriter(random(), dir);- final List<Document> docs = new ArrayList<Document>();+ final List<Document> docs = new ArrayList<>();docs.add(makeJob("java", 2007));docs.add(makeJob("python", 2010));Collections.shuffle(docs, random());docs.add(makeResume("Lisa", "United Kingdom"));- final List<Document> docs2 = new ArrayList<Document>();+ final List<Document> docs2 = new ArrayList<>();docs2.add(makeJob("ruby", 2005));docs2.add(makeJob("java", 2006));Collections.shuffle(docs2, random());@@ -283,7 +283,7 @@ public class TestBlockJoin extends LuceneTestCase {// Cannot assert this since we use NoMergePolicy:w.setDoRandomForceMergeAssert(false);- List<Document> docs = new ArrayList<Document>();+ List<Document> docs = new ArrayList<>();docs.add(makeJob("java", 2007));docs.add(makeJob("python", 2010));docs.add(makeResume("Lisa", "United Kingdom"));@@ -358,7 +358,7 @@ public class TestBlockJoin extends LuceneTestCase {}private Sort getRandomSort(String prefix, int numFields) {- final List<SortField> sortFields = new ArrayList<SortField>();+ final List<SortField> sortFields = new ArrayList<>();// TODO: sometimes sort by score; problem is scores are// not comparable across the two indices// sortFields.add(SortField.FIELD_SCORE);@@ -390,7 +390,7 @@ public class TestBlockJoin extends LuceneTestCase {final String[][] childFields = getRandomFields(numParentDocs);final boolean doDeletes = random().nextBoolean();- final List<Integer> toDelete = new ArrayList<Integer>();+ final List<Integer> toDelete = new ArrayList<>();// TODO: parallel star join, nested join cases too!final RandomIndexWriter w = new RandomIndexWriter(random(), dir);@@ -415,7 +415,7 @@ public class TestBlockJoin extends LuceneTestCase {parentJoinDoc.add(newStringField("blockID", ""+parentDocID, Field.Store.NO));}- final List<Document> joinDocs = new ArrayList<Document>();+ final List<Document> joinDocs = new ArrayList<>();if (VERBOSE) {StringBuilder sb = new StringBuilder();@@ -608,7 +608,7 @@ public class TestBlockJoin extends LuceneTestCase {}// Merge both sorts:- final List<SortField> sortFields = new ArrayList<SortField>(Arrays.asList(parentSort.getSort()));+ final List<SortField> sortFields = new ArrayList<>(Arrays.asList(parentSort.getSort()));sortFields.addAll(Arrays.asList(childSort.getSort()));final Sort parentAndChildSort = new Sort(sortFields.toArray(new SortField[sortFields.size()]));@@ -915,7 +915,7 @@ public class TestBlockJoin extends LuceneTestCase {final Directory dir = newDirectory();final RandomIndexWriter w = new RandomIndexWriter(random(), dir);- final List<Document> docs = new ArrayList<Document>();+ final List<Document> docs = new ArrayList<>();docs.add(makeJob("java", 2007));docs.add(makeJob("python", 2010));@@ -1060,7 +1060,7 @@ public class TestBlockJoin extends LuceneTestCase {final Directory dir = newDirectory();final RandomIndexWriter w = new RandomIndexWriter(random(), dir);- final List<Document> docs = new ArrayList<Document>();+ final List<Document> docs = new ArrayList<>();docs.add(makeJob("ruby", 2005));docs.add(makeJob("java", 2006));docs.add(makeJob("java", 2010));diff --git a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.javaindex 8083cdecd42..dbbf7ba2d7f 100644--- a/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java+++ b/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java@@ -17,9 +17,6 @@ package org.apache.lucene.search.join;* limitations under the License.*/-import java.io.IOException;-import java.util.*;-import org.apache.lucene.analysis.MockAnalyzer;import org.apache.lucene.analysis.MockTokenizer;import org.apache.lucene.document.Document;@@ -28,12 +25,10 @@ import org.apache.lucene.document.TextField;import org.apache.lucene.index.AtomicReader;import org.apache.lucene.index.AtomicReaderContext;import org.apache.lucene.index.BinaryDocValues;-import org.apache.lucene.index.DocTermOrds;import org.apache.lucene.index.DocsEnum;import org.apache.lucene.index.IndexReader;import org.apache.lucene.index.MultiFields;import org.apache.lucene.index.RandomIndexWriter;-import org.apache.lucene.index.ReaderUtil;import org.apache.lucene.index.SlowCompositeReaderWrapper;import org.apache.lucene.index.SortedSetDocValues;import org.apache.lucene.index.Term;@@ -54,11 +49,23 @@ import org.apache.lucene.search.TopScoreDocCollector;import org.apache.lucene.store.Directory;import org.apache.lucene.util.BytesRef;import org.apache.lucene.util.FixedBitSet;-import org.apache.lucene.util.LuceneTestCase.Slow;import org.apache.lucene.util.LuceneTestCase;import org.apache.lucene.util._TestUtil;import org.junit.Test;+import java.io.IOException;+import java.util.ArrayList;+import java.util.Collections;+import java.util.Comparator;+import java.util.HashMap;+import java.util.HashSet;+import java.util.List;+import java.util.Locale;+import java.util.Map;+import java.util.Set;+import java.util.SortedSet;+import java.util.TreeSet;+public class TestJoinUtil extends LuceneTestCase {public void testSimple() throws Exception {@@ -374,7 +381,7 @@ public class TestJoinUtil extends LuceneTestCase {IndexIterationContext context = new IndexIterationContext();int numRandomValues = nDocs / 2;context.randomUniqueValues = new String[numRandomValues];- Set<String> trackSet = new HashSet<String>();+ Set<String> trackSet = new HashSet<>();context.randomFrom = new boolean[numRandomValues];for (int i = 0; i < numRandomValues; i++) {String uniqueRandomValue;@@ -462,7 +469,7 @@ public class TestJoinUtil extends LuceneTestCase {toField = "from";queryVals = context.toHitsToJoinScore;}- final Map<BytesRef, JoinScore> joinValueToJoinScores = new HashMap<BytesRef, JoinScore>();+ final Map<BytesRef, JoinScore> joinValueToJoinScores = new HashMap<>();if (multipleValuesPerDocument) {fromSearcher.search(new TermQuery(new Term("value", uniqueRandomValue)), new Collector() {@@ -538,7 +545,7 @@ public class TestJoinUtil extends LuceneTestCase {});}- final Map<Integer, JoinScore> docToJoinScore = new HashMap<Integer, JoinScore>();+ final Map<Integer, JoinScore> docToJoinScore = new HashMap<>();if (multipleValuesPerDocument) {if (scoreDocsInOrder) {AtomicReader slowCompositeReader = SlowCompositeReaderWrapper.wrap(toSearcher.getIndexReader());@@ -546,7 +553,7 @@ public class TestJoinUtil extends LuceneTestCase {if (terms != null) {DocsEnum docsEnum = null;TermsEnum termsEnum = null;- SortedSet<BytesRef> joinValues = new TreeSet<BytesRef>(BytesRef.getUTF8SortedAsUnicodeComparator());+ SortedSet<BytesRef> joinValues = new TreeSet<>(BytesRef.getUTF8SortedAsUnicodeComparator());joinValues.addAll(joinValueToJoinScores.keySet());for (BytesRef joinValue : joinValues) {termsEnum = terms.iterator(termsEnum);@@ -651,7 +658,7 @@ public class TestJoinUtil extends LuceneTestCase {} else {hitsToJoinScores = context.toHitsToJoinScore.get(queryValue);}- List<Map.Entry<Integer,JoinScore>> hits = new ArrayList<Map.Entry<Integer, JoinScore>>(hitsToJoinScores.entrySet());+ List<Map.Entry<Integer,JoinScore>> hits = new ArrayList<>(hitsToJoinScores.entrySet());Collections.sort(hits, new Comparator<Map.Entry<Integer, JoinScore>>() {@Override@@ -714,13 +721,13 @@ public class TestJoinUtil extends LuceneTestCase {String[] randomUniqueValues;boolean[] randomFrom;- Map<String, List<RandomDoc>> fromDocuments = new HashMap<String, List<RandomDoc>>();- Map<String, List<RandomDoc>> toDocuments = new HashMap<String, List<RandomDoc>>();- Map<String, List<RandomDoc>> randomValueFromDocs = new HashMap<String, List<RandomDoc>>();- Map<String, List<RandomDoc>> randomValueToDocs = new HashMap<String, List<RandomDoc>>();+ Map<String, List<RandomDoc>> fromDocuments = new HashMap<>();+ Map<String, List<RandomDoc>> toDocuments = new HashMap<>();+ Map<String, List<RandomDoc>> randomValueFromDocs = new HashMap<>();+ Map<String, List<RandomDoc>> randomValueToDocs = new HashMap<>();- Map<String, Map<Integer, JoinScore>> fromHitsToJoinScore = new HashMap<String, Map<Integer, JoinScore>>();- Map<String, Map<Integer, JoinScore>> toHitsToJoinScore = new HashMap<String, Map<Integer, JoinScore>>();+ Map<String, Map<Integer, JoinScore>> fromHitsToJoinScore = new HashMap<>();+ Map<String, Map<Integer, JoinScore>> toHitsToJoinScore = new HashMap<>();}@@ -734,7 +741,7 @@ public class TestJoinUtil extends LuceneTestCase {private RandomDoc(String id, int numberOfLinkValues, String value, boolean from) {this.id = id;this.from = from;- linkValues = new ArrayList<String>(numberOfLinkValues);+ linkValues = new ArrayList<>(numberOfLinkValues);this.value = value;}}