You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mv...@apache.org on 2013/04/15 14:01:16 UTC
svn commit: r1467952 - in /lucene/dev/trunk/lucene/join/src:
java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
test/org/apache/lucene/search/join/TestBlockJoin.java
test/org/apache/lucene/search/join/TestJoinUtil.java
Author: mvg
Date: Mon Apr 15 12:01:16 2013
New Revision: 1467952
URL: http://svn.apache.org/r1467952
Log:
Make use of diamond operator in join module.
Modified:
lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
Modified: lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java?rev=1467952&r1=1467951&r2=1467952&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java (original)
+++ lucene/dev/trunk/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java Mon Apr 15 12:01:16 2013
@@ -80,7 +80,7 @@ public class ToParentBlockJoinCollector
// 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
int[][] docs;
float[][] scores;
int[] counts;
- };
+ }
@Override
public void collect(int parentDoc) throws IOException {
@@ -470,7 +470,7 @@ public class ToParentBlockJoinCollector
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
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);
}
Modified: lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java?rev=1467952&r1=1467951&r2=1467952&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (original)
+++ lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java Mon Apr 15 12:01:16 2013
@@ -162,13 +162,13 @@ public class TestBlockJoin extends Lucen
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 Lucen
// 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 Lucen
}
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 Lucen
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 Lucen
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 Lucen
}
// 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 Lucen
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 Lucen
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));
Modified: lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java?rev=1467952&r1=1467951&r2=1467952&view=diff
==============================================================================
--- lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java (original)
+++ lucene/dev/trunk/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java Mon Apr 15 12:01:16 2013
@@ -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.TextFi
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.TopScore
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 Lucene
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 Lucene
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 Lucene
});
}
- 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 Lucene
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 Lucene
} 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 Lucene
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 Lucene
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;
}
}