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 2015/12/21 12:40:14 UTC

svn commit: r1721134 [10/48] - in /lucene/dev/branches/lucene6835: ./ dev-tools/ dev-tools/eclipse/dot.settings/ dev-tools/idea/.idea/libraries/ dev-tools/maven/ dev-tools/maven/lucene/analysis/morfologik/ dev-tools/scripts/ lucene/ lucene/analysis/ lu...

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestDisjunctionMaxQuery.java Mon Dec 21 11:39:57 2015
@@ -20,6 +20,7 @@ package org.apache.lucene.search;
 import java.io.IOException;
 import java.text.DecimalFormat;
 import java.text.DecimalFormatSymbols;
+import java.util.Arrays;
 import java.util.Locale;
 
 import org.apache.lucene.analysis.Analyzer;
@@ -40,7 +41,6 @@ import org.apache.lucene.index.StoredDoc
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.similarities.ClassicSimilarity;
 import org.apache.lucene.search.similarities.Similarity;
-import org.apache.lucene.search.spans.SpanQuery;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
@@ -172,16 +172,15 @@ public class TestDisjunctionMaxQuery ext
   }
   
   public void testSkipToFirsttimeMiss() throws IOException {
-    final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);
-    dq.add(tq("id", "d1"));
-    dq.add(tq("dek", "DOES_NOT_EXIST"));
-    
+    final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(
+        Arrays.asList(tq("id", "d1"), tq("dek", "DOES_NOT_EXIST")), 0.0f);
+
     QueryUtils.check(random(), dq, s);
     assertTrue(s.getTopReaderContext() instanceof LeafReaderContext);
     final Weight dw = s.createNormalizedWeight(dq, true);
     LeafReaderContext context = (LeafReaderContext)s.getTopReaderContext();
     final Scorer ds = dw.scorer(context);
-    final boolean skipOk = ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS;
+    final boolean skipOk = ds.iterator().advance(3) != DocIdSetIterator.NO_MORE_DOCS;
     if (skipOk) {
       fail("firsttime skipTo found a match? ... "
           + r.document(ds.docID()).get("id"));
@@ -189,24 +188,24 @@ public class TestDisjunctionMaxQuery ext
   }
   
   public void testSkipToFirsttimeHit() throws IOException {
-    final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(0.0f);
-    dq.add(tq("dek", "albino"));
-    dq.add(tq("dek", "DOES_NOT_EXIST"));
+    final DisjunctionMaxQuery dq = new DisjunctionMaxQuery(
+        Arrays.asList(tq("dek", "albino"), tq("dek", "DOES_NOT_EXIST")), 0.0f);
+
     assertTrue(s.getTopReaderContext() instanceof LeafReaderContext);
     QueryUtils.check(random(), dq, s);
     final Weight dw = s.createNormalizedWeight(dq, true);
     LeafReaderContext context = (LeafReaderContext)s.getTopReaderContext();
     final Scorer ds = dw.scorer(context);
     assertTrue("firsttime skipTo found no match",
-        ds.advance(3) != DocIdSetIterator.NO_MORE_DOCS);
+        ds.iterator().advance(3) != DocIdSetIterator.NO_MORE_DOCS);
     assertEquals("found wrong docid", "d4", r.document(ds.docID()).get("id"));
   }
   
   public void testSimpleEqualScores1() throws Exception {
     
-    DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
-    q.add(tq("hed", "albino"));
-    q.add(tq("hed", "elephant"));
+    DisjunctionMaxQuery q = new DisjunctionMaxQuery(
+        Arrays.asList(tq("hed", "albino"), tq("hed", "elephant")),
+        0.0f);
     QueryUtils.check(random(), q, s);
     
     ScoreDoc[] h = s.search(q, 1000).scoreDocs;
@@ -228,9 +227,9 @@ public class TestDisjunctionMaxQuery ext
   
   public void testSimpleEqualScores2() throws Exception {
     
-    DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
-    q.add(tq("dek", "albino"));
-    q.add(tq("dek", "elephant"));
+    DisjunctionMaxQuery q = new DisjunctionMaxQuery(
+        Arrays.asList(tq("dek", "albino"), tq("dek", "elephant")),
+        0.0f);
     QueryUtils.check(random(), q, s);
     
     ScoreDoc[] h = s.search(q, 1000).scoreDocs;
@@ -251,11 +250,13 @@ public class TestDisjunctionMaxQuery ext
   
   public void testSimpleEqualScores3() throws Exception {
     
-    DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.0f);
-    q.add(tq("hed", "albino"));
-    q.add(tq("hed", "elephant"));
-    q.add(tq("dek", "albino"));
-    q.add(tq("dek", "elephant"));
+    DisjunctionMaxQuery q = new DisjunctionMaxQuery(
+        Arrays.asList(
+            tq("hed", "albino"),
+            tq("hed", "elephant"),
+            tq("dek", "albino"),
+            tq("dek", "elephant")),
+        0.0f);
     QueryUtils.check(random(), q, s);
     
     ScoreDoc[] h = s.search(q, 1000).scoreDocs;
@@ -276,9 +277,9 @@ public class TestDisjunctionMaxQuery ext
   
   public void testSimpleTiebreaker() throws Exception {
     
-    DisjunctionMaxQuery q = new DisjunctionMaxQuery(0.01f);
-    q.add(tq("dek", "albino"));
-    q.add(tq("dek", "elephant"));
+    DisjunctionMaxQuery q = new DisjunctionMaxQuery(
+        Arrays.asList(tq("dek", "albino"), tq("dek", "elephant")),
+        0.01f);
     QueryUtils.check(random(), q, s);
     
     ScoreDoc[] h = s.search(q, 1000).scoreDocs;
@@ -303,17 +304,17 @@ public class TestDisjunctionMaxQuery ext
     
     BooleanQuery.Builder q = new BooleanQuery.Builder();
     {
-      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
-      q1.add(tq("hed", "albino"));
-      q1.add(tq("dek", "albino"));
+      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "albino"), tq("dek", "albino")),
+          0.0f);
       q.add(q1, BooleanClause.Occur.MUST);// true,false);
       QueryUtils.check(random(), q1, s);
       
     }
     {
-      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
-      q2.add(tq("hed", "elephant"));
-      q2.add(tq("dek", "elephant"));
+      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "elephant"), tq("dek", "elephant")),
+          0.0f);
       q.add(q2, BooleanClause.Occur.MUST);// true,false);
       QueryUtils.check(random(), q2, s);
     }
@@ -339,15 +340,15 @@ public class TestDisjunctionMaxQuery ext
     
     BooleanQuery.Builder q = new BooleanQuery.Builder();
     {
-      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.0f);
-      q1.add(tq("hed", "albino"));
-      q1.add(tq("dek", "albino"));
+      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "albino"), tq("dek", "albino")),
+          0.0f);
       q.add(q1, BooleanClause.Occur.SHOULD);// false,false);
     }
     {
-      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.0f);
-      q2.add(tq("hed", "elephant"));
-      q2.add(tq("dek", "elephant"));
+      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "elephant"), tq("dek", "elephant")),
+          0.0f);
       q.add(q2, BooleanClause.Occur.SHOULD);// false,false);
     }
     QueryUtils.check(random(), q.build(), s);
@@ -375,15 +376,15 @@ public class TestDisjunctionMaxQuery ext
     
     BooleanQuery.Builder q = new BooleanQuery.Builder();
     {
-      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
-      q1.add(tq("hed", "albino"));
-      q1.add(tq("dek", "albino"));
+      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "albino"), tq("dek", "albino")),
+          0.01f);
       q.add(q1, BooleanClause.Occur.SHOULD);// false,false);
     }
     {
-      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
-      q2.add(tq("hed", "elephant"));
-      q2.add(tq("dek", "elephant"));
+      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "elephant"), tq("dek", "elephant")),
+          0.01f);
       q.add(q2, BooleanClause.Occur.SHOULD);// false,false);
     }
     QueryUtils.check(random(), q.build(), s);
@@ -429,15 +430,15 @@ public class TestDisjunctionMaxQuery ext
     
     BooleanQuery.Builder q = new BooleanQuery.Builder();
     {
-      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(0.01f);
-      q1.add(tq("hed", "albino", 1.5f));
-      q1.add(tq("dek", "albino"));
+      DisjunctionMaxQuery q1 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "albino", 1.5f), tq("dek", "albino")),
+          0.01f);
       q.add(q1, BooleanClause.Occur.SHOULD);// false,false);
     }
     {
-      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(0.01f);
-      q2.add(tq("hed", "elephant", 1.5f));
-      q2.add(tq("dek", "elephant"));
+      DisjunctionMaxQuery q2 = new DisjunctionMaxQuery(
+          Arrays.asList(tq("hed", "elephant", 1.5f), tq("dek", "elephant")),
+          0.01f);
       q.add(q2, BooleanClause.Occur.SHOULD);// false,false);
     }
     QueryUtils.check(random(), q.build(), s);
@@ -493,11 +494,11 @@ public class TestDisjunctionMaxQuery ext
     IndexReader indexReader = DirectoryReader.open(directory);
     IndexSearcher searcher = newSearcher(indexReader);
 
-    DisjunctionMaxQuery query = new DisjunctionMaxQuery(1.0f);
-    SpanQuery sq1 = new SpanTermQuery(new Term(FIELD, "clockwork"));
-    SpanQuery sq2 = new SpanTermQuery(new Term(FIELD, "clckwork"));
-    query.add(sq1);
-    query.add(sq2);
+    DisjunctionMaxQuery query = new DisjunctionMaxQuery(
+        Arrays.asList(
+            new SpanTermQuery(new Term(FIELD, "clockwork")),
+            new SpanTermQuery(new Term(FIELD, "clckwork"))),
+        1.0f);
     TopScoreDocCollector collector = TopScoreDocCollector.create(1000);
     searcher.search(query, collector);
     hits = collector.topDocs().scoreDocs.length;

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLRUQueryCache.java Mon Dec 21 11:39:57 2015
@@ -19,6 +19,7 @@ package org.apache.lucene.search;
 
 import java.io.IOException;
 import java.lang.reflect.Field;
+import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
@@ -28,6 +29,7 @@ import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -784,6 +786,7 @@ public class TestLRUQueryCache extends L
     final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
     Document doc = new Document();
     doc.add(new StringField("foo", "bar", Store.YES));
+    doc.add(new StringField("foo", "quux", Store.YES));
     w.addDocument(doc);
     w.commit();
     final IndexReader reader = w.getReader();
@@ -797,7 +800,7 @@ public class TestLRUQueryCache extends L
     BooleanQuery.Builder bq = new BooleanQuery.Builder();
     TermQuery should = new TermQuery(new Term("foo", "baz"));
     TermQuery must = new TermQuery(new Term("foo", "bar"));
-    TermQuery filter = new TermQuery(new Term("foo", "bar"));
+    TermQuery filter = new TermQuery(new Term("foo", "quux"));
     TermQuery mustNot = new TermQuery(new Term("foo", "foo"));
     bq.add(should, Occur.SHOULD);
     bq.add(must, Occur.MUST);
@@ -810,7 +813,7 @@ public class TestLRUQueryCache extends L
     bq2.add(must, Occur.FILTER);
     bq2.add(filter, Occur.FILTER);
     bq2.add(mustNot, Occur.MUST_NOT);
-    
+
     assertEquals(Collections.emptySet(), new HashSet<>(queryCache.cachedQueries()));
     searcher.search(bq.build(), 1);
     assertEquals(new HashSet<>(Arrays.asList(filter, mustNot)), new HashSet<>(queryCache.cachedQueries()));
@@ -860,12 +863,12 @@ public class TestLRUQueryCache extends L
       case 4:
         return new ConstantScoreQuery(buildRandomQuery(level + 1));
       case 5:
-        DisjunctionMaxQuery dmq = new DisjunctionMaxQuery(random().nextFloat());
+        List<Query> disjuncts = new ArrayList<>();
         final int numQueries = TestUtil.nextInt(random(), 1, 3);
         for (int i = 0; i < numQueries; ++i) {
-          dmq.add(buildRandomQuery(level + 1));
+          disjuncts.add(buildRandomQuery(level + 1));
         }
-        return dmq;
+        return new DisjunctionMaxQuery(disjuncts, random().nextFloat());
       default:
         throw new AssertionError();
     }
@@ -879,11 +882,11 @@ public class TestLRUQueryCache extends L
     doc.add(f);
     w.addDocument(doc);
     IndexReader reader = w.getReader();
-    
+
     final int maxSize;
     final long maxRamBytesUsed;
     final int iters;
-    
+
     if (TEST_NIGHTLY) {
       maxSize = TestUtil.nextInt(random(), 1, 10000);
       maxRamBytesUsed = TestUtil.nextLong(random(), 1, 5000000);
@@ -929,7 +932,7 @@ public class TestLRUQueryCache extends L
   private static class BadQuery extends Query {
 
     int[] i = new int[] {42}; // an array so that clone keeps the reference
-    
+
     @Override
     public Weight createWeight(IndexSearcher searcher, boolean needsScores) throws IOException {
       return new ConstantScoreWeight(this) {
@@ -939,17 +942,17 @@ public class TestLRUQueryCache extends L
         }
       };
     }
-    
+
     @Override
     public String toString(String field) {
       return "BadQuery";
     }
-    
+
     @Override
     public int hashCode() {
       return super.hashCode() ^ i[0];
     }
-    
+
   }
 
   public void testDetectMutatedQueries() throws IOException {
@@ -963,11 +966,11 @@ public class TestLRUQueryCache extends L
     final IndexSearcher searcher = newSearcher(reader);
     searcher.setQueryCache(queryCache);
     searcher.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
-    
+
     BadQuery query = new BadQuery();
     searcher.count(query);
     query.i[0] += 1; // change the hashCode!
-    
+
     try {
       // trigger an eviction
       searcher.search(new MatchAllDocsQuery(), new TotalHitCountCollector());
@@ -980,7 +983,7 @@ public class TestLRUQueryCache extends L
       assertTrue(cause instanceof ExecutionException);
       assertTrue(cause.getCause() instanceof ConcurrentModificationException);
     }
-    
+
     IOUtils.close(w, reader, dir);
   }
 
@@ -1081,4 +1084,112 @@ public class TestLRUQueryCache extends L
       return true;
     }
   }
+
+  private static class WeightWrapper extends Weight {
+
+    private final Weight in;
+    private final AtomicBoolean scorerCalled;
+    private final AtomicBoolean bulkScorerCalled;
+
+    protected WeightWrapper(Weight in, AtomicBoolean scorerCalled, AtomicBoolean bulkScorerCalled) {
+      super(in.getQuery());
+      this.in = in;
+      this.scorerCalled = scorerCalled;
+      this.bulkScorerCalled = bulkScorerCalled;
+    }
+
+    @Override
+    public void extractTerms(Set<Term> terms) {
+      in.extractTerms(terms);
+    }
+
+    @Override
+    public Explanation explain(LeafReaderContext context, int doc) throws IOException {
+      return in.explain(context, doc);
+    }
+
+    @Override
+    public float getValueForNormalization() throws IOException {
+      return in.getValueForNormalization();
+    }
+
+    @Override
+    public void normalize(float norm, float boost) {
+      in.normalize(norm, boost);
+    }
+
+    @Override
+    public Scorer scorer(LeafReaderContext context) throws IOException {
+      scorerCalled.set(true);
+      return in.scorer(context);
+    }
+
+    @Override
+    public BulkScorer bulkScorer(LeafReaderContext context) throws IOException {
+      bulkScorerCalled.set(true);
+      return in.bulkScorer(context);
+    }
+  }
+
+  public void testPropagateBulkScorer() throws IOException {
+    Directory dir = newDirectory();
+    RandomIndexWriter w = new RandomIndexWriter(random(), dir);
+    w.addDocument(new Document());
+    IndexReader reader = w.getReader();
+    w.close();
+    IndexSearcher searcher = newSearcher(reader);
+    LeafReaderContext leaf = searcher.getIndexReader().leaves().get(0);
+    AtomicBoolean scorerCalled = new AtomicBoolean();
+    AtomicBoolean bulkScorerCalled = new AtomicBoolean();
+    LRUQueryCache cache = new LRUQueryCache(1, Long.MAX_VALUE);
+
+    // test that the bulk scorer is propagated when a scorer should not be cached
+    Weight weight = searcher.createNormalizedWeight(new MatchAllDocsQuery(), false);
+    weight = new WeightWrapper(weight, scorerCalled, bulkScorerCalled);
+    weight = cache.doCache(weight, NEVER_CACHE);
+    weight.bulkScorer(leaf);
+    assertEquals(true, bulkScorerCalled.get());
+    assertEquals(false, scorerCalled.get());
+    assertEquals(0, cache.getCacheCount());
+
+    // test that the doc id set is computed using the bulk scorer
+    bulkScorerCalled.set(false);
+    weight = searcher.createNormalizedWeight(new MatchAllDocsQuery(), false);
+    weight = new WeightWrapper(weight, scorerCalled, bulkScorerCalled);
+    weight = cache.doCache(weight, QueryCachingPolicy.ALWAYS_CACHE);
+    weight.scorer(leaf);
+    assertEquals(true, bulkScorerCalled.get());
+    assertEquals(false, scorerCalled.get());
+    assertEquals(1, cache.getCacheCount());
+
+    searcher.getIndexReader().close();
+    dir.close();
+  }
+
+  public void testEvictEmptySegmentCache() throws IOException {
+    Directory dir = newDirectory();
+    final RandomIndexWriter w = new RandomIndexWriter(random(), dir);
+    w.addDocument(new Document());
+    final DirectoryReader reader = w.getReader();
+    final IndexSearcher searcher = newSearcher(reader);
+    final LRUQueryCache queryCache = new LRUQueryCache(2, 100000) {
+      @Override
+      protected void onDocIdSetEviction(Object readerCoreKey, int numEntries, long sumRamBytesUsed) {
+        super.onDocIdSetEviction(readerCoreKey, numEntries, sumRamBytesUsed);
+        assertTrue(numEntries > 0);
+      }
+    };
+
+    searcher.setQueryCache(queryCache);
+    searcher.setQueryCachingPolicy(QueryCachingPolicy.ALWAYS_CACHE);
+
+    Query query = new DummyQuery();
+    searcher.count(query);
+    assertEquals(Collections.singletonList(query), queryCache.cachedQueries());
+    queryCache.clearQuery(query);
+
+    reader.close(); // make sure this does not trigger eviction of segment caches with no entries
+    w.close();
+    dir.close();
+  }
 }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestLiveFieldValues.java Mon Dec 21 11:39:57 2015
@@ -30,7 +30,7 @@ import java.util.concurrent.CountDownLat
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.StoredField;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
@@ -109,7 +109,7 @@ public class TestLiveFieldValues extends
                   String id = String.format(Locale.ROOT, "%d_%04x", threadID, threadRandom.nextInt(idCount));
                   Integer field = threadRandom.nextInt(Integer.MAX_VALUE);
                   doc.add(newStringField("id", new BytesRef(id), Field.Store.YES));
-                  doc.add(new IntField("field", field.intValue(), Field.Store.YES));
+                  doc.add(new StoredField("field", field.intValue()));
                   w.updateDocument(new Term("id", id), doc);
                   rt.add(id, field);
                   if (values.put(id, field) == null) {

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMinShouldMatch2.java Mon Dec 21 11:39:57 2015
@@ -147,36 +147,40 @@ public class TestMinShouldMatch2 extends
   
   private void assertNext(Scorer expected, Scorer actual) throws Exception {
     if (actual == null) {
-      assertEquals(DocIdSetIterator.NO_MORE_DOCS, expected.nextDoc());
+      assertEquals(DocIdSetIterator.NO_MORE_DOCS, expected.iterator().nextDoc());
       return;
     }
     int doc;
-    while ((doc = expected.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
-      assertEquals(doc, actual.nextDoc());
+    DocIdSetIterator expectedIt = expected.iterator();
+    DocIdSetIterator actualIt = actual.iterator();
+    while ((doc = expectedIt.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+      assertEquals(doc, actualIt.nextDoc());
       assertEquals(expected.freq(), actual.freq());
       float expectedScore = expected.score();
       float actualScore = actual.score();
       assertEquals(expectedScore, actualScore, CheckHits.explainToleranceDelta(expectedScore, actualScore));
     }
-    assertEquals(DocIdSetIterator.NO_MORE_DOCS, actual.nextDoc());
+    assertEquals(DocIdSetIterator.NO_MORE_DOCS, actualIt.nextDoc());
   }
   
   private void assertAdvance(Scorer expected, Scorer actual, int amount) throws Exception {
     if (actual == null) {
-      assertEquals(DocIdSetIterator.NO_MORE_DOCS, expected.nextDoc());
+      assertEquals(DocIdSetIterator.NO_MORE_DOCS, expected.iterator().nextDoc());
       return;
     }
+    DocIdSetIterator expectedIt = expected.iterator();
+    DocIdSetIterator actualIt = actual.iterator();
     int prevDoc = 0;
     int doc;
-    while ((doc = expected.advance(prevDoc+amount)) != DocIdSetIterator.NO_MORE_DOCS) {
-      assertEquals(doc, actual.advance(prevDoc+amount));
+    while ((doc = expectedIt.advance(prevDoc+amount)) != DocIdSetIterator.NO_MORE_DOCS) {
+      assertEquals(doc, actualIt.advance(prevDoc+amount));
       assertEquals(expected.freq(), actual.freq());
       float expectedScore = expected.score();
       float actualScore = actual.score();
       assertEquals(expectedScore, actualScore, CheckHits.explainToleranceDelta(expectedScore, actualScore));
       prevDoc = doc;
     }
-    assertEquals(DocIdSetIterator.NO_MORE_DOCS, actual.advance(prevDoc+amount));
+    assertEquals(DocIdSetIterator.NO_MORE_DOCS, actualIt.advance(prevDoc+amount));
   }
   
   /** simple test for next(): minShouldMatch=2 on 3 terms (one common, one medium, one rare) */
@@ -361,37 +365,48 @@ public class TestMinShouldMatch2 extends
     }
 
     @Override
-    public int nextDoc() throws IOException {
-      assert currentDoc != NO_MORE_DOCS;
-      for (currentDoc = currentDoc+1; currentDoc < maxDoc; currentDoc++) {
-        currentMatched = 0;
-        score = 0;
-        dv.setDocument(currentDoc);
-        long ord;
-        while ((ord = dv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
-          if (ords.contains(ord)) {
-            currentMatched++;
-            score += sims[(int)ord].score(currentDoc, 1);
+    public DocIdSetIterator iterator() {
+      return new DocIdSetIterator() {
+        
+        @Override
+        public int nextDoc() throws IOException {
+          assert currentDoc != NO_MORE_DOCS;
+          for (currentDoc = currentDoc+1; currentDoc < maxDoc; currentDoc++) {
+            currentMatched = 0;
+            score = 0;
+            dv.setDocument(currentDoc);
+            long ord;
+            while ((ord = dv.nextOrd()) != SortedSetDocValues.NO_MORE_ORDS) {
+              if (ords.contains(ord)) {
+                currentMatched++;
+                score += sims[(int)ord].score(currentDoc, 1);
+              }
+            }
+            if (currentMatched >= minNrShouldMatch) {
+              return currentDoc;
+            }
           }
+          return currentDoc = NO_MORE_DOCS;
         }
-        if (currentMatched >= minNrShouldMatch) {
-          return currentDoc;
-        }
-      }
-      return currentDoc = NO_MORE_DOCS;
-    }
 
-    @Override
-    public int advance(int target) throws IOException {
-      int doc;
-      while ((doc = nextDoc()) < target) {
-      }
-      return doc;
-    }
+        @Override
+        public int advance(int target) throws IOException {
+          int doc;
+          while ((doc = nextDoc()) < target) {
+          }
+          return doc;
+        }
 
-    @Override
-    public long cost() {
-      return maxDoc;
+        @Override
+        public long cost() {
+          return maxDoc;
+        }
+        
+        @Override
+        public int docID() {
+          return currentDoc;
+        }
+      };
     }
   }
 }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestMultiValuedNumericRangeQuery.java Mon Dec 21 11:39:57 2015
@@ -24,7 +24,7 @@ import java.text.DecimalFormatSymbols;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
-import org.apache.lucene.document.IntField;
+import org.apache.lucene.document.LegacyIntField;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.store.Directory;
@@ -33,9 +33,9 @@ import org.apache.lucene.util.TestUtil;
 
 public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
 
-  /** Tests NumericRangeQuery on a multi-valued field (multiple numeric values per document).
+  /** Tests LegacyNumericRangeQuery on a multi-valued field (multiple numeric values per document).
    * This test ensures, that a classical TermRangeQuery returns exactly the same document numbers as
-   * NumericRangeQuery (see SOLR-1322 for discussion) and the multiple precision terms per numeric value
+   * LegacyNumericRangeQuery (see SOLR-1322 for discussion) and the multiple precision terms per numeric value
    * do not interfere with multiple numeric values.
    */
   public void testMultiValuedNRQ() throws Exception {
@@ -52,7 +52,7 @@ public class TestMultiValuedNumericRange
       for (int m=0, c=random().nextInt(10); m<=c; m++) {
         int value = random().nextInt(Integer.MAX_VALUE);
         doc.add(newStringField("asc", format.format(value), Field.Store.NO));
-        doc.add(new IntField("trie", value, Field.Store.NO));
+        doc.add(new LegacyIntField("trie", value, Field.Store.NO));
       }
       writer.addDocument(doc);
     }
@@ -68,10 +68,10 @@ public class TestMultiValuedNumericRange
         int a=lower; lower=upper; upper=a;
       }
       TermRangeQuery cq=TermRangeQuery.newStringRange("asc", format.format(lower), format.format(upper), true, true);
-      NumericRangeQuery<Integer> tq=NumericRangeQuery.newIntRange("trie", lower, upper, true, true);
+      LegacyNumericRangeQuery<Integer> tq= LegacyNumericRangeQuery.newIntRange("trie", lower, upper, true, true);
       TopDocs trTopDocs = searcher.search(cq, 1);
       TopDocs nrTopDocs = searcher.search(tq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", trTopDocs.totalHits, nrTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", trTopDocs.totalHits, nrTopDocs.totalHits );
     }
     reader.close();
     directory.close();

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery32.java Mon Dec 21 11:39:57 2015
@@ -21,23 +21,21 @@ import org.apache.lucene.analysis.MockAn
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.FloatField;
-import org.apache.lucene.document.IntField;
-import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.document.LegacyFloatField;
+import org.apache.lucene.document.LegacyIntField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.SlowCompositeReaderWrapper;
 import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.LegacyNumericUtils;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.util.TestNumericUtils; // NaN arrays
+import org.apache.lucene.util.TestLegacyNumericUtils; // NaN arrays
 import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -65,7 +63,7 @@ public class TestNumericRangeQuery32 ext
         .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
         .setMergePolicy(newLogMergePolicy()));
     
-    final FieldType storedInt = new FieldType(IntField.TYPE_NOT_STORED);
+    final FieldType storedInt = new FieldType(LegacyIntField.TYPE_NOT_STORED);
     storedInt.setStored(true);
     storedInt.freeze();
 
@@ -81,7 +79,7 @@ public class TestNumericRangeQuery32 ext
     final FieldType storedIntNone = new FieldType(storedInt);
     storedIntNone.setNumericPrecisionStep(Integer.MAX_VALUE);
 
-    final FieldType unstoredInt = IntField.TYPE_NOT_STORED;
+    final FieldType unstoredInt = LegacyIntField.TYPE_NOT_STORED;
 
     final FieldType unstoredInt8 = new FieldType(unstoredInt);
     unstoredInt8.setNumericPrecisionStep(8);
@@ -92,14 +90,14 @@ public class TestNumericRangeQuery32 ext
     final FieldType unstoredInt2 = new FieldType(unstoredInt);
     unstoredInt2.setNumericPrecisionStep(2);
 
-    IntField
-      field8 = new IntField("field8", 0, storedInt8),
-      field4 = new IntField("field4", 0, storedInt4),
-      field2 = new IntField("field2", 0, storedInt2),
-      fieldNoTrie = new IntField("field"+Integer.MAX_VALUE, 0, storedIntNone),
-      ascfield8 = new IntField("ascfield8", 0, unstoredInt8),
-      ascfield4 = new IntField("ascfield4", 0, unstoredInt4),
-      ascfield2 = new IntField("ascfield2", 0, unstoredInt2);
+    LegacyIntField
+      field8 = new LegacyIntField("field8", 0, storedInt8),
+      field4 = new LegacyIntField("field4", 0, storedInt4),
+      field2 = new LegacyIntField("field2", 0, storedInt2),
+      fieldNoTrie = new LegacyIntField("field"+Integer.MAX_VALUE, 0, storedIntNone),
+      ascfield8 = new LegacyIntField("ascfield8", 0, unstoredInt8),
+      ascfield4 = new LegacyIntField("ascfield4", 0, unstoredInt4),
+      ascfield2 = new LegacyIntField("ascfield2", 0, unstoredInt2);
     
     Document doc = new Document();
     // add fields, that have a distance to test general functionality
@@ -149,7 +147,7 @@ public class TestNumericRangeQuery32 ext
     String field="field"+precisionStep;
     int count=3000;
     int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
-    NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
+    LegacyNumericRangeQuery<Integer> q = LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
     for (byte i=0; i<2; i++) {
       TopDocs topDocs;
       String type;
@@ -194,7 +192,7 @@ public class TestNumericRangeQuery32 ext
   
   @Test
   public void testOneMatchQuery() throws Exception {
-    NumericRangeQuery<Integer> q = NumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true);
+    LegacyNumericRangeQuery<Integer> q = LegacyNumericRangeQuery.newIntRange("ascfield8", 8, 1000, 1000, true, true);
     TopDocs topDocs = searcher.search(q, noDocs);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -205,7 +203,7 @@ public class TestNumericRangeQuery32 ext
     String field="field"+precisionStep;
     int count=3000;
     int upper=(count-1)*distance + (distance/3) + startOffset;
-    NumericRangeQuery<Integer> q=NumericRangeQuery.newIntRange(field, precisionStep, null, upper, true, true);
+    LegacyNumericRangeQuery<Integer> q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, null, upper, true, true);
     TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -215,7 +213,7 @@ public class TestNumericRangeQuery32 ext
     doc=searcher.doc(sd[sd.length-1].doc);
     assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
     
-    q=NumericRangeQuery.newIntRange(field, precisionStep, null, upper, false, true);
+    q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, null, upper, false, true);
     topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -245,7 +243,7 @@ public class TestNumericRangeQuery32 ext
     String field="field"+precisionStep;
     int count=3000;
     int lower=(count-1)*distance + (distance/3) +startOffset;
-    NumericRangeQuery<Integer> q=NumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, true);
+    LegacyNumericRangeQuery<Integer> q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, true);
     TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -255,7 +253,7 @@ public class TestNumericRangeQuery32 ext
     doc=searcher.doc(sd[sd.length-1].doc);
     assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().intValue());
 
-    q=NumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, false);
+    q= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, null, true, false);
     topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -287,23 +285,23 @@ public class TestNumericRangeQuery32 ext
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
       newIndexWriterConfig(new MockAnalyzer(random())));
     Document doc = new Document();
-    doc.add(new FloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
-    doc.add(new IntField("int", Integer.MIN_VALUE, Field.Store.NO));
+    doc.add(new LegacyFloatField("float", Float.NEGATIVE_INFINITY, Field.Store.NO));
+    doc.add(new LegacyIntField("int", Integer.MIN_VALUE, Field.Store.NO));
     writer.addDocument(doc);
     
     doc = new Document();
-    doc.add(new FloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
-    doc.add(new IntField("int", Integer.MAX_VALUE, Field.Store.NO));
+    doc.add(new LegacyFloatField("float", Float.POSITIVE_INFINITY, Field.Store.NO));
+    doc.add(new LegacyIntField("int", Integer.MAX_VALUE, Field.Store.NO));
     writer.addDocument(doc);
     
     doc = new Document();
-    doc.add(new FloatField("float", 0.0f, Field.Store.NO));
-    doc.add(new IntField("int", 0, Field.Store.NO));
+    doc.add(new LegacyFloatField("float", 0.0f, Field.Store.NO));
+    doc.add(new LegacyIntField("int", 0, Field.Store.NO));
     writer.addDocument(doc);
     
-    for (float f : TestNumericUtils.FLOAT_NANs) {
+    for (float f : TestLegacyNumericUtils.FLOAT_NANs) {
       doc = new Document();
-      doc.add(new FloatField("float", f, Field.Store.NO));
+      doc.add(new LegacyFloatField("float", f, Field.Store.NO));
       writer.addDocument(doc);
     }
     
@@ -312,41 +310,41 @@ public class TestNumericRangeQuery32 ext
     IndexReader r = DirectoryReader.open(dir);
     IndexSearcher s = newSearcher(r);
     
-    Query q=NumericRangeQuery.newIntRange("int", null, null, true, true);
+    Query q= LegacyNumericRangeQuery.newIntRange("int", null, null, true, true);
     TopDocs topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
     
-    q=NumericRangeQuery.newIntRange("int", null, null, false, false);
+    q= LegacyNumericRangeQuery.newIntRange("int", null, null, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
+    q= LegacyNumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
     
-    q=NumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
+    q= LegacyNumericRangeQuery.newIntRange("int", Integer.MIN_VALUE, Integer.MAX_VALUE, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newFloatRange("float", null, null, true, true);
+    q= LegacyNumericRangeQuery.newFloatRange("float", null, null, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newFloatRange("float", null, null, false, false);
+    q= LegacyNumericRangeQuery.newFloatRange("float", null, null, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
+    q= LegacyNumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
+    q= LegacyNumericRangeQuery.newFloatRange("float", Float.NEGATIVE_INFINITY, Float.POSITIVE_INFINITY, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
+    q= LegacyNumericRangeQuery.newFloatRange("float", Float.NaN, Float.NaN, true, true);
     topDocs = s.search(q, 10);
-    assertEquals("Score doc count", TestNumericUtils.FLOAT_NANs.length,  topDocs.scoreDocs.length );
+    assertEquals("Score doc count", TestLegacyNumericUtils.FLOAT_NANs.length,  topDocs.scoreDocs.length );
 
     r.close();
     dir.close();
@@ -364,44 +362,44 @@ public class TestNumericRangeQuery32 ext
       }
       final BytesRef lowerBytes, upperBytes;
       BytesRefBuilder b = new BytesRefBuilder();
-      NumericUtils.intToPrefixCodedBytes(lower, 0, b);
+      LegacyNumericUtils.intToPrefixCodedBytes(lower, 0, b);
       lowerBytes = b.toBytesRef();
-      NumericUtils.intToPrefixCodedBytes(upper, 0, b);
+      LegacyNumericUtils.intToPrefixCodedBytes(upper, 0, b);
       upperBytes = b.toBytesRef();
 
       // test inclusive range
-      NumericRangeQuery<Integer> tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
+      LegacyNumericRangeQuery<Integer> tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
       TermRangeQuery cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, true);
       TopDocs tTopDocs = searcher.search(tq, 1);
       TopDocs cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, false);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, false);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, false);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test left exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, true);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, true);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, true);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test right exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, false);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, false);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, false);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
@@ -421,13 +419,13 @@ public class TestNumericRangeQuery32 ext
     int lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
     // test empty enum
     assert lower < upper;
-    assertTrue(0 < countTerms(NumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
-    assertEquals(0, countTerms(NumericRangeQuery.newIntRange("field4", 4, upper, lower, true, true)));
+    assertTrue(0 < countTerms(LegacyNumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
+    assertEquals(0, countTerms(LegacyNumericRangeQuery.newIntRange("field4", 4, upper, lower, true, true)));
     // test empty enum outside of bounds
     lower = distance*noDocs+startOffset;
     upper = 2 * lower;
     assert lower < upper;
-    assertEquals(0, countTerms(NumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
+    assertEquals(0, countTerms(LegacyNumericRangeQuery.newIntRange("field4", 4, lower, upper, true, true)));
   }
   
   private int countTerms(MultiTermQuery q) throws Exception {
@@ -489,19 +487,19 @@ public class TestNumericRangeQuery32 ext
         int a=lower; lower=upper; upper=a;
       }
       // test inclusive range
-      Query tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
+      Query tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, true);
       TopDocs tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
       // test exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, false);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, false);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to exclusive range length", Math.max(upper-lower-1, 0), tTopDocs.totalHits );
       // test left exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, true);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, false, true);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
       // test right exclusive range
-      tq=NumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, false);
+      tq= LegacyNumericRangeQuery.newIntRange(field, precisionStep, lower, upper, true, false);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
     }
@@ -522,13 +520,13 @@ public class TestNumericRangeQuery32 ext
     testRangeSplit(2);
   }
   
-  /** we fake a float test using int2float conversion of NumericUtils */
+  /** we fake a float test using int2float conversion of LegacyNumericUtils */
   private void testFloatRange(int precisionStep) throws Exception {
     final String field="ascfield"+precisionStep;
     final int lower=-1000, upper=+2000;
     
-    Query tq=NumericRangeQuery.newFloatRange(field, precisionStep,
-      NumericUtils.sortableIntToFloat(lower), NumericUtils.sortableIntToFloat(upper), true, true);
+    Query tq= LegacyNumericRangeQuery.newFloatRange(field, precisionStep,
+        LegacyNumericUtils.sortableIntToFloat(lower), LegacyNumericUtils.sortableIntToFloat(upper), true, true);
     TopDocs tTopDocs = searcher.search(tq, 1);
     assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
   }
@@ -550,40 +548,40 @@ public class TestNumericRangeQuery32 ext
   
   @Test
   public void testEqualsAndHash() throws Exception {
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test1", 4, 10, 20, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test2", 4, 10, 20, false, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test3", 4, 10, 20, true, false));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test4", 4, 10, 20, false, false));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test5", 4, 10, null, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test6", 4, null, 20, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newIntRange("test7", 4, null, null, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test1", 4, 10, 20, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test2", 4, 10, 20, false, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test3", 4, 10, 20, true, false));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test4", 4, 10, 20, false, false));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test5", 4, 10, null, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test6", 4, null, 20, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newIntRange("test7", 4, null, null, true, true));
     QueryUtils.checkEqual(
-      NumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true), 
-      NumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true)
+      LegacyNumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newIntRange("test8", 4, 10, 20, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newIntRange("test9", 4, 10, 20, true, true), 
-      NumericRangeQuery.newIntRange("test9", 8, 10, 20, true, true)
+      LegacyNumericRangeQuery.newIntRange("test9", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newIntRange("test9", 8, 10, 20, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newIntRange("test10a", 4, 10, 20, true, true), 
-      NumericRangeQuery.newIntRange("test10b", 4, 10, 20, true, true)
+      LegacyNumericRangeQuery.newIntRange("test10a", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newIntRange("test10b", 4, 10, 20, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newIntRange("test11", 4, 10, 20, true, true), 
-      NumericRangeQuery.newIntRange("test11", 4, 20, 10, true, true)
+      LegacyNumericRangeQuery.newIntRange("test11", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newIntRange("test11", 4, 20, 10, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newIntRange("test12", 4, 10, 20, true, true), 
-      NumericRangeQuery.newIntRange("test12", 4, 10, 20, false, true)
+      LegacyNumericRangeQuery.newIntRange("test12", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newIntRange("test12", 4, 10, 20, false, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newIntRange("test13", 4, 10, 20, true, true), 
-      NumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
+      LegacyNumericRangeQuery.newIntRange("test13", 4, 10, 20, true, true),
+      LegacyNumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
     );
     // the following produces a hash collision, because Long and Integer have the same hashcode, so only test equality:
-    Query q1 = NumericRangeQuery.newIntRange("test14", 4, 10, 20, true, true);
-    Query q2 = NumericRangeQuery.newLongRange("test14", 4, 10L, 20L, true, true);
+    Query q1 = LegacyNumericRangeQuery.newIntRange("test14", 4, 10, 20, true, true);
+    Query q2 = LegacyNumericRangeQuery.newLongRange("test14", 4, 10L, 20L, true, true);
     assertFalse(q1.equals(q2));
     assertFalse(q2.equals(q1));
   }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestNumericRangeQuery64.java Mon Dec 21 11:39:57 2015
@@ -19,25 +19,23 @@ package org.apache.lucene.search;
 
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.DoubleField;
+import org.apache.lucene.document.LegacyDoubleField;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.FieldType;
-import org.apache.lucene.document.LongField;
-import org.apache.lucene.index.LeafReaderContext;
+import org.apache.lucene.document.LegacyLongField;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.MultiFields;
 import org.apache.lucene.index.RandomIndexWriter;
-import org.apache.lucene.index.SlowCompositeReaderWrapper;
 import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.index.Terms;
 import org.apache.lucene.index.TermsEnum;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.BytesRefBuilder;
+import org.apache.lucene.util.LegacyNumericUtils;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util.NumericUtils;
-import org.apache.lucene.util.TestNumericUtils; // NaN arrays
+import org.apache.lucene.util.TestLegacyNumericUtils;
 import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -65,7 +63,7 @@ public class TestNumericRangeQuery64 ext
         .setMaxBufferedDocs(TestUtil.nextInt(random(), 100, 1000))
         .setMergePolicy(newLogMergePolicy()));
 
-    final FieldType storedLong = new FieldType(LongField.TYPE_NOT_STORED);
+    final FieldType storedLong = new FieldType(LegacyLongField.TYPE_NOT_STORED);
     storedLong.setStored(true);
     storedLong.freeze();
 
@@ -84,7 +82,7 @@ public class TestNumericRangeQuery64 ext
     final FieldType storedLongNone = new FieldType(storedLong);
     storedLongNone.setNumericPrecisionStep(Integer.MAX_VALUE);
 
-    final FieldType unstoredLong = LongField.TYPE_NOT_STORED;
+    final FieldType unstoredLong = LegacyLongField.TYPE_NOT_STORED;
 
     final FieldType unstoredLong8 = new FieldType(unstoredLong);
     unstoredLong8.setNumericPrecisionStep(8);
@@ -98,16 +96,16 @@ public class TestNumericRangeQuery64 ext
     final FieldType unstoredLong2 = new FieldType(unstoredLong);
     unstoredLong2.setNumericPrecisionStep(2);
 
-    LongField
-      field8 = new LongField("field8", 0L, storedLong8),
-      field6 = new LongField("field6", 0L, storedLong6),
-      field4 = new LongField("field4", 0L, storedLong4),
-      field2 = new LongField("field2", 0L, storedLong2),
-      fieldNoTrie = new LongField("field"+Integer.MAX_VALUE, 0L, storedLongNone),
-      ascfield8 = new LongField("ascfield8", 0L, unstoredLong8),
-      ascfield6 = new LongField("ascfield6", 0L, unstoredLong6),
-      ascfield4 = new LongField("ascfield4", 0L, unstoredLong4),
-      ascfield2 = new LongField("ascfield2", 0L, unstoredLong2);
+    LegacyLongField
+      field8 = new LegacyLongField("field8", 0L, storedLong8),
+      field6 = new LegacyLongField("field6", 0L, storedLong6),
+      field4 = new LegacyLongField("field4", 0L, storedLong4),
+      field2 = new LegacyLongField("field2", 0L, storedLong2),
+      fieldNoTrie = new LegacyLongField("field"+Integer.MAX_VALUE, 0L, storedLongNone),
+      ascfield8 = new LegacyLongField("ascfield8", 0L, unstoredLong8),
+      ascfield6 = new LegacyLongField("ascfield6", 0L, unstoredLong6),
+      ascfield4 = new LegacyLongField("ascfield4", 0L, unstoredLong4),
+      ascfield2 = new LegacyLongField("ascfield2", 0L, unstoredLong2);
 
     Document doc = new Document();
     // add fields, that have a distance to test general functionality
@@ -158,7 +156,7 @@ public class TestNumericRangeQuery64 ext
     String field="field"+precisionStep;
     int count=3000;
     long lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
-    NumericRangeQuery<Long> q = NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
+    LegacyNumericRangeQuery<Long> q = LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
     for (byte i=0; i<2; i++) {
       TopDocs topDocs;
       String type;
@@ -208,7 +206,7 @@ public class TestNumericRangeQuery64 ext
   
   @Test
   public void testOneMatchQuery() throws Exception {
-    NumericRangeQuery<Long> q = NumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
+    LegacyNumericRangeQuery<Long> q = LegacyNumericRangeQuery.newLongRange("ascfield8", 8, 1000L, 1000L, true, true);
     TopDocs topDocs = searcher.search(q, noDocs);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -219,7 +217,7 @@ public class TestNumericRangeQuery64 ext
     String field="field"+precisionStep;
     int count=3000;
     long upper=(count-1)*distance + (distance/3) + startOffset;
-    NumericRangeQuery<Long> q=NumericRangeQuery.newLongRange(field, precisionStep, null, upper, true, true);
+    LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, null, upper, true, true);
     TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -229,7 +227,7 @@ public class TestNumericRangeQuery64 ext
     doc=searcher.doc(sd[sd.length-1].doc);
     assertEquals("Last doc", (count-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
 
-    q=NumericRangeQuery.newLongRange(field, precisionStep, null, upper, false, true);
+    q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, null, upper, false, true);
     topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -264,7 +262,7 @@ public class TestNumericRangeQuery64 ext
     String field="field"+precisionStep;
     int count=3000;
     long lower=(count-1)*distance + (distance/3) +startOffset;
-    NumericRangeQuery<Long> q=NumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, true);
+    LegacyNumericRangeQuery<Long> q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, true);
     TopDocs topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     ScoreDoc[] sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -274,7 +272,7 @@ public class TestNumericRangeQuery64 ext
     doc=searcher.doc(sd[sd.length-1].doc);
     assertEquals("Last doc", (noDocs-1)*distance+startOffset, doc.getField(field).numericValue().longValue() );
 
-    q=NumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, false);
+    q= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, null, true, false);
     topDocs = searcher.search(q, noDocs, Sort.INDEXORDER);
     sd = topDocs.scoreDocs;
     assertNotNull(sd);
@@ -311,23 +309,23 @@ public class TestNumericRangeQuery64 ext
     RandomIndexWriter writer = new RandomIndexWriter(random(), dir,
       newIndexWriterConfig(new MockAnalyzer(random())));
     Document doc = new Document();
-    doc.add(new DoubleField("double", Double.NEGATIVE_INFINITY, Field.Store.NO));
-    doc.add(new LongField("long", Long.MIN_VALUE, Field.Store.NO));
+    doc.add(new LegacyDoubleField("double", Double.NEGATIVE_INFINITY, Field.Store.NO));
+    doc.add(new LegacyLongField("long", Long.MIN_VALUE, Field.Store.NO));
     writer.addDocument(doc);
     
     doc = new Document();
-    doc.add(new DoubleField("double", Double.POSITIVE_INFINITY, Field.Store.NO));
-    doc.add(new LongField("long", Long.MAX_VALUE, Field.Store.NO));
+    doc.add(new LegacyDoubleField("double", Double.POSITIVE_INFINITY, Field.Store.NO));
+    doc.add(new LegacyLongField("long", Long.MAX_VALUE, Field.Store.NO));
     writer.addDocument(doc);
     
     doc = new Document();
-    doc.add(new DoubleField("double", 0.0, Field.Store.NO));
-    doc.add(new LongField("long", 0L, Field.Store.NO));
+    doc.add(new LegacyDoubleField("double", 0.0, Field.Store.NO));
+    doc.add(new LegacyLongField("long", 0L, Field.Store.NO));
     writer.addDocument(doc);
     
-    for (double d : TestNumericUtils.DOUBLE_NANs) {
+    for (double d : TestLegacyNumericUtils.DOUBLE_NANs) {
       doc = new Document();
-      doc.add(new DoubleField("double", d, Field.Store.NO));
+      doc.add(new LegacyDoubleField("double", d, Field.Store.NO));
       writer.addDocument(doc);
     }
     
@@ -336,41 +334,41 @@ public class TestNumericRangeQuery64 ext
     IndexReader r = DirectoryReader.open(dir);
     IndexSearcher s = newSearcher(r);
     
-    Query q=NumericRangeQuery.newLongRange("long", null, null, true, true);
+    Query q= LegacyNumericRangeQuery.newLongRange("long", null, null, true, true);
     TopDocs topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
     
-    q=NumericRangeQuery.newLongRange("long", null, null, false, false);
+    q= LegacyNumericRangeQuery.newLongRange("long", null, null, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, true, true);
+    q= LegacyNumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
     
-    q=NumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, false, false);
+    q= LegacyNumericRangeQuery.newLongRange("long", Long.MIN_VALUE, Long.MAX_VALUE, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newDoubleRange("double", null, null, true, true);
+    q= LegacyNumericRangeQuery.newDoubleRange("double", null, null, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newDoubleRange("double", null, null, false, false);
+    q= LegacyNumericRangeQuery.newDoubleRange("double", null, null, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true, true);
+    q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, true, true);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 3,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, false);
+    q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, false, false);
     topDocs = s.search(q, 10);
     assertEquals("Score doc count", 1,  topDocs.scoreDocs.length );
 
-    q=NumericRangeQuery.newDoubleRange("double", Double.NaN, Double.NaN, true, true);
+    q= LegacyNumericRangeQuery.newDoubleRange("double", Double.NaN, Double.NaN, true, true);
     topDocs = s.search(q, 10);
-    assertEquals("Score doc count", TestNumericUtils.DOUBLE_NANs.length,  topDocs.scoreDocs.length );
+    assertEquals("Score doc count", TestLegacyNumericUtils.DOUBLE_NANs.length,  topDocs.scoreDocs.length );
 
     r.close();
     dir.close();
@@ -388,44 +386,44 @@ public class TestNumericRangeQuery64 ext
       }
       final BytesRef lowerBytes, upperBytes;
       BytesRefBuilder b = new BytesRefBuilder();
-      NumericUtils.longToPrefixCodedBytes(lower, 0, b);
+      LegacyNumericUtils.longToPrefixCodedBytes(lower, 0, b);
       lowerBytes = b.toBytesRef();
-      NumericUtils.longToPrefixCodedBytes(upper, 0, b);
+      LegacyNumericUtils.longToPrefixCodedBytes(upper, 0, b);
       upperBytes = b.toBytesRef();
       
       // test inclusive range
-      NumericRangeQuery<Long> tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
+      LegacyNumericRangeQuery<Long> tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
       TermRangeQuery cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, true);
       TopDocs tTopDocs = searcher.search(tq, 1);
       TopDocs cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, false);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test left exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, false, true);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
       // test right exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
       cq=new TermRangeQuery(field, lowerBytes, upperBytes, true, false);
       tTopDocs = searcher.search(tq, 1);
       cTopDocs = searcher.search(cq, 1);
-      assertEquals("Returned count for NumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
+      assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", cTopDocs.totalHits, tTopDocs.totalHits );
       totalTermCountT += termCountT = countTerms(tq);
       totalTermCountC += termCountC = countTerms(cq);
       checkTermCounts(precisionStep, termCountT, termCountC);
@@ -445,13 +443,13 @@ public class TestNumericRangeQuery64 ext
     long lower=(distance*3/2)+startOffset, upper=lower + count*distance + (distance/3);
     // test empty enum
     assert lower < upper;
-    assertTrue(0 < countTerms(NumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
-    assertEquals(0, countTerms(NumericRangeQuery.newLongRange("field4", 4, upper, lower, true, true)));
+    assertTrue(0 < countTerms(LegacyNumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
+    assertEquals(0, countTerms(LegacyNumericRangeQuery.newLongRange("field4", 4, upper, lower, true, true)));
     // test empty enum outside of bounds
     lower = distance*noDocs+startOffset;
     upper = 2L * lower;
     assert lower < upper;
-    assertEquals(0, countTerms(NumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
+    assertEquals(0, countTerms(LegacyNumericRangeQuery.newLongRange("field4", 4, lower, upper, true, true)));
   }
   
   private int countTerms(MultiTermQuery q) throws Exception {
@@ -518,19 +516,19 @@ public class TestNumericRangeQuery64 ext
         long a=lower; lower=upper; upper=a;
       }
       // test inclusive range
-      Query tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
+      Query tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, true);
       TopDocs tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
       // test exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, false);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to exclusive range length", Math.max(upper-lower-1, 0), tTopDocs.totalHits );
       // test left exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, false, true);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
       // test right exclusive range
-      tq=NumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
+      tq= LegacyNumericRangeQuery.newLongRange(field, precisionStep, lower, upper, true, false);
       tTopDocs = searcher.search(tq, 1);
       assertEquals("Returned count of range query must be equal to half exclusive range length", upper-lower, tTopDocs.totalHits );
     }
@@ -556,13 +554,13 @@ public class TestNumericRangeQuery64 ext
     testRangeSplit(2);
   }
   
-  /** we fake a double test using long2double conversion of NumericUtils */
+  /** we fake a double test using long2double conversion of LegacyNumericUtils */
   private void testDoubleRange(int precisionStep) throws Exception {
     final String field="ascfield"+precisionStep;
     final long lower=-1000L, upper=+2000L;
     
-    Query tq=NumericRangeQuery.newDoubleRange(field, precisionStep,
-      NumericUtils.sortableLongToDouble(lower), NumericUtils.sortableLongToDouble(upper), true, true);
+    Query tq= LegacyNumericRangeQuery.newDoubleRange(field, precisionStep,
+        LegacyNumericUtils.sortableLongToDouble(lower), LegacyNumericUtils.sortableLongToDouble(upper), true, true);
     TopDocs tTopDocs = searcher.search(tq, 1);
     assertEquals("Returned count of range query must be equal to inclusive range length", upper-lower+1, tTopDocs.totalHits );
   }
@@ -589,36 +587,36 @@ public class TestNumericRangeQuery64 ext
   
   @Test
   public void testEqualsAndHash() throws Exception {
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test1", 4, 10L, 20L, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test2", 4, 10L, 20L, false, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test3", 4, 10L, 20L, true, false));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test4", 4, 10L, 20L, false, false));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test5", 4, 10L, null, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test6", 4, null, 20L, true, true));
-    QueryUtils.checkHashEquals(NumericRangeQuery.newLongRange("test7", 4, null, null, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test1", 4, 10L, 20L, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test2", 4, 10L, 20L, false, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test3", 4, 10L, 20L, true, false));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test4", 4, 10L, 20L, false, false));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test5", 4, 10L, null, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test6", 4, null, 20L, true, true));
+    QueryUtils.checkHashEquals(LegacyNumericRangeQuery.newLongRange("test7", 4, null, null, true, true));
     QueryUtils.checkEqual(
-      NumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true)
+      LegacyNumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newLongRange("test8", 4, 10L, 20L, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newLongRange("test9", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newLongRange("test9", 8, 10L, 20L, true, true)
+      LegacyNumericRangeQuery.newLongRange("test9", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newLongRange("test9", 8, 10L, 20L, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newLongRange("test10a", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newLongRange("test10b", 4, 10L, 20L, true, true)
+      LegacyNumericRangeQuery.newLongRange("test10a", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newLongRange("test10b", 4, 10L, 20L, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newLongRange("test11", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newLongRange("test11", 4, 20L, 10L, true, true)
+      LegacyNumericRangeQuery.newLongRange("test11", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newLongRange("test11", 4, 20L, 10L, true, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newLongRange("test12", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newLongRange("test12", 4, 10L, 20L, false, true)
+      LegacyNumericRangeQuery.newLongRange("test12", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newLongRange("test12", 4, 10L, 20L, false, true)
     );
     QueryUtils.checkUnequal(
-      NumericRangeQuery.newLongRange("test13", 4, 10L, 20L, true, true), 
-      NumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
+      LegacyNumericRangeQuery.newLongRange("test13", 4, 10L, 20L, true, true),
+      LegacyNumericRangeQuery.newFloatRange("test13", 4, 10f, 20f, true, true)
     );
      // difference to int range is tested in TestNumericRangeQuery32
   }

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPhraseQuery.java Mon Dec 21 11:39:57 2015
@@ -23,19 +23,23 @@ import java.util.List;
 import java.util.Random;
 
 import org.apache.lucene.analysis.Analyzer;
+import org.apache.lucene.analysis.CannedTokenStream;
 import org.apache.lucene.analysis.MockAnalyzer;
 import org.apache.lucene.analysis.MockTokenFilter;
 import org.apache.lucene.analysis.MockTokenizer;
+import org.apache.lucene.analysis.Token;
 import org.apache.lucene.analysis.TokenStream;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
+import org.apache.lucene.document.TextField;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriterConfig.OpenMode;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.search.similarities.ClassicSimilarity;
 import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
@@ -549,6 +553,52 @@ public class TestPhraseQuery extends Luc
     assertTrue(rewritten instanceof TermQuery);
   }
 
+  /** Tests PhraseQuery with terms at the same position in the query. */
+  public void testZeroPosIncr() throws IOException {
+    Directory dir = newDirectory();
+    final Token[] tokens = new Token[3];
+    tokens[0] = new Token();
+    tokens[0].append("a");
+    tokens[0].setPositionIncrement(1);
+    tokens[1] = new Token();
+    tokens[1].append("aa");
+    tokens[1].setPositionIncrement(0);
+    tokens[2] = new Token();
+    tokens[2].append("b");
+    tokens[2].setPositionIncrement(1);
+
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir);
+    Document doc = new Document();
+    doc.add(new TextField("field", new CannedTokenStream(tokens)));
+    writer.addDocument(doc);
+    IndexReader r = writer.getReader();
+    writer.close();
+    IndexSearcher searcher = newSearcher(r);
+
+    // Sanity check; simple "a b" phrase:
+    PhraseQuery.Builder pqBuilder = new PhraseQuery.Builder();
+    pqBuilder.add(new Term("field", "a"), 0);
+    pqBuilder.add(new Term("field", "b"), 1);
+    assertEquals(1, searcher.search(pqBuilder.build(), 1).totalHits);
+
+    // Now with "a|aa b"
+    pqBuilder = new PhraseQuery.Builder();
+    pqBuilder.add(new Term("field", "a"), 0);
+    pqBuilder.add(new Term("field", "aa"), 0);
+    pqBuilder.add(new Term("field", "b"), 1);
+    assertEquals(1, searcher.search(pqBuilder.build(), 1).totalHits);
+
+    // Now with "a|z b" which should not match; this isn't a MultiPhraseQuery
+    pqBuilder = new PhraseQuery.Builder();
+    pqBuilder.add(new Term("field", "a"), 0);
+    pqBuilder.add(new Term("field", "z"), 0);
+    pqBuilder.add(new Term("field", "b"), 1);
+    assertEquals(0, searcher.search(pqBuilder.build(), 1).totalHits);
+
+    r.close();
+    dir.close();
+  }
+
   public void testRandomPhrases() throws Exception {
     Directory dir = newDirectory();
     Analyzer analyzer = new MockAnalyzer(random());

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositionIncrement.java Mon Dec 21 11:39:57 2015
@@ -42,9 +42,9 @@ import org.apache.lucene.search.spans.Mu
 import org.apache.lucene.search.spans.SpanCollector;
 import org.apache.lucene.search.spans.SpanNearQuery;
 import org.apache.lucene.search.spans.SpanQuery;
+import org.apache.lucene.search.spans.Spans;
 import org.apache.lucene.search.spans.SpanTermQuery;
 import org.apache.lucene.search.spans.SpanWeight;
-import org.apache.lucene.search.spans.Spans;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestPositiveScoresOnlyCollector.java Mon Dec 21 11:39:57 2015
@@ -43,19 +43,29 @@ public class TestPositiveScoresOnlyColle
 
     @Override public int docID() { return idx; }
 
-    @Override public int nextDoc() {
-      return ++idx != scores.length ? idx : NO_MORE_DOCS;
-    }
-    
-    @Override public int advance(int target) {
-      idx = target;
-      return idx < scores.length ? idx : NO_MORE_DOCS;
-    }
-
     @Override
-    public long cost() {
-      return scores.length;
-    } 
+    public DocIdSetIterator iterator() {
+      return new DocIdSetIterator() {
+        @Override
+        public int docID() {
+          return idx;
+        }
+
+        @Override public int nextDoc() {
+          return ++idx != scores.length ? idx : NO_MORE_DOCS;
+        }
+        
+        @Override public int advance(int target) {
+          idx = target;
+          return idx < scores.length ? idx : NO_MORE_DOCS;
+        }
+
+        @Override
+        public long cost() {
+          return scores.length;
+        } 
+      };
+    }
   }
 
   // The scores must have positive as well as negative values
@@ -90,7 +100,7 @@ public class TestPositiveScoresOnlyColle
     Collector c = new PositiveScoresOnlyCollector(tdc);
     LeafCollector ac = c.getLeafCollector(ir.leaves().get(0));
     ac.setScorer(s);
-    while (s.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+    while (s.iterator().nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
       ac.collect(0);
     }
     TopDocs td = tdc.topDocs();

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestQueryRescorer.java Mon Dec 21 11:39:57 2015
@@ -446,23 +446,34 @@ public class TestQueryRescorer extends L
             }
 
             @Override
-            public long cost() {
-              return 1;
-            }
+            public DocIdSetIterator iterator() {
+              return new DocIdSetIterator() {
 
-            @Override
-            public int nextDoc() {
-              docID++;
-              if (docID >= context.reader().maxDoc()) {
-                return NO_MORE_DOCS;
-              }
-              return docID;
-            }
+                @Override
+                public int docID() {
+                  return docID;
+                }
 
-            @Override
-            public int advance(int target) {
-              docID = target;
-              return docID;
+                @Override
+                public long cost() {
+                  return 1;
+                }
+
+                @Override
+                public int nextDoc() {
+                  docID++;
+                  if (docID >= context.reader().maxDoc()) {
+                    return NO_MORE_DOCS;
+                  }
+                  return docID;
+                }
+
+                @Override
+                public int advance(int target) {
+                  docID = target;
+                  return docID;
+                }
+              };
             }
 
             @Override

Modified: lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java?rev=1721134&r1=1721133&r2=1721134&view=diff
==============================================================================
--- lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java (original)
+++ lucene/dev/branches/lucene6835/lucene/core/src/test/org/apache/lucene/search/TestScoreCachingWrappingScorer.java Mon Dec 21 11:39:57 2015
@@ -49,18 +49,25 @@ public class TestScoreCachingWrappingSco
 
     @Override public int docID() { return doc; }
 
-    @Override public int nextDoc() {
-      return ++doc < scores.length ? doc : NO_MORE_DOCS;
-    }
-    
-    @Override public int advance(int target) {
-      doc = target;
-      return doc < scores.length ? doc : NO_MORE_DOCS;
-    }
-
     @Override
-    public long cost() {
-      return scores.length;
+    public DocIdSetIterator iterator() {
+      return new DocIdSetIterator() {
+        @Override public int docID() { return doc; }
+
+        @Override public int nextDoc() {
+          return ++doc < scores.length ? doc : NO_MORE_DOCS;
+        }
+        
+        @Override public int advance(int target) {
+          doc = target;
+          return doc < scores.length ? doc : NO_MORE_DOCS;
+        }
+
+        @Override
+        public long cost() {
+          return scores.length;
+        }
+      };
     }
   }
   
@@ -116,7 +123,7 @@ public class TestScoreCachingWrappingSco
     
     // We need to iterate on the scorer so that its doc() advances.
     int doc;
-    while ((doc = s.nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
+    while ((doc = s.iterator().nextDoc()) != DocIdSetIterator.NO_MORE_DOCS) {
       scc.collect(doc);
     }