You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by mi...@apache.org on 2014/03/16 20:39:37 UTC

svn commit: r1578144 [15/37] - in /lucene/dev/branches/lucene5376_2: ./ dev-tools/ dev-tools/idea/.idea/libraries/ dev-tools/idea/solr/contrib/dataimporthandler/ dev-tools/idea/solr/contrib/map-reduce/ dev-tools/idea/solr/core/src/test/ dev-tools/scrip...

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldPhraseList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldPhraseList.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldPhraseList.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldPhraseList.java Sun Mar 16 19:39:10 2014
@@ -34,7 +34,7 @@ public class FieldPhraseList {
   /**
    * List of non-overlapping WeightedPhraseInfo objects.
    */
-  LinkedList<WeightedPhraseInfo> phraseList = new LinkedList<WeightedPhraseInfo>();
+  LinkedList<WeightedPhraseInfo> phraseList = new LinkedList<>();
   
   /**
    * create a FieldPhraseList that has no limit on the number of phrases to analyze
@@ -65,7 +65,7 @@ public class FieldPhraseList {
   public FieldPhraseList( FieldTermStack fieldTermStack, FieldQuery fieldQuery, int phraseLimit ){
     final String field = fieldTermStack.getFieldName();
 
-    LinkedList<TermInfo> phraseCandidate = new LinkedList<TermInfo>();
+    LinkedList<TermInfo> phraseCandidate = new LinkedList<>();
     QueryPhraseMap currMap = null;
     QueryPhraseMap nextMap = null;
     while( !fieldTermStack.isEmpty() && (phraseList.size() < phraseLimit) )
@@ -125,13 +125,13 @@ public class FieldPhraseList {
     for ( FieldPhraseList fplToMerge : toMerge ) {
       allInfos[ index++ ] = fplToMerge.phraseList.iterator();
     }
-    MergedIterator< WeightedPhraseInfo > itr = new MergedIterator< WeightedPhraseInfo >( false, allInfos );
+    MergedIterator< WeightedPhraseInfo > itr = new MergedIterator<>( false, allInfos );
     // Step 2.  Walk the sorted list merging infos that overlap
-    phraseList = new LinkedList< WeightedPhraseInfo >();
+    phraseList = new LinkedList<>();
     if ( !itr.hasNext() ) {
       return;
     }
-    List< WeightedPhraseInfo > work = new ArrayList< WeightedPhraseInfo >();
+    List< WeightedPhraseInfo > work = new ArrayList<>();
     WeightedPhraseInfo first = itr.next();
     work.add( first );
     int workEndOffset = first.getEndOffset();
@@ -225,9 +225,9 @@ public class FieldPhraseList {
       this.seqnum = seqnum;
       
       // We keep TermInfos for further operations
-      termsInfos = new ArrayList<TermInfo>( terms );
+      termsInfos = new ArrayList<>( terms );
       
-      termsOffsets = new ArrayList<Toffs>( terms.size() );
+      termsOffsets = new ArrayList<>( terms.size() );
       TermInfo ti = terms.get( 0 );
       termsOffsets.add( new Toffs( ti.getStartOffset(), ti.getEndOffset() ) );
       if( terms.size() == 1 ){
@@ -261,7 +261,7 @@ public class FieldPhraseList {
       WeightedPhraseInfo first = toMergeItr.next();
       @SuppressWarnings( { "rawtypes", "unchecked" } )
       Iterator< Toffs >[] allToffs = new Iterator[ toMerge.size() ];
-      termsInfos = new ArrayList< TermInfo >();
+      termsInfos = new ArrayList<>();
       seqnum = first.seqnum;
       boost = first.boost;
       allToffs[ 0 ] = first.termsOffsets.iterator();
@@ -273,8 +273,8 @@ public class FieldPhraseList {
         allToffs[ index++ ] = info.termsOffsets.iterator();
       }
       // Step 2.  Walk the sorted list merging overlaps
-      MergedIterator< Toffs > itr = new MergedIterator< Toffs >( false, allToffs );
-      termsOffsets = new ArrayList< Toffs >();
+      MergedIterator< Toffs > itr = new MergedIterator<>( false, allToffs );
+      termsOffsets = new ArrayList<>();
       if ( !itr.hasNext() ) {
         return;
       }

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldQuery.java Sun Mar 16 19:39:10 2014
@@ -50,11 +50,11 @@ public class FieldQuery {
 
   // fieldMatch==true,  Map<fieldName,QueryPhraseMap>
   // fieldMatch==false, Map<null,QueryPhraseMap>
-  Map<String, QueryPhraseMap> rootMaps = new HashMap<String, QueryPhraseMap>();
+  Map<String, QueryPhraseMap> rootMaps = new HashMap<>();
 
   // fieldMatch==true,  Map<fieldName,setOfTermsInQueries>
   // fieldMatch==false, Map<null,setOfTermsInQueries>
-  Map<String, Set<String>> termSetMap = new HashMap<String, Set<String>>();
+  Map<String, Set<String>> termSetMap = new HashMap<>();
 
   int termOrPhraseNumber; // used for colored tag support
 
@@ -63,7 +63,7 @@ public class FieldQuery {
 
   FieldQuery( Query query, IndexReader reader, boolean phraseHighlight, boolean fieldMatch ) throws IOException {
     this.fieldMatch = fieldMatch;
-    Set<Query> flatQueries = new LinkedHashSet<Query>();
+    Set<Query> flatQueries = new LinkedHashSet<>();
     flatten( query, reader, flatQueries );
     saveTerms( flatQueries, reader );
     Collection<Query> expandQueries = expand( flatQueries );
@@ -169,7 +169,7 @@ public class FieldQuery {
    *      => expandQueries={a,"b c","c d","b c d"}
    */
   Collection<Query> expand( Collection<Query> flatQueries ){
-    Set<Query> expandQueries = new LinkedHashSet<Query>();
+    Set<Query> expandQueries = new LinkedHashSet<>();
     for( Iterator<Query> i = flatQueries.iterator(); i.hasNext(); ){
       Query query = i.next();
       i.remove();
@@ -316,7 +316,7 @@ public class FieldQuery {
     String key = getKey( query );
     Set<String> set = termSetMap.get( key );
     if( set == null ){
-      set = new HashSet<String>();
+      set = new HashSet<>();
       termSetMap.put( key, set );
     }
     return set;
@@ -364,7 +364,7 @@ public class FieldQuery {
     float boost;  // valid if terminal == true
     int termOrPhraseNumber;   // valid if terminal == true
     FieldQuery fieldQuery;
-    Map<String, QueryPhraseMap> subMap = new HashMap<String, QueryPhraseMap>();
+    Map<String, QueryPhraseMap> subMap = new HashMap<>();
     
     public QueryPhraseMap( FieldQuery fieldQuery ){
       this.fieldQuery = fieldQuery;

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/FieldTermStack.java Sun Mar 16 19:39:10 2014
@@ -38,7 +38,7 @@ import org.apache.lucene.util.UnicodeUti
 public class FieldTermStack {
   
   private final String fieldName;
-  LinkedList<TermInfo> termList = new LinkedList<TermInfo>();
+  LinkedList<TermInfo> termList = new LinkedList<>();
   
   //public static void main( String[] args ) throws Exception {
   //  Analyzer analyzer = new WhitespaceAnalyzer(Version.LUCENE_CURRENT);

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleBoundaryScanner.java Sun Mar 16 19:39:10 2014
@@ -47,7 +47,7 @@ public class SimpleBoundaryScanner imple
   
   public SimpleBoundaryScanner( int maxScan, Character[] boundaryChars ){
     this.maxScan = maxScan;
-    this.boundaryChars = new HashSet<Character>();
+    this.boundaryChars = new HashSet<>();
     this.boundaryChars.addAll(Arrays.asList(boundaryChars));
   }
   

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleFieldFragList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleFieldFragList.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleFieldFragList.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SimpleFieldFragList.java Sun Mar 16 19:39:10 2014
@@ -43,7 +43,7 @@ public class SimpleFieldFragList extends
   @Override
   public void add( int startOffset, int endOffset, List<WeightedPhraseInfo> phraseInfoList ) {
     float totalBoost = 0;
-    List<SubInfo> subInfos = new ArrayList<SubInfo>();
+    List<SubInfo> subInfos = new ArrayList<>();
     for( WeightedPhraseInfo phraseInfo : phraseInfoList ){
       subInfos.add( new SubInfo( phraseInfo.getText(), phraseInfo.getTermsOffsets(), phraseInfo.getSeqnum(), phraseInfo.getBoost() ) );
       totalBoost += phraseInfo.getBoost();

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SingleFragListBuilder.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SingleFragListBuilder.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SingleFragListBuilder.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/SingleFragListBuilder.java Sun Mar 16 19:39:10 2014
@@ -41,7 +41,7 @@ public class SingleFragListBuilder imple
 
     FieldFragList ffl = new SimpleFieldFragList( fragCharSize );
 
-    List<WeightedPhraseInfo> wpil = new ArrayList<WeightedPhraseInfo>();
+    List<WeightedPhraseInfo> wpil = new ArrayList<>();
     Iterator<WeightedPhraseInfo> ite = fieldPhraseList.phraseList.iterator();
     WeightedPhraseInfo phraseInfo = null;
     while( true ){

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/WeightedFieldFragList.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/WeightedFieldFragList.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/WeightedFieldFragList.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/java/org/apache/lucene/search/vectorhighlight/WeightedFieldFragList.java Sun Mar 16 19:39:10 2014
@@ -44,9 +44,9 @@ public class WeightedFieldFragList exten
    */ 
   @Override
   public void add( int startOffset, int endOffset, List<WeightedPhraseInfo> phraseInfoList ) {
-    List<SubInfo> tempSubInfos = new ArrayList<SubInfo>();
-    List<SubInfo> realSubInfos = new ArrayList<SubInfo>();
-    HashSet<String> distinctTerms = new HashSet<String>();   
+    List<SubInfo> tempSubInfos = new ArrayList<>();
+    List<SubInfo> realSubInfos = new ArrayList<>();
+    HashSet<String> distinctTerms = new HashSet<>();
     int length = 0;
 
     for( WeightedPhraseInfo phraseInfo : phraseInfoList ){

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/highlight/HighlighterTest.java Sun Mar 16 19:39:10 2014
@@ -419,7 +419,7 @@ public class HighlighterTest extends Bas
   }
   
   public void testSpanRegexQuery() throws Exception {
-    query = new SpanOrQuery(new SpanMultiTermQueryWrapper<RegexpQuery>(new RegexpQuery(new Term(FIELD_NAME, "ken.*"))));
+    query = new SpanOrQuery(new SpanMultiTermQueryWrapper<>(new RegexpQuery(new Term(FIELD_NAME, "ken.*"))));
     searcher = newSearcher(reader);
     hits = searcher.search(query, 100);
     int maxNumFragmentsRequired = 2;
@@ -1173,12 +1173,12 @@ public class HighlighterTest extends Bas
         WeightedSpanTerm[] wTerms = new WeightedSpanTerm[2];
         wTerms[0] = new WeightedSpanTerm(10f, "hello");
 
-        List<PositionSpan> positionSpans = new ArrayList<PositionSpan>();
+        List<PositionSpan> positionSpans = new ArrayList<>();
         positionSpans.add(new PositionSpan(0, 0));
         wTerms[0].addPositionSpans(positionSpans);
 
         wTerms[1] = new WeightedSpanTerm(1f, "kennedy");
-        positionSpans = new ArrayList<PositionSpan>();
+        positionSpans = new ArrayList<>();
         positionSpans.add(new PositionSpan(14, 14));
         wTerms[1].addPositionSpans(positionSpans);
 
@@ -1216,7 +1216,7 @@ public class HighlighterTest extends Bas
 
       @Override
       public void run() throws Exception {
-        HashMap<String,String> synonyms = new HashMap<String,String>();
+        HashMap<String,String> synonyms = new HashMap<>();
         synonyms.put("football", "soccer,footie");
         Analyzer analyzer = new SynonymAnalyzer(synonyms);
 
@@ -1578,7 +1578,7 @@ public class HighlighterTest extends Bas
       private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
       {
-        lst = new ArrayList<Token>();
+        lst = new ArrayList<>();
         Token t;
         t = createToken("hi", 0, 2);
         t.setPositionIncrement(1);
@@ -1629,7 +1629,7 @@ public class HighlighterTest extends Bas
       private final PositionIncrementAttribute posIncrAtt = addAttribute(PositionIncrementAttribute.class);
       private final OffsetAttribute offsetAtt = addAttribute(OffsetAttribute.class);
       {
-        lst = new ArrayList<Token>();
+        lst = new ArrayList<>();
         Token t;
         t = createToken("hispeed", 0, 8);
         t.setPositionIncrement(1);

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestMultiTermHighlighting.java Sun Mar 16 19:39:10 2014
@@ -525,7 +525,7 @@ public class TestMultiTermHighlighting e
         return analyzer;
       }
     };
-    Query query = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
+    Query query = new SpanMultiTermQueryWrapper<>(new WildcardQuery(new Term("body", "te*")));
     TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
     assertEquals(2, topDocs.totalHits);
     String snippets[] = highlighter.highlight("body", query, searcher, topDocs);
@@ -566,7 +566,7 @@ public class TestMultiTermHighlighting e
         return analyzer;
       }
     };
-    SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
+    SpanQuery childQuery = new SpanMultiTermQueryWrapper<>(new WildcardQuery(new Term("body", "te*")));
     Query query = new SpanOrQuery(new SpanQuery[] { childQuery });
     TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
     assertEquals(2, topDocs.totalHits);
@@ -608,7 +608,7 @@ public class TestMultiTermHighlighting e
         return analyzer;
       }
     };
-    SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
+    SpanQuery childQuery = new SpanMultiTermQueryWrapper<>(new WildcardQuery(new Term("body", "te*")));
     Query query = new SpanNearQuery(new SpanQuery[] { childQuery }, 0, true);
     TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
     assertEquals(2, topDocs.totalHits);
@@ -650,7 +650,7 @@ public class TestMultiTermHighlighting e
         return analyzer;
       }
     };
-    SpanQuery include = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
+    SpanQuery include = new SpanMultiTermQueryWrapper<>(new WildcardQuery(new Term("body", "te*")));
     SpanQuery exclude = new SpanTermQuery(new Term("body", "bogus"));
     Query query = new SpanNotQuery(include, exclude);
     TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
@@ -693,7 +693,7 @@ public class TestMultiTermHighlighting e
         return analyzer;
       }
     };
-    SpanQuery childQuery = new SpanMultiTermQueryWrapper<WildcardQuery>(new WildcardQuery(new Term("body", "te*")));
+    SpanQuery childQuery = new SpanMultiTermQueryWrapper<>(new WildcardQuery(new Term("body", "te*")));
     Query query = new SpanFirstQuery(childQuery, 1000000);
     TopDocs topDocs = searcher.search(query, null, 10, Sort.INDEXORDER);
     assertEquals(2, topDocs.totalHits);

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/postingshighlight/TestPostingsHighlighterRanking.java Sun Mar 16 19:39:10 2014
@@ -163,7 +163,7 @@ public class TestPostingsHighlighterRank
    * instead it just collects them for asserts!
    */
   static class FakePassageFormatter extends PassageFormatter {
-    HashSet<Pair> seen = new HashSet<Pair>();
+    HashSet<Pair> seen = new HashSet<>();
     
     @Override
     public String format(Passage passages[], String content) {

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/AbstractTestCase.java Sun Mar 16 19:39:10 2014
@@ -168,7 +168,7 @@ public abstract class AbstractTestCase e
   }
 
   protected List<BytesRef> analyze(String text, String field, Analyzer analyzer) throws IOException {
-    List<BytesRef> bytesRefs = new ArrayList<BytesRef>();
+    List<BytesRef> bytesRefs = new ArrayList<>();
 
     try (TokenStream tokenStream = analyzer.tokenStream(field, text)) {
       TermToBytesRefAttribute termAttribute = tokenStream.getAttribute(TermToBytesRefAttribute.class);

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FastVectorHighlighterTest.java Sun Mar 16 19:39:10 2014
@@ -533,7 +533,7 @@ public class FastVectorHighlighterTest e
           token( "red", 0, 0, 3 )
         ), matched ) );
 
-    final Map<String, Analyzer> fieldAnalyzers = new TreeMap<String, Analyzer>();
+    final Map<String, Analyzer> fieldAnalyzers = new TreeMap<>();
     fieldAnalyzers.put( "field", new MockAnalyzer( random(), MockTokenizer.WHITESPACE, true, MockTokenFilter.ENGLISH_STOPSET ) );
     fieldAnalyzers.put( "field_exact", new MockAnalyzer( random() ) );
     fieldAnalyzers.put( "field_super_exact", new MockAnalyzer( random(), MockTokenizer.WHITESPACE, false ) );
@@ -566,7 +566,7 @@ public class FastVectorHighlighterTest e
     FieldQuery fieldQuery = new FieldQuery( query, reader, true, fieldMatch );
     String[] bestFragments;
     if ( useMatchedFields ) {
-      Set< String > matchedFields = new HashSet< String >();
+      Set< String > matchedFields = new HashSet<>();
       matchedFields.add( "field" );
       matchedFields.add( "field_exact" );
       matchedFields.add( "field_super_exact" );

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldPhraseListTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldPhraseListTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldPhraseListTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldPhraseListTest.java Sun Mar 16 19:39:10 2014
@@ -269,7 +269,7 @@ public class FieldPhraseListTest extends
   }
 
   private WeightedPhraseInfo newInfo( int startOffset, int endOffset, float boost ) {
-    LinkedList< TermInfo > infos = new LinkedList< TermInfo >();
+    LinkedList< TermInfo > infos = new LinkedList<>();
     infos.add( new TermInfo( TestUtil.randomUnicodeString(random()), startOffset, endOffset, 0, 0 ) );
     return new WeightedPhraseInfo( infos, boost );
   }

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/FieldQueryTest.java Sun Mar 16 19:39:10 2014
@@ -67,7 +67,7 @@ public class FieldQueryTest extends Abst
     booleanQuery.add(innerQuery, Occur.MUST_NOT);
 
     FieldQuery fq = new FieldQuery(booleanQuery, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten(booleanQuery, reader, flatQueries);
     assertCollectionQueries( flatQueries, tq( boost, "A" ), tq( boost, "B" ), tq( boost, "C" ) );
   }
@@ -77,7 +77,7 @@ public class FieldQueryTest extends Abst
     Query query = dmq( tq( "A" ), tq( "B" ), pqF( "C", "D" ) );
     query.setBoost( boost );
     FieldQuery fq = new FieldQuery( query, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten( query, reader, flatQueries );
     assertCollectionQueries( flatQueries, tq( boost, "A" ), tq( boost, "B" ), pqF( boost, "C", "D" ) );
   }
@@ -90,7 +90,7 @@ public class FieldQueryTest extends Abst
     booleanQuery.add(pqF("B", "C"), Occur.MUST);
 
     FieldQuery fq = new FieldQuery(booleanQuery, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten(booleanQuery, reader, flatQueries);
     assertCollectionQueries( flatQueries, tq( boost, "A" ), pqF( boost, "B", "C" ) );
   }
@@ -102,7 +102,7 @@ public class FieldQueryTest extends Abst
     query.add(toPhraseQuery(analyze("EFGH", F, analyzerB), F), Occur.SHOULD);
 
     FieldQuery fq = new FieldQuery( query, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten( query, reader, flatQueries );
     assertCollectionQueries( flatQueries, tq( "AA" ), pqF( "BC", "CD" ), pqF( "EF", "FG", "GH" ) );
   }
@@ -110,7 +110,7 @@ public class FieldQueryTest extends Abst
   public void testFlatten1TermPhrase() throws Exception {
     Query query = pqF( "A" );
     FieldQuery fq = new FieldQuery( query, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten( query, reader, flatQueries );
     assertCollectionQueries( flatQueries, tq( "A" ) );
   }
@@ -120,56 +120,56 @@ public class FieldQueryTest extends Abst
     FieldQuery fq = new FieldQuery( dummy, true, true );
 
     // "a b","b c" => "a b","b c","a b c"
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), pqF( "b", "c" ), pqF( "a", "b", "c" ) );
 
     // "a b","b c d" => "a b","b c d","a b c d"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "b", "c", "d" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), pqF( "b", "c", "d" ), pqF( "a", "b", "c", "d" ) );
 
     // "a b c","b c d" => "a b c","b c d","a b c d"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "c" ) );
     flatQueries.add( pqF( "b", "c", "d" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b", "c" ), pqF( "b", "c", "d" ), pqF( "a", "b", "c", "d" ) );
 
     // "a b c","c d e" => "a b c","c d e","a b c d e"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "c" ) );
     flatQueries.add( pqF( "c", "d", "e" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b", "c" ), pqF( "c", "d", "e" ), pqF( "a", "b", "c", "d", "e" ) );
 
     // "a b c d","b c" => "a b c d","b c"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "c", "d" ) );
     flatQueries.add( pqF( "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b", "c", "d" ), pqF( "b", "c" ) );
 
     // "a b b","b c" => "a b b","b c","a b b c"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "b" ) );
     flatQueries.add( pqF( "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b", "b" ), pqF( "b", "c" ), pqF( "a", "b", "b", "c" ) );
 
     // "a b","b a" => "a b","b a","a b a", "b a b"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "b", "a" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), pqF( "b", "a" ), pqF( "a", "b", "a" ), pqF( "b", "a", "b" ) );
 
     // "a b","a b c" => "a b","a b c"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "a", "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
@@ -181,42 +181,42 @@ public class FieldQueryTest extends Abst
     FieldQuery fq = new FieldQuery( dummy, true, true );
 
     // "a b","c d" => "a b","c d"
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "c", "d" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), pqF( "c", "d" ) );
 
     // "a","a b" => "a", "a b"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( tq( "a" ) );
     flatQueries.add( pqF( "a", "b" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         tq( "a" ), pqF( "a", "b" ) );
 
     // "a b","b" => "a b", "b"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( tq( "b" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), tq( "b" ) );
 
     // "a b c","b c" => "a b c","b c"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "c" ) );
     flatQueries.add( pqF( "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b", "c" ), pqF( "b", "c" ) );
 
     // "a b","a b c" => "a b","a b c"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b" ) );
     flatQueries.add( pqF( "a", "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
         pqF( "a", "b" ), pqF( "a", "b", "c" ) );
 
     // "a b c","b d e" => "a b c","b d e"
-    flatQueries = new HashSet<Query>();
+    flatQueries = new HashSet<>();
     flatQueries.add( pqF( "a", "b", "c" ) );
     flatQueries.add( pqF( "b", "d", "e" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
@@ -228,7 +228,7 @@ public class FieldQueryTest extends Abst
     FieldQuery fq = new FieldQuery( dummy, true, false );
 
     // f1:"a b",f2:"b c" => f1:"a b",f2:"b c",f1:"a b c"
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     flatQueries.add( pq( F1, "a", "b" ) );
     flatQueries.add( pq( F2, "b", "c" ) );
     assertCollectionQueries( fq.expand( flatQueries ),
@@ -826,7 +826,7 @@ public class FieldQueryTest extends Abst
     FieldQuery fq = new FieldQuery( query, true, true );
     
     // "a"
-    List<TermInfo> phraseCandidate = new ArrayList<TermInfo>();
+    List<TermInfo> phraseCandidate = new ArrayList<>();
     phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
     assertNull( fq.searchPhrase( F, phraseCandidate ) );
     // "a b"
@@ -868,7 +868,7 @@ public class FieldQueryTest extends Abst
     FieldQuery fq = new FieldQuery( query, true, true );
     
     // "a b c" w/ position-gap = 2
-    List<TermInfo> phraseCandidate = new ArrayList<TermInfo>();
+    List<TermInfo> phraseCandidate = new ArrayList<>();
     phraseCandidate.add( new TermInfo( "a", 0, 1, 0, 1 ) );
     phraseCandidate.add( new TermInfo( "b", 2, 3, 2, 1 ) );
     phraseCandidate.add( new TermInfo( "c", 4, 5, 4, 1 ) );
@@ -917,7 +917,7 @@ public class FieldQueryTest extends Abst
     QueryPhraseMap qpm = fq.getFieldTermMap(F, "defg");
     assertNotNull (qpm);
     assertNull (fq.getFieldTermMap(F, "dog"));
-    List<TermInfo> phraseCandidate = new ArrayList<TermInfo>();
+    List<TermInfo> phraseCandidate = new ArrayList<>();
     phraseCandidate.add( new TermInfo( "defg", 0, 12, 0, 1 ) );
     assertNotNull (fq.searchPhrase(F, phraseCandidate));
   }
@@ -947,7 +947,7 @@ public class FieldQueryTest extends Abst
     });
     query.setBoost(boost);
     FieldQuery fq = new FieldQuery( query, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten( query, reader, flatQueries );
     assertCollectionQueries( flatQueries, tq( boost, "A" ) );
   }
@@ -957,7 +957,7 @@ public class FieldQueryTest extends Abst
     Query query = new ConstantScoreQuery(pqF( "A" ));
     query.setBoost(boost);
     FieldQuery fq = new FieldQuery( query, true, true );
-    Set<Query> flatQueries = new HashSet<Query>();
+    Set<Query> flatQueries = new HashSet<>();
     fq.flatten( query, reader, flatQueries );
     assertCollectionQueries( flatQueries, tq( boost, "A" ) );
   }

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/IndexTimeSynonymTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/IndexTimeSynonymTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/IndexTimeSynonymTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/IndexTimeSynonymTest.java Sun Mar 16 19:39:10 2014
@@ -48,7 +48,7 @@ public class IndexTimeSynonymTest extend
     FieldQuery fq = new FieldQuery( bq, true, true );
     FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
     assertEquals( 2, stack.termList.size() );
-    Set<String> expectedSet = new HashSet<String>();
+    Set<String> expectedSet = new HashSet<>();
     expectedSet.add( "Mac(11,20,3)" );
     expectedSet.add( "MacBook(11,20,3)" );
     assertTrue( expectedSet.contains( stack.pop().toString() ) );
@@ -92,7 +92,7 @@ public class IndexTimeSynonymTest extend
     FieldQuery fq = new FieldQuery( bq, true, true );
     FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
     assertEquals( 3, stack.termList.size() );
-    Set<String> expectedSet = new HashSet<String>();
+    Set<String> expectedSet = new HashSet<>();
     expectedSet.add( "pc(3,5,1)" );
     expectedSet.add( "personal(3,5,1)" );
     assertTrue( expectedSet.contains( stack.pop().toString() ) );
@@ -137,7 +137,7 @@ public class IndexTimeSynonymTest extend
     FieldQuery fq = new FieldQuery( bq, true, true );
     FieldTermStack stack = new FieldTermStack( reader, 0, F, fq );
     assertEquals( 3, stack.termList.size() );
-    Set<String> expectedSet = new HashSet<String>();
+    Set<String> expectedSet = new HashSet<>();
     expectedSet.add( "pc(3,20,1)" );
     expectedSet.add( "personal(3,20,1)" );
     assertTrue( expectedSet.contains( stack.pop().toString() ) );

Modified: lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/highlighter/src/test/org/apache/lucene/search/vectorhighlight/SimpleFragmentsBuilderTest.java Sun Mar 16 19:39:10 2014
@@ -248,9 +248,9 @@ public class SimpleFragmentsBuilderTest 
     int numDocs = randomValues.length * 5;
     int numFields = 2 + random().nextInt(5);
     int numTerms = 2 + random().nextInt(3);
-    List<Doc> docs = new ArrayList<Doc>(numDocs);
-    List<Document> documents = new ArrayList<Document>(numDocs);
-    Map<String, Set<Integer>> valueToDocId = new HashMap<String, Set<Integer>>();
+    List<Doc> docs = new ArrayList<>(numDocs);
+    List<Document> documents = new ArrayList<>(numDocs);
+    Map<String, Set<Integer>> valueToDocId = new HashMap<>();
     for (int i = 0; i < numDocs; i++) {
       Document document = new Document();
       String[][] fields = new String[numFields][numTerms];
@@ -277,7 +277,7 @@ public class SimpleFragmentsBuilderTest 
       for (int highlightIter = 0; highlightIter < highlightIters; highlightIter++) {
         String queryTerm = randomValues[random().nextInt(randomValues.length)];
         int randomHit = valueToDocId.get(queryTerm).iterator().next();
-        List<StringBuilder> builders = new ArrayList<StringBuilder>();
+        List<StringBuilder> builders = new ArrayList<>();
         for (String[] fieldValues : docs.get(randomHit).fieldValues) {
           StringBuilder builder = new StringBuilder();
           boolean hit = false;

Modified: lucene/dev/branches/lucene5376_2/lucene/ivy-settings.xml
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/ivy-settings.xml?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/ivy-settings.xml (original)
+++ lucene/dev/branches/lucene5376_2/lucene/ivy-settings.xml Sun Mar 16 19:39:10 2014
@@ -33,8 +33,8 @@
   <resolvers>
     <ibiblio name="sonatype-releases" root="http://oss.sonatype.org/content/repositories/releases" m2compatible="true" />
     <ibiblio name="maven.restlet.org" root="http://maven.restlet.org" m2compatible="true" />
-    <ibiblio name="cloudera" root="https://repository.cloudera.com/artifactory/repo" m2compatible="true" />
-    <ibiblio name="releases.cloudera.com" root="https://repository.cloudera.com/content/repositories/releases" m2compatible="true" />
+    <ibiblio name="cloudera" root="http://repository.cloudera.com/artifactory/repo" m2compatible="true" />
+    <ibiblio name="releases.cloudera.com" root="http://repository.cloudera.com/content/repositories/releases" m2compatible="true" />
     
     <!-- needed only for newer svnkit releases, e.g. 1.8.x -->
     <ibiblio name="svnkit-releases" root="http://maven.tmatesoft.com/content/repositories/releases" m2compatible="true" />

Modified: lucene/dev/branches/lucene5376_2/lucene/ivy-versions.properties
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/ivy-versions.properties?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/ivy-versions.properties (original)
+++ lucene/dev/branches/lucene5376_2/lucene/ivy-versions.properties Sun Mar 16 19:39:10 2014
@@ -8,7 +8,7 @@
 /cglib/cglib-nodep = 2.2
 /com.adobe.xmp/xmpcore = 5.1.2
 
-com.carrotsearch.randomizedtesting.version = 2.0.13
+com.carrotsearch.randomizedtesting.version = 2.1.1
 /com.carrotsearch.randomizedtesting/junit4-ant = ${com.carrotsearch.randomizedtesting.version}
 /com.carrotsearch.randomizedtesting/randomizedtesting-runner = ${com.carrotsearch.randomizedtesting.version}
 

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/TermsIncludingScoreQuery.java Sun Mar 16 19:39:10 2014
@@ -17,6 +17,10 @@ package org.apache.lucene.search.join;
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Locale;
+import java.util.Set;
+
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.DocsEnum;
 import org.apache.lucene.index.IndexReader;
@@ -30,16 +34,13 @@ import org.apache.lucene.search.Explanat
 import org.apache.lucene.search.IndexSearcher;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.BulkScorer;
 import org.apache.lucene.search.Weight;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefHash;
 import org.apache.lucene.util.FixedBitSet;
 
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Set;
-
 class TermsIncludingScoreQuery extends Query {
 
   final String field;
@@ -131,16 +132,21 @@ class TermsIncludingScoreQuery extends Q
 
       @Override
       public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
-        SVInnerScorer scorer = (SVInnerScorer) scorer(context, false, false, context.reader().getLiveDocs());
+        SVInnerScorer scorer = (SVInnerScorer) bulkScorer(context, false, null);
         if (scorer != null) {
-          if (scorer.advanceForExplainOnly(doc) == doc) {
-            return scorer.explain();
-          }
+          return scorer.explain(doc);
         }
         return new ComplexExplanation(false, 0.0f, "Not a match");
       }
 
       @Override
+      public boolean scoresDocsOutOfOrder() {
+        // We have optimized impls below if we are allowed
+        // to score out-of-order:
+        return true;
+      }
+
+      @Override
       public Query getQuery() {
         return TermsIncludingScoreQuery.this;
       }
@@ -156,7 +162,7 @@ class TermsIncludingScoreQuery extends Q
       }
 
       @Override
-      public Scorer scorer(AtomicReaderContext context, boolean scoreDocsInOrder, boolean topScorer, Bits acceptDocs) throws IOException {
+      public Scorer scorer(AtomicReaderContext context, Bits acceptDocs) throws IOException {
         Terms terms = context.reader().terms(field);
         if (terms == null) {
           return null;
@@ -166,23 +172,41 @@ class TermsIncludingScoreQuery extends Q
         final long cost = context.reader().maxDoc() * terms.size();
 
         segmentTermsEnum = terms.iterator(segmentTermsEnum);
+        if (multipleValuesPerDocument) {
+          return new MVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+        } else {
+          return new SVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+        }
+      }
+
+      @Override
+      public BulkScorer bulkScorer(AtomicReaderContext context, boolean scoreDocsInOrder, Bits acceptDocs) throws IOException {
+
         if (scoreDocsInOrder) {
+          return super.bulkScorer(context, scoreDocsInOrder, acceptDocs);
+        } else {
+          Terms terms = context.reader().terms(field);
+          if (terms == null) {
+            return null;
+          }
+          // what is the runtime...seems ok?
+          final long cost = context.reader().maxDoc() * terms.size();
+
+          segmentTermsEnum = terms.iterator(segmentTermsEnum);
+          // Optimized impls that take advantage of docs
+          // being allowed to be out of order:
           if (multipleValuesPerDocument) {
-            return new MVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+            return new MVInnerScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
           } else {
-            return new SVInOrderScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
+            return new SVInnerScorer(this, acceptDocs, segmentTermsEnum, cost);
           }
-        } else if (multipleValuesPerDocument) {
-          return new MVInnerScorer(this, acceptDocs, segmentTermsEnum, context.reader().maxDoc(), cost);
-        } else {
-          return new SVInnerScorer(this, acceptDocs, segmentTermsEnum, cost);
         }
       }
     };
   }
 
   // This impl assumes that the 'join' values are used uniquely per doc per field. Used for one to many relations.
-  class SVInnerScorer extends Scorer {
+  class SVInnerScorer extends BulkScorer {
 
     final BytesRef spare = new BytesRef();
     final Bits acceptDocs;
@@ -196,7 +220,6 @@ class TermsIncludingScoreQuery extends Q
     int doc;
 
     SVInnerScorer(Weight weight, Bits acceptDocs, TermsEnum termsEnum, long cost) {
-      super(weight);
       this.acceptDocs = acceptDocs;
       this.termsEnum = termsEnum;
       this.cost = cost;
@@ -204,25 +227,20 @@ class TermsIncludingScoreQuery extends Q
     }
 
     @Override
-    public void score(Collector collector) throws IOException {
-      collector.setScorer(this);
-      for (int doc = nextDocOutOfOrder(); doc != NO_MORE_DOCS; doc = nextDocOutOfOrder()) {
+    public boolean score(Collector collector, int max) throws IOException {
+      FakeScorer fakeScorer = new FakeScorer();
+      collector.setScorer(fakeScorer);
+      if (doc == -1) {
+        doc = nextDocOutOfOrder();
+      }
+      while(doc < max) {
+        fakeScorer.doc = doc;
+        fakeScorer.score = scores[ords[scoreUpto]];
         collector.collect(doc);
+        doc = nextDocOutOfOrder();
       }
-    }
 
-    @Override
-    public float score() throws IOException {
-      return scores[ords[scoreUpto]];
-    }
-
-    Explanation explain() throws IOException {
-      return new ComplexExplanation(true, score(), "Score based on join value " + termsEnum.term().utf8ToString());
-    }
-
-    @Override
-    public int docID() {
-      return doc;
+      return doc != DocsEnum.NO_MORE_DOCS;
     }
 
     int nextDocOutOfOrder() throws IOException {
@@ -251,17 +269,7 @@ class TermsIncludingScoreQuery extends Q
       return docsEnum.nextDoc();
     }
 
-    @Override
-    public int nextDoc() throws IOException {
-      throw new UnsupportedOperationException("nextDoc() isn't supported because doc ids are emitted out of order");
-    }
-
-    @Override
-    public int advance(int target) throws IOException {
-      throw new UnsupportedOperationException("advance() isn't supported because doc ids are emitted out of order");
-    }
-
-    private int advanceForExplainOnly(int target) throws IOException {
+    private Explanation explain(int target) throws IOException {
       int docId;
       do {
         docId = nextDocOutOfOrder();
@@ -276,17 +284,8 @@ class TermsIncludingScoreQuery extends Q
         }
         docsEnum = null; // goto the next ord.
       } while (docId != DocIdSetIterator.NO_MORE_DOCS);
-      return docId;
-    }
-
-    @Override
-    public int freq() {
-      return 1;
-    }
 
-    @Override
-    public long cost() {
-      return cost;
+      return new ComplexExplanation(true, scores[ords[scoreUpto]], "Score based on join value " + termsEnum.term().utf8ToString());
     }
   }
 

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToChildBlockJoinQuery.java Sun Mar 16 19:39:10 2014
@@ -129,11 +129,9 @@ public class ToChildBlockJoinQuery exten
     // NOTE: acceptDocs applies (and is checked) only in the
     // child document space
     @Override
-    public Scorer scorer(AtomicReaderContext readerContext, boolean scoreDocsInOrder,
-        boolean topScorer, Bits acceptDocs) throws IOException {
+    public Scorer scorer(AtomicReaderContext readerContext, Bits acceptDocs) throws IOException {
 
-      // Pass scoreDocsInOrder true, topScorer false to our sub:
-      final Scorer parentScorer = parentWeight.scorer(readerContext, true, false, null);
+      final Scorer parentScorer = parentWeight.scorer(readerContext, null);
 
       if (parentScorer == null) {
         // No matches
@@ -214,7 +212,7 @@ public class ToChildBlockJoinQuery exten
             validateParentDoc();
 
             if (parentDoc == 0) {
-              // Degenerate but allowed: parent has no children
+              // Degenerate but allowed: first parent doc has no children
               // TODO: would be nice to pull initial parent
               // into ctor so we can skip this if... but it's
               // tricky because scorer must return -1 for
@@ -229,8 +227,15 @@ public class ToChildBlockJoinQuery exten
               return childDoc;
             }
 
+            // Go to first child for this next parentDoc:
             childDoc = 1 + parentBits.prevSetBit(parentDoc-1);
 
+            if (childDoc == parentDoc) {
+              // This parent has no children; continue
+              // parent loop so we move to next parent
+              continue;
+            }
+
             if (acceptDocs != null && !acceptDocs.get(childDoc)) {
               continue nextChildDoc;
             }

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinCollector.java Sun Mar 16 19:39:10 2014
@@ -314,7 +314,7 @@ public class ToParentBlockJoinCollector 
     }
     Arrays.fill(joinScorers, null);
 
-    Queue<Scorer> queue = new LinkedList<Scorer>();
+    Queue<Scorer> queue = new LinkedList<>();
     //System.out.println("\nqueue: add top scorer=" + scorer);
     queue.add(scorer);
     while ((scorer = queue.poll()) != null) {
@@ -330,46 +330,6 @@ public class ToParentBlockJoinCollector 
     }
   }
 
-  private final static class FakeScorer extends Scorer {
-
-    float score;
-    int doc;
-
-    public FakeScorer() {
-      super((Weight) null);
-    }
-
-    @Override
-    public float score() {
-      return score;
-    }
-    
-    @Override
-    public int freq() {
-      return 1; // TODO: does anything else make sense?... duplicate of grouping's FakeScorer btw?
-    }
-
-    @Override
-    public int docID() {
-      return doc;
-    }
-
-    @Override
-    public int advance(int target) {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public int nextDoc() {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public long cost() {
-      return 1;
-    }
-  }
-
   private OneGroup[] sortedGroups;
 
   private void sortQueue() {

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/java/org/apache/lucene/search/join/ToParentBlockJoinQuery.java Sun Mar 16 19:39:10 2014
@@ -17,6 +17,12 @@ package org.apache.lucene.search.join;
  * limitations under the License.
  */
 
+import java.io.IOException;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Locale;
+import java.util.Set;
+
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
@@ -35,12 +41,6 @@ import org.apache.lucene.util.ArrayUtil;
 import org.apache.lucene.util.Bits;
 import org.apache.lucene.util.FixedBitSet;
 
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Locale;
-import java.util.Set;
-
 /**
  * This query requires that you index
  * children and parent docs as a single block, using the
@@ -158,12 +158,9 @@ public class ToParentBlockJoinQuery exte
     // NOTE: acceptDocs applies (and is checked) only in the
     // parent document space
     @Override
-    public Scorer scorer(AtomicReaderContext readerContext, boolean scoreDocsInOrder,
-        boolean topScorer, Bits acceptDocs) throws IOException {
-
-      // Pass scoreDocsInOrder true, topScorer false to our sub and the live docs:
-      final Scorer childScorer = childWeight.scorer(readerContext, true, false, readerContext.reader().getLiveDocs());
+    public Scorer scorer(AtomicReaderContext readerContext, Bits acceptDocs) throws IOException {
 
+      final Scorer childScorer = childWeight.scorer(readerContext, readerContext.reader().getLiveDocs());
       if (childScorer == null) {
         // No matches
         return null;
@@ -195,7 +192,7 @@ public class ToParentBlockJoinQuery exte
 
     @Override
     public Explanation explain(AtomicReaderContext context, int doc) throws IOException {
-      BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, true, false, context.reader().getLiveDocs());
+      BlockJoinScorer scorer = (BlockJoinScorer) scorer(context, context.reader().getLiveDocs());
       if (scorer != null && scorer.advance(doc) == doc) {
         return scorer.explain(context.docBase);
       }

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestBlockJoin.java Sun Mar 16 19:39:10 2014
@@ -69,7 +69,7 @@ public class TestBlockJoin extends Lucen
     // we don't want to merge - since we rely on certain segment setup
     final IndexWriter w = new IndexWriter(dir, config);
 
-    final List<Document> docs = new ArrayList<Document>();
+    final List<Document> docs = new ArrayList<>();
 
     docs.add(makeJob("java", 2007));
     docs.add(makeJob("python", 2010));
@@ -127,7 +127,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));
@@ -217,7 +217,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<>();
 
     for (int i=0;i<10;i++) {
       docs.clear();
@@ -1103,7 +1103,6 @@ public class TestBlockJoin extends Lucen
     parentDoc = s.doc(qGroup.groupValue);
     assertEquals("Lisa", parentDoc.get("name"));
 
-
     r.close();
     dir.close();
   }
@@ -1126,7 +1125,7 @@ public class TestBlockJoin extends Lucen
 
     ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentFilter, ScoreMode.Avg);
     Weight weight = s.createNormalizedWeight(q);
-    DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), true, true, null);
+    DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), null);
     assertEquals(1, disi.advance(1));
     r.close();
     dir.close();
@@ -1160,7 +1159,7 @@ public class TestBlockJoin extends Lucen
 
     ToParentBlockJoinQuery q = new ToParentBlockJoinQuery(tq, parentFilter, ScoreMode.Avg);
     Weight weight = s.createNormalizedWeight(q);
-    DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), true, true, null);
+    DocIdSetIterator disi = weight.scorer(s.getIndexReader().leaves().get(0), null);
     assertEquals(2, disi.advance(0));
     r.close();
     dir.close();
@@ -1200,7 +1199,6 @@ public class TestBlockJoin extends Lucen
     ToParentBlockJoinQuery childJoinQuery = new ToParentBlockJoinQuery(childQuery, parentsFilter, ScoreMode.Avg);
 
     ToParentBlockJoinCollector c = new ToParentBlockJoinCollector(Sort.RELEVANCE, 2, true, true);
-
     s.search(childJoinQuery, c);
 
     //Get all child documents within groups
@@ -1266,7 +1264,7 @@ public class TestBlockJoin extends Lucen
     parent.add(newTextField("parentText", "text", Field.Store.NO));
     parent.add(newStringField("isParent", "yes", Field.Store.NO));
 
-    List<Document> docs = new ArrayList<Document>();
+    List<Document> docs = new ArrayList<>();
 
     Document child = new Document();
     docs.add(child);
@@ -1312,7 +1310,6 @@ public class TestBlockJoin extends Lucen
     GroupDocs<Integer> group = groups.groups[0];
     StoredDocument doc = r.document(group.groupValue.intValue());
     assertEquals("0", doc.get("parentID"));
-    System.out.println("group: " + group);
 
     group = groups.groups[1];
     doc = r.document(group.groupValue.intValue());
@@ -1331,7 +1328,7 @@ public class TestBlockJoin extends Lucen
     parent.add(newTextField("parentText", "text", Field.Store.NO));
     parent.add(newStringField("isParent", "yes", Field.Store.NO));
 
-    List<Document> docs = new ArrayList<Document>();
+    List<Document> docs = new ArrayList<>();
 
     Document child = new Document();
     docs.add(child);
@@ -1378,7 +1375,6 @@ public class TestBlockJoin extends Lucen
     GroupDocs<Integer> group = groups.groups[0];
     StoredDocument doc = r.document(group.groupValue.intValue());
     assertEquals("0", doc.get("parentID"));
-    System.out.println("group: " + group);
 
     group = groups.groups[1];
     doc = r.document(group.groupValue.intValue());
@@ -1397,7 +1393,7 @@ public class TestBlockJoin extends Lucen
     parent.add(newTextField("parentText", "text", Field.Store.NO));
     parent.add(newStringField("isParent", "yes", Field.Store.NO));
 
-    List<Document> docs = new ArrayList<Document>();
+    List<Document> docs = new ArrayList<>();
 
     Document child = new Document();
     docs.add(child);
@@ -1443,4 +1439,48 @@ public class TestBlockJoin extends Lucen
     r.close();
     d.close();
   }
+
+  public void testAdvanceSingleDeletedParentNoChild() throws Exception {
+
+    final Directory dir = newDirectory();
+    final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
+
+    // First doc with 1 children
+    Document parentDoc = new Document();
+    parentDoc.add(newStringField("parent", "1", Field.Store.NO));
+    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
+    Document childDoc = new Document();
+    childDoc.add(newStringField("child", "1", Field.Store.NO));
+    w.addDocuments(Arrays.asList(childDoc, parentDoc));
+
+    parentDoc = new Document();
+    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
+    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
+    w.addDocuments(Arrays.asList(parentDoc));
+
+    w.deleteDocuments(new Term("parent", "2"));
+
+    parentDoc = new Document();
+    parentDoc.add(newStringField("parent", "2", Field.Store.NO));
+    parentDoc.add(newStringField("isparent", "yes", Field.Store.NO));
+    childDoc = new Document();
+    childDoc.add(newStringField("child", "2", Field.Store.NO));
+    w.addDocuments(Arrays.asList(childDoc, parentDoc));
+
+    IndexReader r = w.getReader();
+    w.close();
+    IndexSearcher s = newSearcher(r);
+
+    // Create a filter that defines "parent" documents in the index - in this case resumes
+    Filter parentsFilter = new FixedBitSetCachingWrapperFilter(new QueryWrapperFilter(new TermQuery(new Term("isparent", "yes"))));
+
+    Query parentQuery = new TermQuery(new Term("parent", "2"));
+
+    ToChildBlockJoinQuery parentJoinQuery = new ToChildBlockJoinQuery(parentQuery, parentsFilter, random().nextBoolean());
+    TopDocs topdocs = s.search(parentJoinQuery, 3);
+    assertEquals(1, topdocs.totalHits);
+    
+    r.close();
+    dir.close();
+  }
 }

Modified: lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/join/src/test/org/apache/lucene/search/join/TestJoinUtil.java Sun Mar 16 19:39:10 2014
@@ -17,6 +17,19 @@ package org.apache.lucene.search.join;
  * limitations under the License.
  */
 
+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;
+
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenizer;
 import org.apache.lucene.document.Document;
@@ -34,6 +47,8 @@ import org.apache.lucene.index.SortedSet
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
+import org.apache.lucene.search.BooleanClause;
+import org.apache.lucene.search.BooleanQuery;
 import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Explanation;
@@ -54,19 +69,6 @@ import org.apache.lucene.util.LuceneTest
 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 {
@@ -151,6 +153,104 @@ public class TestJoinUtil extends Lucene
     dir.close();
   }
 
+  /** LUCENE-5487: verify a join query inside a SHOULD BQ
+   *  will still use the join query's optimized BulkScorers */
+  public void testInsideBooleanQuery() throws Exception {
+    final String idField = "id";
+    final String toField = "productId";
+
+    Directory dir = newDirectory();
+    RandomIndexWriter w = new RandomIndexWriter(
+        random(),
+        dir,
+        newIndexWriterConfig(TEST_VERSION_CURRENT,
+            new MockAnalyzer(random())).setMergePolicy(newLogMergePolicy()));
+
+    // 0
+    Document doc = new Document();
+    doc.add(new TextField("description", "random text", Field.Store.NO));
+    doc.add(new TextField("name", "name1", Field.Store.NO));
+    doc.add(new TextField(idField, "7", Field.Store.NO));
+    w.addDocument(doc);
+
+    // 1
+    doc = new Document();
+    doc.add(new TextField("price", "10.0", Field.Store.NO));
+    doc.add(new TextField(idField, "2", Field.Store.NO));
+    doc.add(new TextField(toField, "7", Field.Store.NO));
+    w.addDocument(doc);
+
+    // 2
+    doc = new Document();
+    doc.add(new TextField("price", "20.0", Field.Store.NO));
+    doc.add(new TextField(idField, "3", Field.Store.NO));
+    doc.add(new TextField(toField, "7", Field.Store.NO));
+    w.addDocument(doc);
+
+    // 3
+    doc = new Document();
+    doc.add(new TextField("description", "more random text", Field.Store.NO));
+    doc.add(new TextField("name", "name2", Field.Store.NO));
+    doc.add(new TextField(idField, "0", Field.Store.NO));
+    w.addDocument(doc);
+    w.commit();
+
+    // 4
+    doc = new Document();
+    doc.add(new TextField("price", "10.0", Field.Store.NO));
+    doc.add(new TextField(idField, "5", Field.Store.NO));
+    doc.add(new TextField(toField, "0", Field.Store.NO));
+    w.addDocument(doc);
+
+    // 5
+    doc = new Document();
+    doc.add(new TextField("price", "20.0", Field.Store.NO));
+    doc.add(new TextField(idField, "6", Field.Store.NO));
+    doc.add(new TextField(toField, "0", Field.Store.NO));
+    w.addDocument(doc);
+
+    w.forceMerge(1);
+
+    IndexSearcher indexSearcher = new IndexSearcher(w.getReader());
+    w.close();
+
+    // Search for product
+    Query joinQuery =
+        JoinUtil.createJoinQuery(idField, false, toField, new TermQuery(new Term("description", "random")), indexSearcher, ScoreMode.Avg);
+
+    BooleanQuery bq = new BooleanQuery();
+    bq.add(joinQuery, BooleanClause.Occur.SHOULD);
+    bq.add(new TermQuery(new Term("id", "3")), BooleanClause.Occur.SHOULD);
+
+    indexSearcher.search(bq, new Collector() {
+        boolean sawFive;
+        @Override
+        public void setNextReader(AtomicReaderContext context) {
+        }
+        @Override
+        public void collect(int docID) {
+          // Hairy / evil (depends on how BooleanScorer
+          // stores temporarily collected docIDs by
+          // appending to head of linked list):
+          if (docID == 5) {
+            sawFive = true;
+          } else if (docID == 1) {
+            assertFalse("optimized bulkScorer was not used for join query embedded in boolean query!", sawFive);
+          }
+        }
+        @Override
+        public void setScorer(Scorer scorer) {
+        }
+        @Override
+        public boolean acceptsDocsOutOfOrder() {
+          return true;
+        }
+      });
+
+    indexSearcher.getIndexReader().close();
+    dir.close();
+  }
+
   public void testSimpleWithScoring() throws Exception {
     final String idField = "id";
     final String toField = "movieId";

Modified: lucene/dev/branches/lucene5376_2/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/memory/src/java/org/apache/lucene/index/memory/MemoryIndex.java Sun Mar 16 19:39:10 2014
@@ -195,7 +195,7 @@ import org.apache.lucene.util.RecyclingI
 public class MemoryIndex {
 
   /** info for each field: Map<String fieldName, Info field> */
-  private final HashMap<String,Info> fields = new HashMap<String,Info>();
+  private final HashMap<String,Info> fields = new HashMap<>();
   
   /** fields sorted ascending by fieldName; lazily computed on demand */
   private transient Map.Entry<String,Info>[] sortedFields; 
@@ -209,7 +209,7 @@ public class MemoryIndex {
 //  private final IntBlockPool.SliceReader postingsReader;
   private final IntBlockPool.SliceWriter postingsWriter;
   
-  private HashMap<String,FieldInfo> fieldInfos = new HashMap<String,FieldInfo>();
+  private HashMap<String,FieldInfo> fieldInfos = new HashMap<>();
 
   private Counter bytesUsed;
   

Modified: lucene/dev/branches/lucene5376_2/lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/memory/src/test/org/apache/lucene/index/memory/MemoryIndexTest.java Sun Mar 16 19:39:10 2014
@@ -83,7 +83,7 @@ import static org.hamcrest.CoreMatchers.
  * returning the same results for queries on some randomish indexes.
  */
 public class MemoryIndexTest extends BaseTokenStreamTestCase {
-  private Set<String> queries = new HashSet<String>();
+  private Set<String> queries = new HashSet<>();
   
   public static final int ITERATIONS = 100 * RANDOM_MULTIPLIER;
 
@@ -98,7 +98,7 @@ public class MemoryIndexTest extends Bas
    * read a set of queries from a resource file
    */
   private Set<String> readQueries(String resource) throws IOException {
-    Set<String> queries = new HashSet<String>();
+    Set<String> queries = new HashSet<>();
     InputStream stream = getClass().getResourceAsStream(resource);
     BufferedReader reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
     String line = null;
@@ -376,7 +376,7 @@ public class MemoryIndexTest extends Bas
   // LUCENE-3831
   public void testNullPointerException() throws IOException {
     RegexpQuery regex = new RegexpQuery(new Term("field", "worl."));
-    SpanQuery wrappedquery = new SpanMultiTermQueryWrapper<RegexpQuery>(regex);
+    SpanQuery wrappedquery = new SpanMultiTermQueryWrapper<>(regex);
         
     MemoryIndex mindex = new MemoryIndex(random().nextBoolean(),  random().nextInt(50) * 1024 * 1024);
     mindex.addField("field", new MockAnalyzer(random()).tokenStream("field", "hello there"));
@@ -388,7 +388,7 @@ public class MemoryIndexTest extends Bas
   // LUCENE-3831
   public void testPassesIfWrapped() throws IOException {
     RegexpQuery regex = new RegexpQuery(new Term("field", "worl."));
-    SpanQuery wrappedquery = new SpanOrQuery(new SpanMultiTermQueryWrapper<RegexpQuery>(regex));
+    SpanQuery wrappedquery = new SpanOrQuery(new SpanMultiTermQueryWrapper<>(regex));
 
     MemoryIndex mindex = new MemoryIndex(random().nextBoolean(),  random().nextInt(50) * 1024 * 1024);
     mindex.addField("field", new MockAnalyzer(random()).tokenStream("field", "hello there"));
@@ -436,6 +436,7 @@ public class MemoryIndexTest extends Bas
     for (int i = 0; i < numDocs; i++) {
       Directory dir = newDirectory();
       MockAnalyzer mockAnalyzer = new MockAnalyzer(random());
+      mockAnalyzer.setMaxTokenLength(TestUtil.nextInt(random(), 1, IndexWriter.MAX_TERM_LENGTH));
       IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(random(), TEST_VERSION_CURRENT, mockAnalyzer));
       Document nextDoc = lineFileDocs.nextDoc();
       Document doc = new Document();

Modified: lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/document/LazyDocument.java Sun Mar 16 19:39:10 2014
@@ -45,8 +45,8 @@ public class LazyDocument {
   // null until first field is loaded
   private StoredDocument doc;
 
-  private Map<Integer,List<LazyField>> fields = new HashMap<Integer,List<LazyField>>();
-  private Set<String> fieldNames = new HashSet<String>();
+  private Map<Integer,List<LazyField>> fields = new HashMap<>();
+  private Set<String> fieldNames = new HashSet<>();
 
   public LazyDocument(IndexReader reader, int docID) {
     this.reader = reader;
@@ -73,7 +73,7 @@ public class LazyDocument {
     fieldNames.add(fieldInfo.name);
     List<LazyField> values = fields.get(fieldInfo.number);
     if (null == values) {
-      values = new ArrayList<LazyField>();
+      values = new ArrayList<>();
       fields.put(fieldInfo.number, values);
     } 
 

Modified: lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/IndexSplitter.java Sun Mar 16 19:39:10 2014
@@ -73,14 +73,14 @@ public class IndexSplitter {
     if (args[1].equals("-l")) {
       is.listSegments();
     } else if (args[1].equals("-d")) {
-      List<String> segs = new ArrayList<String>();
+      List<String> segs = new ArrayList<>();
       for (int x = 2; x < args.length; x++) {
         segs.add(args[x]);
       }
       is.remove(segs.toArray(new String[0]));
     } else {
       File targetDir = new File(args[1]);
-      List<String> segs = new ArrayList<String>();
+      List<String> segs = new ArrayList<>();
       for (int x = 2; x < args.length; x++) {
         segs.add(args[x]);
       }

Modified: lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/MultiPassIndexSplitter.java Sun Mar 16 19:39:10 2014
@@ -118,7 +118,7 @@ public class MultiPassIndexSplitter {
       System.err.println("\t-seq\tsequential docid-range split (default is round-robin)");
       System.exit(-1);
     }
-    ArrayList<IndexReader> indexes = new ArrayList<IndexReader>();
+    ArrayList<IndexReader> indexes = new ArrayList<>();
     String outDir = null;
     int numParts = -1;
     boolean seq = false;

Modified: lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/sorter/EarlyTerminatingSortingCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/sorter/EarlyTerminatingSortingCollector.java?rev=1578144&r1=1578143&r2=1578144&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/sorter/EarlyTerminatingSortingCollector.java (original)
+++ lucene/dev/branches/lucene5376_2/lucene/misc/src/java/org/apache/lucene/index/sorter/EarlyTerminatingSortingCollector.java Sun Mar 16 19:39:10 2014
@@ -24,50 +24,53 @@ import org.apache.lucene.index.IndexWrit
 import org.apache.lucene.search.CollectionTerminatedException;
 import org.apache.lucene.search.Collector;
 import org.apache.lucene.search.Scorer;
+import org.apache.lucene.search.Sort;
 import org.apache.lucene.search.TopDocsCollector;
 import org.apache.lucene.search.TotalHitCountCollector;
 
 /**
  * A {@link Collector} that early terminates collection of documents on a
  * per-segment basis, if the segment was sorted according to the given
- * {@link Sorter}.
+ * {@link Sort}.
  * 
  * <p>
- * <b>NOTE:</b> the {@link Collector} detects sorted segments according to
+ * <b>NOTE:</b> the {@code Collector} detects sorted segments according to
  * {@link SortingMergePolicy}, so it's best used in conjunction with it. Also,
- * it collects up to a specified num docs from each segment, and therefore is
- * mostly suitable for use in conjunction with collectors such as
+ * it collects up to a specified {@code numDocsToCollect} from each segment, 
+ * and therefore is mostly suitable for use in conjunction with collectors such as
  * {@link TopDocsCollector}, and not e.g. {@link TotalHitCountCollector}.
  * <p>
- * <b>NOTE</b>: If you wrap a {@link TopDocsCollector} that sorts in the same
- * order as the index order, the returned {@link TopDocsCollector#topDocs()}
+ * <b>NOTE</b>: If you wrap a {@code TopDocsCollector} that sorts in the same
+ * order as the index order, the returned {@link TopDocsCollector#topDocs() TopDocs}
  * will be correct. However the total of {@link TopDocsCollector#getTotalHits()
  * hit count} will be underestimated since not all matching documents will have
  * been collected.
  * <p>
- * <b>NOTE</b>: This {@link Collector} uses {@link Sorter#getID()} to detect
- * whether a segment was sorted with the same {@link Sorter} as the one given in
- * {@link #EarlyTerminatingSortingCollector(Collector, Sorter, int)}. This has
+ * <b>NOTE</b>: This {@code Collector} uses {@link Sort#toString()} to detect
+ * whether a segment was sorted with the same {@code Sort}. This has
  * two implications:
  * <ul>
- * <li>if {@link Sorter#getID()} is not implemented correctly and returns
- * different identifiers for equivalent {@link Sorter}s, this collector will not
+ * <li>if a custom comparator is not implemented correctly and returns
+ * different identifiers for equivalent instances, this collector will not
  * detect sorted segments,</li>
  * <li>if you suddenly change the {@link IndexWriter}'s
- * {@link SortingMergePolicy} to sort according to another criterion and if both
- * the old and the new {@link Sorter}s have the same identifier, this
- * {@link Collector} will incorrectly detect sorted segments.</li>
+ * {@code SortingMergePolicy} to sort according to another criterion and if both
+ * the old and the new {@code Sort}s have the same identifier, this
+ * {@code Collector} will incorrectly detect sorted segments.</li>
  * </ul>
  * 
  * @lucene.experimental
  */
 public class EarlyTerminatingSortingCollector extends Collector {
-
+  /** The wrapped Collector */
   protected final Collector in;
-  protected final Sorter sorter;
+  /** Sort used to sort the search results */
+  protected final Sort sort;
+  /** Number of documents to collect in each segment */
   protected final int numDocsToCollect;
-  
+  /** Number of documents to collect in the current segment being processed */
   protected int segmentTotalCollect;
+  /** True if the current segment being processed is sorted by {@link #sort} */
   protected boolean segmentSorted;
 
   private int numCollected;
@@ -77,20 +80,19 @@ public class EarlyTerminatingSortingColl
    * 
    * @param in
    *          the collector to wrap
-   * @param sorter
-   *          the same sorter as the one which is used by {@link IndexWriter}'s
-   *          {@link SortingMergePolicy}
+   * @param sort
+   *          the sort you are sorting the search results on
    * @param numDocsToCollect
    *          the number of documents to collect on each segment. When wrapping
    *          a {@link TopDocsCollector}, this number should be the number of
    *          hits.
    */
-  public EarlyTerminatingSortingCollector(Collector in, Sorter sorter, int numDocsToCollect) {
+  public EarlyTerminatingSortingCollector(Collector in, Sort sort, int numDocsToCollect) {
     if (numDocsToCollect <= 0) {
       throw new IllegalStateException("numDocsToCollect must always be > 0, got " + segmentTotalCollect);
     }
     this.in = in;
-    this.sorter = sorter;
+    this.sort = sort;
     this.numDocsToCollect = numDocsToCollect;
   }
 
@@ -110,7 +112,7 @@ public class EarlyTerminatingSortingColl
   @Override
   public void setNextReader(AtomicReaderContext context) throws IOException {
     in.setNextReader(context);
-    segmentSorted = SortingMergePolicy.isSorted(context.reader(), sorter);
+    segmentSorted = SortingMergePolicy.isSorted(context.reader(), sort);
     segmentTotalCollect = segmentSorted ? numDocsToCollect : Integer.MAX_VALUE;
     numCollected = 0;
   }