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/02/26 15:44:12 UTC

svn commit: r1572063 [12/22] - in /lucene/dev/branches/lucene5376: ./ dev-tools/ dev-tools/idea/.idea/ dev-tools/idea/lucene/sandbox/ dev-tools/idea/solr/contrib/morphlines-core/ dev-tools/maven/lucene/ dev-tools/maven/lucene/core/src/java/ dev-tools/m...

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/java/org/apache/lucene/queries/ChainedFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/java/org/apache/lucene/queries/ChainedFilter.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/java/org/apache/lucene/queries/ChainedFilter.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/java/org/apache/lucene/queries/ChainedFilter.java Wed Feb 26 14:43:56 2014
@@ -17,6 +17,8 @@ package org.apache.lucene.queries;
  * limitations under the License.
  */
 
+import java.io.IOException;
+
 import org.apache.lucene.index.AtomicReader;
 import org.apache.lucene.index.AtomicReaderContext;
 import org.apache.lucene.search.BitsFilteredDocIdSet;
@@ -24,10 +26,7 @@ import org.apache.lucene.search.DocIdSet
 import org.apache.lucene.search.DocIdSetIterator;
 import org.apache.lucene.search.Filter;
 import org.apache.lucene.util.Bits;
-import org.apache.lucene.util.OpenBitSet;
-import org.apache.lucene.util.OpenBitSetDISI;
-
-import java.io.IOException;
+import org.apache.lucene.util.FixedBitSet;
 
 /**
  * <p>
@@ -127,23 +126,17 @@ public class ChainedFilter extends Filte
     }
   }
 
-  private OpenBitSetDISI initialResult(AtomicReaderContext context, int logic, int[] index)
+  private FixedBitSet initialResult(AtomicReaderContext context, int logic, int[] index)
       throws IOException {
     AtomicReader reader = context.reader();
-    OpenBitSetDISI result;
-    /**
-     * First AND operation takes place against a completely false
-     * bitset and will always return zero results.
-     */
+    FixedBitSet result = new FixedBitSet(reader.maxDoc());
     if (logic == AND) {
-      result = new OpenBitSetDISI(getDISI(chain[index[0]], context), reader.maxDoc());
+      result.or(getDISI(chain[index[0]], context));
       ++index[0];
     } else if (logic == ANDNOT) {
-      result = new OpenBitSetDISI(getDISI(chain[index[0]], context), reader.maxDoc());
+      result.or(getDISI(chain[index[0]], context));
       result.flip(0, reader.maxDoc()); // NOTE: may set bits for deleted docs.
       ++index[0];
-    } else {
-      result = new OpenBitSetDISI(reader.maxDoc());
     }
     return result;
   }
@@ -157,7 +150,7 @@ public class ChainedFilter extends Filte
    */
   private DocIdSet getDocIdSet(AtomicReaderContext context, int logic, int[] index)
       throws IOException {
-    OpenBitSetDISI result = initialResult(context, logic, index);
+    FixedBitSet result = initialResult(context, logic, index);
     for (; index[0] < chain.length; index[0]++) {
       // we dont pass acceptDocs, we will filter at the end using an additional filter
       doChain(result, logic, chain[index[0]].getDocIdSet(context, null));
@@ -178,7 +171,7 @@ public class ChainedFilter extends Filte
       throw new IllegalArgumentException("Invalid number of elements in logic array");
     }
 
-    OpenBitSetDISI result = initialResult(context, logic[0], index);
+    FixedBitSet result = initialResult(context, logic[0], index);
     for (; index[0] < chain.length; index[0]++) {
       // we dont pass acceptDocs, we will filter at the end using an additional filter
       doChain(result, logic[index[0]], chain[index[0]].getDocIdSet(context, null));
@@ -198,23 +191,21 @@ public class ChainedFilter extends Filte
     return sb.toString();
   }
 
-  private void doChain(OpenBitSetDISI result, int logic, DocIdSet dis)
-      throws IOException {
-
-    if (dis instanceof OpenBitSet) {
-      // optimized case for OpenBitSets
+  private void doChain(FixedBitSet result, int logic, DocIdSet dis) throws IOException {
+    if (dis instanceof FixedBitSet) {
+      // optimized case for FixedBitSets
       switch (logic) {
         case OR:
-          result.or((OpenBitSet) dis);
+          result.or((FixedBitSet) dis);
           break;
         case AND:
-          result.and((OpenBitSet) dis);
+          result.and((FixedBitSet) dis);
           break;
         case ANDNOT:
-          result.andNot((OpenBitSet) dis);
+          result.andNot((FixedBitSet) dis);
           break;
         case XOR:
-          result.xor((OpenBitSet) dis);
+          result.xor((FixedBitSet) dis);
           break;
         default:
           doChain(result, DEFAULT, dis);
@@ -233,16 +224,16 @@ public class ChainedFilter extends Filte
 
       switch (logic) {
         case OR:
-          result.inPlaceOr(disi);
+          result.or(disi);
           break;
         case AND:
-          result.inPlaceAnd(disi);
+          result.and(disi);
           break;
         case ANDNOT:
-          result.inPlaceNot(disi);
+          result.andNot(disi);
           break;
         case XOR:
-          result.inPlaceXor(disi);
+          result.xor(disi);
           break;
         default:
           doChain(result, DEFAULT, dis);

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java Wed Feb 26 14:43:56 2014
@@ -48,7 +48,8 @@ import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.PriorityQueue;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
 
 public class CommonTermsQueryTest extends LuceneTestCase {
   
@@ -130,8 +131,8 @@ public class CommonTermsQueryTest extend
         randomOccur(random()), random().nextFloat(), random().nextBoolean());
     int terms = atLeast(2);
     for (int i = 0; i < terms; i++) {
-      query.add(new Term(_TestUtil.randomRealisticUnicodeString(random()),
-          _TestUtil.randomRealisticUnicodeString(random())));
+      query.add(new Term(TestUtil.randomRealisticUnicodeString(random()),
+          TestUtil.randomRealisticUnicodeString(random())));
     }
     QueryUtils.checkHashEquals(query);
     QueryUtils.checkUnequal(new CommonTermsQuery(randomOccur(random()),
@@ -145,7 +146,7 @@ public class CommonTermsQueryTest extend
           randomOccur(r), r.nextFloat(), r.nextBoolean());
       int leftTerms = atLeast(r, 2);
       for (int i = 0; i < leftTerms; i++) {
-        left.add(new Term(_TestUtil.randomRealisticUnicodeString(r), _TestUtil
+        left.add(new Term(TestUtil.randomRealisticUnicodeString(r), TestUtil
             .randomRealisticUnicodeString(r)));
       }
       left.setHighFreqMinimumNumberShouldMatch(r.nextInt(4));
@@ -156,7 +157,7 @@ public class CommonTermsQueryTest extend
           randomOccur(r), r.nextFloat(), r.nextBoolean());
       int rightTerms = atLeast(r, 2);
       for (int i = 0; i < rightTerms; i++) {
-        right.add(new Term(_TestUtil.randomRealisticUnicodeString(r), _TestUtil
+        right.add(new Term(TestUtil.randomRealisticUnicodeString(r), TestUtil
             .randomRealisticUnicodeString(r)));
       }
       right.setHighFreqMinimumNumberShouldMatch(r.nextInt(4));

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermFilterTest.java Wed Feb 26 14:43:56 2014
@@ -34,7 +34,7 @@ import org.apache.lucene.search.TermQuer
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 
 import java.io.IOException;
 import java.util.ArrayList;
@@ -87,7 +87,7 @@ public class TermFilterTest extends Luce
     List<Term> terms = new ArrayList<Term>();
     for (int i = 0; i < num; i++) {
       String field = "field" + i;
-      String string = _TestUtil.randomRealisticUnicodeString(random());
+      String string = TestUtil.randomRealisticUnicodeString(random());
       terms.add(new Term(field, string));
       Document doc = new Document();
       doc.add(newStringField(field, string, Field.Store.NO));
@@ -122,7 +122,7 @@ public class TermFilterTest extends Luce
     for (int i = 0; i < num; i++) {
       String field1 = "field" + i;
       String field2 = "field" + i + num;
-      String value1 = _TestUtil.randomRealisticUnicodeString(random());
+      String value1 = TestUtil.randomRealisticUnicodeString(random());
       String value2 = value1 + "x"; // this must be not equal to value1
 
       TermFilter filter1 = termFilter(field1, value1);

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/TermsFilterTest.java Wed Feb 26 14:43:56 2014
@@ -49,7 +49,8 @@ import org.apache.lucene.store.Directory
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.FixedBitSet;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
 
 public class TermsFilterTest extends LuceneTestCase {
 
@@ -213,7 +214,7 @@ public class TermsFilterTest extends Luc
     List<Term> terms = new ArrayList<Term>();
     for (int i = 0; i < num; i++) {
       String field = "field" + (singleField ? "1" : random().nextInt(100));
-      String string = _TestUtil.randomRealisticUnicodeString(random());
+      String string = TestUtil.randomRealisticUnicodeString(random());
       terms.add(new Term(field, string));
       Document doc = new Document();
       doc.add(newStringField(field, string, Field.Store.YES));
@@ -279,7 +280,7 @@ public class TermsFilterTest extends Luc
     Set<Term> uniqueTerms = new HashSet<Term>();
     for (int i = 0; i < num; i++) {
       String field = "field" + (singleField ? "1" : random().nextInt(100));
-      String string = _TestUtil.randomRealisticUnicodeString(random());
+      String string = TestUtil.randomRealisticUnicodeString(random());
       terms.add(new Term(field, string));
       uniqueTerms.add(new Term(field, string));
       TermsFilter left = termsFilter(singleField ? random().nextBoolean() : false, uniqueTerms);

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/FunctionTestSetup.java Wed Feb 26 14:43:56 2014
@@ -21,7 +21,7 @@ import org.apache.lucene.search.FieldCac
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.Ignore;
 
@@ -113,7 +113,7 @@ public abstract class FunctionTestSetup 
     anlzr = new MockAnalyzer(random());
     IndexWriterConfig iwc = newIndexWriterConfig( TEST_VERSION_CURRENT, anlzr).setMergePolicy(newLogMergePolicy());
     if (doMultiSegment) {
-      iwc.setMaxBufferedDocs(_TestUtil.nextInt(random(), 2, 7));
+      iwc.setMaxBufferedDocs(TestUtil.nextInt(random(), 2, 7));
     }
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
     // add docs not exactly in natural ID order, to verify we do check the order of docs by scores

Modified: lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queries/src/test/org/apache/lucene/queries/function/TestDocValuesFieldSources.java Wed Feb 26 14:43:56 2014
@@ -35,7 +35,8 @@ import org.apache.lucene.queries.functio
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.packed.PackedInts;
 
 import com.carrotsearch.randomizedtesting.generators.RandomInts;
@@ -75,7 +76,7 @@ public class TestDocValuesFieldSources e
         case SORTED:
         case BINARY:
           do {
-            vals[i] = _TestUtil.randomSimpleString(random(), 20);
+            vals[i] = TestUtil.randomSimpleString(random(), 20);
           } while (((String) vals[i]).isEmpty());
           f.setBytesValue(new BytesRef((String) vals[i]));
           break;

Modified: lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/flexible/standard/TestNumericQueryParser.java Wed Feb 26 14:43:56 2014
@@ -52,7 +52,7 @@ import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -190,7 +190,7 @@ public class TestNumericQueryParser exte
     directory = newDirectory();
     RandomIndexWriter writer = new RandomIndexWriter(random(), directory,
         newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
-            .setMaxBufferedDocs(_TestUtil.nextInt(random(), 50, 1000))
+            .setMaxBufferedDocs(TestUtil.nextInt(random(), 50, 1000))
             .setMergePolicy(newLogMergePolicy()));
     
     Document doc = new Document();

Modified: lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java (original)
+++ lucene/dev/branches/lucene5376/lucene/queryparser/src/test/org/apache/lucene/queryparser/simple/TestSimpleQueryParser.java Wed Feb 26 14:43:56 2014
@@ -34,7 +34,8 @@ import org.apache.lucene.search.PrefixQu
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.automaton.LevenshteinAutomata;
 
 import static org.apache.lucene.queryparser.simple.SimpleQueryParser.AND_OPERATOR;
@@ -623,9 +624,9 @@ public class TestSimpleQueryParser exten
   // we aren't supposed to barf on any input...
   public void testRandomQueries() throws Exception {
     for (int i = 0; i < 1000; i++) {
-      String query = _TestUtil.randomUnicodeString(random());
+      String query = TestUtil.randomUnicodeString(random());
       parse(query); // no exception
-      parseKeyword(query, _TestUtil.nextInt(random(), 0, 1024)); // no exception
+      parseKeyword(query, TestUtil.nextInt(random(), 0, 1024)); // no exception
     }
   }
 
@@ -639,7 +640,7 @@ public class TestSimpleQueryParser exten
         sb.append(chars[random().nextInt(chars.length)]);
       }
       parse(sb.toString()); // no exception
-      parseKeyword(sb.toString(), _TestUtil.nextInt(random(), 0, 1024)); // no exception
+      parseKeyword(sb.toString(), TestUtil.nextInt(random(), 0, 1024)); // no exception
     }
   }
 }
\ No newline at end of file

Modified: lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexAndTaxonomyReplicationClientTest.java Wed Feb 26 14:43:56 2014
@@ -48,8 +48,8 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.util._TestUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -91,7 +91,7 @@ public class IndexAndTaxonomyReplication
         indexReader.close();
         indexReader = newReader;
         lastIndexGeneration = newGeneration;
-        _TestUtil.checkIndex(indexDir);
+        TestUtil.checkIndex(indexDir);
         
         // verify taxonomy index
         DirectoryTaxonomyReader newTaxoReader = TaxonomyReader.openIfChanged(taxoReader);
@@ -99,7 +99,7 @@ public class IndexAndTaxonomyReplication
           taxoReader.close();
           taxoReader = newTaxoReader;
         }
-        _TestUtil.checkIndex(taxoDir);
+        TestUtil.checkIndex(taxoDir);
         
         // verify faceted search
         int id = Integer.parseInt(indexReader.getIndexCommit().getUserData().get(VERSION_ID), 16);
@@ -191,7 +191,7 @@ public class IndexAndTaxonomyReplication
     publishTaxoDir = newDirectory();
     handlerIndexDir = newMockDirectory();
     handlerTaxoDir = newMockDirectory();
-    clientWorkDir = _TestUtil.getTempDir("replicationClientTest");
+    clientWorkDir = TestUtil.getTempDir("replicationClientTest");
     sourceDirFactory = new PerSessionDirectoryFactory(clientWorkDir);
     replicator = new LocalReplicator();
     callback = new IndexAndTaxonomyReadyCallback(handlerIndexDir, handlerTaxoDir);
@@ -399,11 +399,11 @@ public class IndexAndTaxonomyReplication
               reader.close();
             }
             // verify index is fully consistent
-            _TestUtil.checkIndex(handlerIndexDir.getDelegate());
+            TestUtil.checkIndex(handlerIndexDir.getDelegate());
             
             // verify taxonomy index is fully consistent (since we only add one
             // category to all documents, there's nothing much more to validate
-            _TestUtil.checkIndex(handlerTaxoDir.getDelegate());
+            TestUtil.checkIndex(handlerTaxoDir.getDelegate());
           } catch (IOException e) {
             throw new RuntimeException(e);
           } finally {

Modified: lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/IndexReplicationClientTest.java Wed Feb 26 14:43:56 2014
@@ -33,8 +33,8 @@ import org.apache.lucene.replicator.Repl
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.MockDirectoryWrapper;
 import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.ThreadInterruptedException;
-import org.apache.lucene.util._TestUtil;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
@@ -68,7 +68,7 @@ public class IndexReplicationClientTest 
         reader.close();
         reader = newReader;
         lastGeneration = newGeneration;
-        _TestUtil.checkIndex(indexDir);
+        TestUtil.checkIndex(indexDir);
       }
       return null;
     }
@@ -136,7 +136,7 @@ public class IndexReplicationClientTest 
     super.setUp();
     publishDir = newMockDirectory();
     handlerDir = newMockDirectory();
-    sourceDirFactory = new PerSessionDirectoryFactory(_TestUtil.getTempDir("replicationClientTest"));
+    sourceDirFactory = new PerSessionDirectoryFactory(TestUtil.getTempDir("replicationClientTest"));
     replicator = new LocalReplicator();
     callback = new IndexReadyCallback(handlerDir);
     handler = new IndexReplicationHandler(handlerDir, callback);
@@ -305,7 +305,7 @@ public class IndexReplicationClientTest 
               reader.close();
             }
             // verify index consistency
-            _TestUtil.checkIndex(handlerDir.getDelegate());
+            TestUtil.checkIndex(handlerDir.getDelegate());
           } catch (IOException e) {
             // exceptions here are bad, don't ignore them
             throw new RuntimeException(e);

Modified: lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/replicator/src/test/org/apache/lucene/replicator/http/HttpReplicatorTest.java Wed Feb 26 14:43:56 2014
@@ -35,7 +35,7 @@ import org.apache.lucene.replicator.Repl
 import org.apache.lucene.replicator.ReplicatorTestCase;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.servlet.ServletHandler;
 import org.eclipse.jetty.servlet.ServletHolder;
@@ -68,7 +68,7 @@ public class HttpReplicatorTest extends 
   public void setUp() throws Exception {
     super.setUp();
     System.setProperty("org.eclipse.jetty.LEVEL", "DEBUG"); // sets stderr logging to DEBUG level
-    clientWorkDir = _TestUtil.getTempDir("httpReplicatorTest");
+    clientWorkDir = TestUtil.getTempDir("httpReplicatorTest");
     handlerIndexDir = newDirectory();
     serverIndexDir = newDirectory();
     serverReplicator = new LocalReplicator();

Modified: lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/DuplicateFilterTest.java Wed Feb 26 14:43:56 2014
@@ -31,7 +31,7 @@ import org.apache.lucene.search.TermQuer
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 
 public class DuplicateFilterTest extends LuceneTestCase {
   private static final String KEY_FIELD = "url";
@@ -134,12 +134,12 @@ public class DuplicateFilterTest extends
     for (ScoreDoc hit : hits) {
       StoredDocument d = searcher.doc(hit.doc);
       String url = d.get(KEY_FIELD);
-      DocsEnum td = _TestUtil.docs(random(), reader,
-                                   KEY_FIELD,
-                                   new BytesRef(url),
-                                   MultiFields.getLiveDocs(reader),
-                                   null,
-                                   0);
+      DocsEnum td = TestUtil.docs(random(), reader,
+          KEY_FIELD,
+          new BytesRef(url),
+          MultiFields.getLiveDocs(reader),
+          null,
+          0);
 
       int lastDoc = 0;
       while (td.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
@@ -158,12 +158,12 @@ public class DuplicateFilterTest extends
     for (ScoreDoc hit : hits) {
       StoredDocument d = searcher.doc(hit.doc);
       String url = d.get(KEY_FIELD);
-      DocsEnum td = _TestUtil.docs(random(), reader,
-                                   KEY_FIELD,
-                                   new BytesRef(url),
-                                   MultiFields.getLiveDocs(reader),
-                                   null,
-                                   0);
+      DocsEnum td = TestUtil.docs(random(), reader,
+          KEY_FIELD,
+          new BytesRef(url),
+          MultiFields.getLiveDocs(reader),
+          null,
+          0);
 
       int lastDoc = 0;
       td.nextDoc();

Modified: lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java (original)
+++ lucene/dev/branches/lucene5376/lucene/sandbox/src/test/org/apache/lucene/sandbox/queries/TestSlowCollationMethods.java Wed Feb 26 14:43:56 2014
@@ -11,7 +11,7 @@ import org.apache.lucene.search.*;
 import org.apache.lucene.search.BooleanClause.Occur;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 
@@ -55,12 +55,12 @@ public class TestSlowCollationMethods ex
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     for (int i = 0; i < numDocs; i++) {
       Document doc = new Document();
-      String value = _TestUtil.randomUnicodeString(random());
+      String value = TestUtil.randomUnicodeString(random());
       Field field = newStringField("field", value, Field.Store.YES);
       doc.add(field);
       iw.addDocument(doc);
     }
-    splitDoc = _TestUtil.randomUnicodeString(random());
+    splitDoc = TestUtil.randomUnicodeString(random());
     reader = iw.getReader();
     iw.close();
 
@@ -130,8 +130,8 @@ public class TestSlowCollationMethods ex
   public void testRangeQuery() throws Exception {
     int numQueries = 50*RANDOM_MULTIPLIER;
     for (int i = 0; i < numQueries; i++) {
-      String startPoint = _TestUtil.randomUnicodeString(random());
-      String endPoint = _TestUtil.randomUnicodeString(random());
+      String startPoint = TestUtil.randomUnicodeString(random());
+      String endPoint = TestUtil.randomUnicodeString(random());
       Query query = new SlowCollatedTermRangeQuery("field", startPoint, endPoint, true, true, collator);
       doTestRanges(startPoint, endPoint, query);
     }
@@ -140,8 +140,8 @@ public class TestSlowCollationMethods ex
   public void testRangeFilter() throws Exception {
     int numQueries = 50*RANDOM_MULTIPLIER;
     for (int i = 0; i < numQueries; i++) {
-      String startPoint = _TestUtil.randomUnicodeString(random());
-      String endPoint = _TestUtil.randomUnicodeString(random());
+      String startPoint = TestUtil.randomUnicodeString(random());
+      String endPoint = TestUtil.randomUnicodeString(random());
       Query query = new ConstantScoreQuery(new SlowCollatedTermRangeFilter("field", startPoint, endPoint, true, true, collator));
       doTestRanges(startPoint, endPoint, query);
     }
@@ -162,7 +162,7 @@ public class TestSlowCollationMethods ex
     RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
     for (int i = 0; i < numDocs; i++) {
       Document doc = new Document();
-      String value = _TestUtil.randomUnicodeString(random());
+      String value = TestUtil.randomUnicodeString(random());
       Field field = newStringField("field", value, Field.Store.YES);
       doc.add(field);
       iw.addDocument(doc);
@@ -172,8 +172,8 @@ public class TestSlowCollationMethods ex
 
     IndexSearcher searcher = newSearcher(reader);
 
-    String startPoint = _TestUtil.randomUnicodeString(random());
-    String endPoint = _TestUtil.randomUnicodeString(random());
+    String startPoint = TestUtil.randomUnicodeString(random());
+    String endPoint = TestUtil.randomUnicodeString(random());
     Query query = new SlowCollatedTermRangeQuery("field", startPoint, endPoint, true, true, collator);
     QueryUtils.check(random(), query, searcher);
     reader.close();

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/ServerBaseTestCase.java Wed Feb 26 14:43:56 2014
@@ -35,7 +35,7 @@ import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
 
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.codehaus.jackson.JsonNode;
 import org.codehaus.jackson.map.ObjectMapper;
 import org.codehaus.jackson.map.ObjectWriter;
@@ -76,7 +76,7 @@ public abstract class ServerBaseTestCase
 
   @BeforeClass
   public static void beforeClassServerBase() throws Exception {
-    File dir = _TestUtil.getTempDir("ServerBase");
+    File dir = TestUtil.getTempDir("ServerBase");
     STATE_DIR = new File(dir, "state");
   }
   
@@ -177,7 +177,7 @@ public abstract class ServerBaseTestCase
   }
 
   protected static void createAndStartIndex() throws Exception {
-    _TestUtil.rmDir(new File(curIndexName));
+    TestUtil.rmDir(new File(curIndexName));
     send("createIndex", "{indexName: " + curIndexName + ", rootDir: " + curIndexName + "}");
     // Wait at most 1 msec for a searcher to reopen; this
     // value is too low for a production site but for

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestAnalysis.java Wed Feb 26 14:43:56 2014
@@ -20,7 +20,7 @@ package org.apache.lucene.server;
 import java.io.File;
 import java.util.Locale;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;
@@ -122,7 +122,7 @@ public class TestAnalysis extends Server
 
   public void testPositionIncrementGap() throws Exception {
     curIndexName = "posinc";
-    _TestUtil.rmDir(new File("posinc"));
+    TestUtil.rmDir(new File("posinc"));
     send("createIndex", "{rootDir: posinc}");
     send("settings", "{directory: RAMDirectory}");
     send("registerFields", "{fields: {author1: {type: text, analyzer: {tokenizer: Whitespace}, multiValued: true}, author2: {type: text, analyzer: {tokenizer: Whitespace, positionIncrementGap: 1}, multiValued: true}}}");

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestCustomDirectory.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestCustomDirectory.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestCustomDirectory.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestCustomDirectory.java Wed Feb 26 14:43:56 2014
@@ -24,7 +24,7 @@ import java.util.Locale;
 import java.util.Set;
 
 import org.apache.lucene.store.MMapDirectory;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONObject;
@@ -53,7 +53,7 @@ public class TestCustomDirectory extends
 
   public void testCustomDirectory() throws Exception {
     curIndexName = "index";
-    _TestUtil.rmDir(new File("index"));
+    TestUtil.rmDir(new File("index"));
     send("createIndex", "{rootDir: " + curIndexName + "}");
     send("settings", "{directory: org.apache.lucene.server.TestCustomDirectory$MyDirectory, matchVersion: LUCENE_40}");
     send("startIndex");
@@ -64,7 +64,7 @@ public class TestCustomDirectory extends
 
   public void testInvalidDirectory() throws Exception {
     curIndexName = "index";
-    _TestUtil.rmDir(new File("index"));
+    TestUtil.rmDir(new File("index"));
     send("createIndex", "{rootDir: " + curIndexName + "}");
     assertFailsWith("settings", "{directory: bad}", "could not locate Directory sub-class \"bad\"; verify CLASSPATH");
     send("deleteIndex");

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestFacets.java Wed Feb 26 14:43:56 2014
@@ -21,7 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Locale;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;
@@ -60,12 +60,12 @@ public class TestFacets extends ServerBa
     put(o, "date", "{type: atom, search: false, store: true}");
     if (random().nextBoolean()) {
       // Send facets to two different random fields:
-      String name = "x" + _TestUtil.randomSimpleString(random(), 1, 10);
+      String name = "x" + TestUtil.randomSimpleString(random(), 1, 10);
       put(o, "dateFacet", "{type: atom, search: false, store: false, facet: hierarchy, facetIndexFieldName: " + name + "}");
       if (VERBOSE) {
         System.out.println("NOTE: send dateFacet to facetIndexFieldName=" + name);
       }
-      name = "y" + _TestUtil.randomSimpleString(random(), 1, 10);
+      name = "y" + TestUtil.randomSimpleString(random(), 1, 10);
       put(o, "author", "{type: text, search: false, facet: flat, group: true, facetIndexFieldName: " + name + "}");
       if (VERBOSE) {
         System.out.println("NOTE: send author to facetIndexFieldName=" + name);
@@ -73,7 +73,7 @@ public class TestFacets extends ServerBa
 
     } else if (random().nextBoolean()) {
       // Send facets to the same random field:
-      indexFacetField = "x" + _TestUtil.randomSimpleString(random(), 1, 10);
+      indexFacetField = "x" + TestUtil.randomSimpleString(random(), 1, 10);
       put(o, "dateFacet", "{type: atom, search: false, store: false, facet: hierarchy, facetIndexFieldName: " + indexFacetField + "}");
       put(o, "author", "{type: text, search: false, facet: flat, group: true, facetIndexFieldName: " + indexFacetField + "}");
       if (VERBOSE) {
@@ -260,7 +260,7 @@ public class TestFacets extends ServerBa
 
   public void testSortedSetDocValuesFacets() throws Exception {
     curIndexName = "ssdvFacets";
-    _TestUtil.rmDir(new File(curIndexName));
+    TestUtil.rmDir(new File(curIndexName));
     send("createIndex", "{rootDir: " + curIndexName + "}");
     send("settings", "{directory: FSDirectory, matchVersion: LUCENE_46}");
     send("startIndex");
@@ -270,7 +270,7 @@ public class TestFacets extends ServerBa
       send("registerFields", "{fields: {ssdv: {type: atom, search: false, store: false, facet: sortedSetDocValues, facetIndexFieldName: " + indexFacetField + "}}}");
     } else if (random().nextBoolean()) {
       // Send SSDV facets to a random index field:
-      String name = _TestUtil.randomSimpleString(random(), 1, 10);
+      String name = TestUtil.randomSimpleString(random(), 1, 10);
       send("registerFields", "{fields: {ssdv: {type: atom, search: false, store: false, facet: sortedSetDocValues, facetIndexFieldName: " + name + "}}}");
     } else {
       // Send SSDV facets to default field:

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestIndexing.java Wed Feb 26 14:43:56 2014
@@ -21,7 +21,7 @@ import java.io.File;
 import java.io.IOException;
 import java.util.Locale;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;
@@ -230,7 +230,7 @@ public class TestIndexing extends Server
   }
 
   public void testBoost() throws Exception {
-    _TestUtil.rmDir(new File("boost"));
+    TestUtil.rmDir(new File("boost"));
     curIndexName = "boost";
     send("createIndex");
     send("settings", "{directory: RAMDirectory, matchVersion: LUCENE_40}");
@@ -314,7 +314,7 @@ public class TestIndexing extends Server
       if (i == 0) {
         send("createIndex");
       } else {
-        File dir = new File(_TestUtil.getTempDir("recency"), "root");
+        File dir = new File(TestUtil.getTempDir("recency"), "root");
         send("createIndex", "{rootDir: " + dir.getAbsolutePath() + "}");
       }
       String dirImpl = i == 0 ? "RAMDirectory" : "FSDirectory";

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestPlugins.java Wed Feb 26 14:43:56 2014
@@ -23,10 +23,9 @@ import java.io.InputStream;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipOutputStream;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
-
 import net.minidev.json.JSONObject;
 
 public class TestPlugins extends ServerBaseTestCase {
@@ -34,7 +33,7 @@ public class TestPlugins extends ServerB
   @BeforeClass
   public static void init() throws Exception {
     useDefaultIndex = false;
-    File tmpDir = _TestUtil.getTempDir("TestPlugins");
+    File tmpDir = TestUtil.getTempDir("TestPlugins");
     tmpDir.mkdirs();
     File zipFile = new File(tmpDir, "MockPlugin-0.1.zip");
     ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile));
@@ -76,7 +75,7 @@ public class TestPlugins extends ServerB
     // nocommit need a "list plugins" API: verify foobar is there
     // nocommit send addDocument & verify change "took"
 
-    _TestUtil.rmDir(new File("index"));
+    TestUtil.rmDir(new File("index"));
     send("createIndex", "{rootDir: index}");
     send("startIndex");
     send("registerFields", "{fields: {id: {type: int, store: true, postingsFormat: Memory}, intfield: {type: int, store: true}}}");

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSearch.java Wed Feb 26 14:43:56 2014
@@ -24,7 +24,7 @@ import java.util.Set;
 
 import org.apache.lucene.document.Document;
 import org.apache.lucene.util.LineFileDocs;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONObject;
@@ -178,7 +178,7 @@ public class TestSearch extends ServerBa
   public void testNumericRangeQuery() throws Exception {
     curIndexName = "nrq";
     for(String type : new String[] {"int", "long", "float", "double"}) {
-      _TestUtil.rmDir(new File("nrq"));
+      TestUtil.rmDir(new File("nrq"));
       send("createIndex", "{rootDir: nrq}");
       send("startIndex");
       send("registerFields", String.format(Locale.ROOT, "{fields: {nf: {type: %s, search: true}}}", type));
@@ -321,7 +321,7 @@ public class TestSearch extends ServerBa
 
   public void testRecencyBlendedSort() throws Exception {
     curIndexName = "recency";
-    File dir = new File(_TestUtil.getTempDir("recency"), "root");
+    File dir = new File(TestUtil.getTempDir("recency"), "root");
     send("createIndex", "{rootDir: " + dir.getAbsolutePath() + "}");
     send("startIndex");
     send("registerFields", "{fields: {timestamp: {type: long, search: false, sort: true}, body: {type: text, analyzer: StandardAnalyzer}}}");

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSimpleSpatial.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSimpleSpatial.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSimpleSpatial.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSimpleSpatial.java Wed Feb 26 14:43:56 2014
@@ -20,7 +20,7 @@ package org.apache.lucene.server;
 import java.io.File;
 import java.util.Locale;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSnapshots.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSnapshots.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSnapshots.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSnapshots.java Wed Feb 26 14:43:56 2014
@@ -20,7 +20,7 @@ package org.apache.lucene.server;
 import java.io.File;
 import java.util.Map;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;
@@ -70,7 +70,7 @@ public class TestSnapshots extends Serve
     long indexGen2 = getLong("indexGen");
     commit();
 
-    File backupDir = _TestUtil.getTempDir("backup");
+    File backupDir = TestUtil.getTempDir("backup");
 
     // Make sure all files in the snapshot still exist, even
     // though we deleted that segment, and make a backup:
@@ -163,7 +163,7 @@ public class TestSnapshots extends Serve
       assertEquals(2, o.get("totalHits"));
 
     } finally {
-      _TestUtil.rmDir(backupDir);
+      TestUtil.rmDir(backupDir);
     }
   }
 

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSort.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSort.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSort.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSort.java Wed Feb 26 14:43:56 2014
@@ -22,7 +22,7 @@ import java.util.HashSet;
 import java.util.Locale;
 import java.util.Set;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONObject;

Modified: lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSuggest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSuggest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSuggest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/server/src/test/org/apache/lucene/server/TestSuggest.java Wed Feb 26 14:43:56 2014
@@ -23,7 +23,7 @@ import java.io.FileOutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
 
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import net.minidev.json.JSONArray;
@@ -40,7 +40,7 @@ public class TestSuggest extends ServerB
     startServer();
     createAndStartIndex();
     commit();
-    File tempDir = _TestUtil.getTempDir("TestSuggest");
+    File tempDir = TestUtil.getTempDir("TestSuggest");
     tempDir.mkdirs();
     tempFile = new File(tempDir, "suggest.in");
   }
@@ -163,7 +163,7 @@ public class TestSuggest extends ServerB
   /** Build a suggest, pulling suggestions/weights/payloads from stored fields. */
   public void testFromStoredFields() throws Exception {
     curIndexName = "storedSuggest";
-    _TestUtil.rmDir(new File("storedsuggest"));
+    TestUtil.rmDir(new File("storedsuggest"));
     send("createIndex", "{rootDir: storedsuggest}");
     send("settings", "{directory: FSDirectory, matchVersion: LUCENE_46}");
     send("startIndex");
@@ -198,7 +198,7 @@ public class TestSuggest extends ServerB
    *  stored fields, and weight from an expression */
   public void testFromStoredFieldsWithWeightExpression() throws Exception {
     curIndexName = "storedsuggestexpr";
-    _TestUtil.rmDir(new File(curIndexName));
+    TestUtil.rmDir(new File(curIndexName));
     send("createIndex", "{rootDir: " + curIndexName + "}");
     send("settings", "{directory: FSDirectory, matchVersion: LUCENE_46}");
     send("startIndex");

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/AbstractVisitingPrefixTreeFilter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/AbstractVisitingPrefixTreeFilter.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/AbstractVisitingPrefixTreeFilter.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/java/org/apache/lucene/spatial/prefix/AbstractVisitingPrefixTreeFilter.java Wed Feb 26 14:43:56 2014
@@ -83,7 +83,7 @@ public abstract class AbstractVisitingPr
    * The {@link #getDocIdSet()} method here starts the work. It first checks
    * that there are indexed terms; if not it quickly returns null. Then it calls
    * {@link #start()} so a subclass can set up a return value, like an
-   * {@link org.apache.lucene.util.OpenBitSet}. Then it starts the traversal
+   * {@link org.apache.lucene.util.FixedBitSet}. Then it starts the traversal
    * process, calling {@link #findSubCellsToVisit(org.apache.lucene.spatial.prefix.tree.Cell)}
    * which by default finds the top cells that intersect {@code queryShape}. If
    * there isn't an indexed cell for a corresponding cell returned for this

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/DistanceStrategyTest.java Wed Feb 26 14:43:56 2014
@@ -29,6 +29,7 @@ import org.apache.lucene.spatial.prefix.
 import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
+import org.apache.lucene.spatial.serialized.SerializedDVStrategy;
 import org.apache.lucene.spatial.vector.PointVectorStrategy;
 import org.junit.Test;
 
@@ -61,6 +62,9 @@ public class DistanceStrategyTest extend
     strategy = new BBoxStrategy(ctx, "bbox");
     ctorArgs.add(new Object[]{new Param(strategy)});
 
+    strategy = new SerializedDVStrategy(ctx, "serialized");
+    ctorArgs.add(new Object[]{new Param(strategy)});
+
     return ctorArgs;
   }
 
@@ -86,11 +90,19 @@ public class DistanceStrategyTest extend
     this.strategy = strategy;
   }
 
+  @Override
+  protected boolean needsDocValues() {
+    return (strategy instanceof SerializedDVStrategy);
+  }
+
   @Test
   public void testDistanceOrder() throws IOException {
-    adoc("100", ctx.makePoint(2,1));
-    adoc("101", ctx.makePoint(-1,4));
+    adoc("100", ctx.makePoint(2, 1));
+    adoc("101", ctx.makePoint(-1, 4));
     adoc("103", (Shape)null);//test score for nothing
+    adoc("999", ctx.makePoint(2, 1));//test deleted
+    commit();
+    deleteDoc("999");
     commit();
     //FYI distances are in docid order
     checkDistValueSource(ctx.makePoint(4, 3), 2.8274937f, 5.0898066f, 180f);
@@ -104,6 +116,9 @@ public class DistanceStrategyTest extend
     Point p101 = ctx.makePoint(-1, 4);
     adoc("101", p101);
     adoc("103", (Shape)null);//test score for nothing
+    adoc("999", ctx.makePoint(2, 1));//test deleted
+    commit();
+    deleteDoc("999");
     commit();
 
     double dist = ctx.getDistCalc().distance(p100, p101);

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/QueryEqualsHashCodeTest.java Wed Feb 26 14:43:56 2014
@@ -22,10 +22,12 @@ import com.spatial4j.core.shape.Shape;
 import org.apache.lucene.spatial.bbox.BBoxStrategy;
 import org.apache.lucene.spatial.prefix.RecursivePrefixTreeStrategy;
 import org.apache.lucene.spatial.prefix.TermQueryPrefixTreeStrategy;
+import org.apache.lucene.spatial.prefix.tree.GeohashPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.prefix.tree.SpatialPrefixTree;
 import org.apache.lucene.spatial.query.SpatialArgs;
 import org.apache.lucene.spatial.query.SpatialOperation;
+import org.apache.lucene.spatial.serialized.SerializedDVStrategy;
 import org.apache.lucene.spatial.vector.PointVectorStrategy;
 import org.apache.lucene.util.LuceneTestCase;
 import org.junit.Test;
@@ -40,43 +42,52 @@ public class QueryEqualsHashCodeTest ext
   @Test
   public void testEqualsHashCode() {
 
-    final SpatialPrefixTree grid = new QuadPrefixTree(ctx,10);
+    final SpatialPrefixTree gridQuad = new QuadPrefixTree(ctx,10);
+    final SpatialPrefixTree gridGeohash = new GeohashPrefixTree(ctx,10);
+
+    Collection<SpatialStrategy> strategies = new ArrayList<SpatialStrategy>();
+    strategies.add(new RecursivePrefixTreeStrategy(gridGeohash, "recursive_geohash"));
+    strategies.add(new TermQueryPrefixTreeStrategy(gridQuad, "termquery_quad"));
+    strategies.add(new PointVectorStrategy(ctx, "pointvector"));
+    strategies.add(new BBoxStrategy(ctx, "bbox"));
+    strategies.add(new SerializedDVStrategy(ctx, "serialized"));
+    for (SpatialStrategy strategy : strategies) {
+      testEqualsHashcode(strategy);
+    }
+  }
+
+  private void testEqualsHashcode(final SpatialStrategy strategy) {
     final SpatialArgs args1 = makeArgs1();
     final SpatialArgs args2 = makeArgs2();
-
-    Collection<ObjGenerator> generators = new ArrayList<ObjGenerator>();
-    generators.add(new ObjGenerator() {
-      @Override
-      public Object gen(SpatialArgs args) {
-        return new RecursivePrefixTreeStrategy(grid, "recursive_quad").makeQuery(args);
-      }
-    });
-    generators.add(new ObjGenerator() {
+    testEqualsHashcode(args1, args2, new ObjGenerator() {
       @Override
       public Object gen(SpatialArgs args) {
-        return new TermQueryPrefixTreeStrategy(grid, "termquery_quad").makeQuery(args);
+        return strategy.makeQuery(args);
       }
     });
-    generators.add(new ObjGenerator() {
+    testEqualsHashcode(args1, args2, new ObjGenerator() {
       @Override
       public Object gen(SpatialArgs args) {
-        return new PointVectorStrategy(ctx, "pointvector").makeQuery(args);
+        return strategy.makeFilter(args);
       }
     });
-    generators.add(new ObjGenerator() {
+    testEqualsHashcode(args1, args2, new ObjGenerator() {
       @Override
       public Object gen(SpatialArgs args) {
-        return new BBoxStrategy(ctx, "bbox").makeQuery(args);
+        return strategy.makeDistanceValueSource(args.getShape().getCenter());
       }
     });
-
-    for (ObjGenerator generator : generators) {
-      testStratQueryEqualsHashcode(args1, args2, generator);
-    }
   }
 
-  private void testStratQueryEqualsHashcode(SpatialArgs args1, SpatialArgs args2, ObjGenerator generator) {
-    Object first = generator.gen(args1);
+  private void testEqualsHashcode(SpatialArgs args1, SpatialArgs args2, ObjGenerator generator) {
+    Object first;
+    try {
+      first = generator.gen(args1);
+    } catch (UnsupportedOperationException e) {
+      return;
+    }
+    if (first == null)
+      return;//unsupported op?
     Object second = generator.gen(args1);//should be the same
     assertEquals(first, second);
     assertEquals(first.hashCode(), second.hashCode());

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/SpatialTestCase.java Wed Feb 26 14:43:56 2014
@@ -20,8 +20,11 @@ package org.apache.lucene.spatial;
 import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.shape.Point;
 import com.spatial4j.core.shape.Rectangle;
+import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.codecs.lucene45.Lucene45DocValuesFormat;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.index.DirectoryReader;
+import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.RandomIndexWriter;
 import org.apache.lucene.index.StoredDocument;
 import org.apache.lucene.search.IndexSearcher;
@@ -31,12 +34,14 @@ import org.apache.lucene.search.TopDocs;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 import org.junit.After;
 import org.junit.Before;
 
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Random;
 
 import static com.carrotsearch.randomizedtesting.RandomizedTest.randomGaussian;
 import static com.carrotsearch.randomizedtesting.RandomizedTest.randomIntBetween;
@@ -57,11 +62,24 @@ public abstract class SpatialTestCase ex
     super.setUp();
 
     directory = newDirectory();
-    indexWriter = new RandomIndexWriter(random(),directory);
+    final Random random = random();
+    indexWriter = new RandomIndexWriter(random,directory, newIndexWriterConfig(random));
     indexReader = indexWriter.getReader();
     indexSearcher = newSearcher(indexReader);
   }
 
+  protected IndexWriterConfig newIndexWriterConfig(Random random) {
+    final IndexWriterConfig indexWriterConfig = LuceneTestCase.newIndexWriterConfig(random, LuceneTestCase.TEST_VERSION_CURRENT, new MockAnalyzer(random));
+    //TODO can we randomly choose a doc-values supported format?
+    if (needsDocValues())
+      indexWriterConfig.setCodec( TestUtil.alwaysDocValuesFormat(new Lucene45DocValuesFormat()));;
+    return indexWriterConfig;
+  }
+
+  protected boolean needsDocValues() {
+    return false;
+  }
+
   @Override
   @After
   public void tearDown() throws Exception {

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/StrategyTestCase.java Wed Feb 26 14:43:56 2014
@@ -28,6 +28,7 @@ import org.apache.lucene.index.Term;
 import org.apache.lucene.queries.function.FunctionQuery;
 import org.apache.lucene.queries.function.ValueSource;
 import org.apache.lucene.search.CheckHits;
+import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
 import org.apache.lucene.search.TermQuery;
 import org.apache.lucene.search.TopDocs;
@@ -139,7 +140,7 @@ public abstract class StrategyTestCase e
 
   public void runTestQuery(SpatialMatchConcern concern, SpatialTestQuery q) {
     String msg = q.toString(); //"Query: " + q.args.toString(ctx);
-    SearchResults got = executeQuery(strategy.makeQuery(q.args), Math.max(100, q.ids.size()+1));
+    SearchResults got = executeQuery(makeQuery(q), Math.max(100, q.ids.size()+1));
     if (storeShape && got.numFound > 0) {
       //check stored value is there
       assertNotNull(got.results.get(0).document.get(strategy.getFieldName()));
@@ -183,6 +184,10 @@ public abstract class StrategyTestCase e
     }
   }
 
+  protected Query makeQuery(SpatialTestQuery q) {
+    return strategy.makeQuery(q.args);
+  }
+
   protected void adoc(String id, String shapeStr) throws IOException, ParseException {
     Shape shape = shapeStr==null ? null : ctx.readShapeFromWkt(shapeStr);
     addDocument(newDoc(id, shape));

Modified: lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/SpatialOpRecursivePrefixTreeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/SpatialOpRecursivePrefixTreeTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/SpatialOpRecursivePrefixTreeTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/SpatialOpRecursivePrefixTreeTest.java Wed Feb 26 14:43:56 2014
@@ -18,11 +18,10 @@ package org.apache.lucene.spatial.prefix
  */
 
 import com.carrotsearch.randomizedtesting.annotations.Repeat;
-import com.spatial4j.core.context.SpatialContext;
 import com.spatial4j.core.context.SpatialContextFactory;
-import com.spatial4j.core.shape.Point;
 import com.spatial4j.core.shape.Rectangle;
 import com.spatial4j.core.shape.Shape;
+import com.spatial4j.core.shape.ShapeCollection;
 import com.spatial4j.core.shape.SpatialRelation;
 import com.spatial4j.core.shape.impl.RectangleImpl;
 import org.apache.lucene.document.Document;
@@ -41,6 +40,7 @@ import org.junit.Test;
 
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
@@ -200,7 +200,7 @@ public class SpatialOpRecursivePrefixTre
     final boolean biasContains = (operation == SpatialOperation.Contains);
 
     Map<String, Shape> indexedShapes = new LinkedHashMap<String, Shape>();
-    Map<String, Shape> indexedShapesGS = new LinkedHashMap<String, Shape>();
+    Map<String, Shape> indexedShapesGS = new LinkedHashMap<String, Shape>();//grid snapped
     final int numIndexedShapes = randomIntBetween(1, 6);
     for (int i = 0; i < numIndexedShapes; i++) {
       String id = "" + i;
@@ -210,7 +210,7 @@ public class SpatialOpRecursivePrefixTre
       if (R == 0) {//1 in 12
         indexedShape = null; //no shape for this doc
         indexedShapeGS = null;
-      } else if (R % 3 == 0) {//4-1 in 12
+      } else if (R % 3 == 0) {//4 in 12 (0,3,6,9)
         //comprised of more than one shape
         Rectangle shape1 = randomRectangle();
         Rectangle shape2 = randomRectangle();
@@ -221,6 +221,7 @@ public class SpatialOpRecursivePrefixTre
         indexedShape = randomRectangle();
         indexedShapeGS = gridSnap(indexedShape);
       }
+      //TODO sometimes index a point. Need to fix LUCENE-4978 first though.
       indexedShapes.put(id, indexedShape);
       indexedShapesGS.put(id, indexedShapeGS);
 
@@ -230,6 +231,7 @@ public class SpatialOpRecursivePrefixTre
         commit();//intermediate commit, produces extra segments
 
     }
+    //delete some documents randomly
     Iterator<String> idIter = indexedShapes.keySet().iterator();
     while (idIter.hasNext()) {
       String id = idIter.next();
@@ -246,39 +248,44 @@ public class SpatialOpRecursivePrefixTre
     for (int i = 0; i < numQueryShapes; i++) {
       int scanLevel = randomInt(grid.getMaxLevels());
       ((RecursivePrefixTreeStrategy) strategy).setPrefixGridScanLevel(scanLevel);
+
       final Shape queryShape = randomRectangle();
 
-      final boolean DISJOINT = operation.equals(SpatialOperation.IsDisjointTo);
+      final boolean opIsDisjoint = operation == SpatialOperation.IsDisjointTo;
 
       //Generate truth via brute force:
-      // We really try to ensure true-positive matches (if the predicate on the raw shapes match
+      // We ensure true-positive matches (if the predicate on the raw shapes match
       //  then the search should find those same matches).
       // approximations, false-positive matches
-      Set <String> expectedIds = new LinkedHashSet<String>();//true-positives
+      Set<String> expectedIds = new LinkedHashSet<String>();//true-positives
       Set<String> secondaryIds = new LinkedHashSet<String>();//false-positives (unless disjoint)
       for (Map.Entry<String, Shape> entry : indexedShapes.entrySet()) {
+        String id = entry.getKey();
         Shape indexedShapeCompare = entry.getValue();
         if (indexedShapeCompare == null)
           continue;
         Shape queryShapeCompare = queryShape;
-        String id = entry.getKey();
+
         if (operation.evaluate(indexedShapeCompare, queryShapeCompare)) {
           expectedIds.add(id);
-          if (DISJOINT) {
+          if (opIsDisjoint) {
             //if no longer intersect after buffering them, for disjoint, remember this
-            indexedShapeCompare = indexedShapesGS.get(entry.getKey());
+            indexedShapeCompare = indexedShapesGS.get(id);
             queryShapeCompare = gridSnap(queryShape);
             if (!operation.evaluate(indexedShapeCompare, queryShapeCompare))
               secondaryIds.add(id);
           }
-        } else if (!DISJOINT) {
+        } else if (!opIsDisjoint) {
           //buffer either the indexed or query shape (via gridSnap) and try again
-          if (operation.equals(SpatialOperation.Intersects)) {
-            indexedShapeCompare = indexedShapesGS.get(entry.getKey());
+          if (operation == SpatialOperation.Intersects) {
+            indexedShapeCompare = indexedShapesGS.get(id);
             queryShapeCompare = gridSnap(queryShape);
-          } else if (operation.equals(SpatialOperation.Contains)) {
-            indexedShapeCompare = indexedShapesGS.get(entry.getKey());
-          } else if (operation.equals(SpatialOperation.IsWithin)) {
+            //TODO Unfortunately, grid-snapping both can result in intersections that otherwise
+            // wouldn't happen when the grids are adjacent. Not a big deal but our test is just a
+            // bit more lenient.
+          } else if (operation == SpatialOperation.Contains) {
+            indexedShapeCompare = indexedShapesGS.get(id);
+          } else if (operation == SpatialOperation.IsWithin) {
             queryShapeCompare = gridSnap(queryShape);
           }
           if (operation.evaluate(indexedShapeCompare, queryShapeCompare))
@@ -294,11 +301,11 @@ public class SpatialOpRecursivePrefixTre
       for (SearchResult result : got.results) {
         String id = result.getId();
         boolean removed = remainingExpectedIds.remove(id);
-        if (!removed && (!DISJOINT && !secondaryIds.contains(id))) {
+        if (!removed && (!opIsDisjoint && !secondaryIds.contains(id))) {
           fail("Shouldn't match", id, indexedShapes, indexedShapesGS, queryShape);
         }
       }
-      if (DISJOINT)
+      if (opIsDisjoint)
         remainingExpectedIds.removeAll(secondaryIds);
       if (!remainingExpectedIds.isEmpty()) {
         String id = remainingExpectedIds.iterator().next();
@@ -327,30 +334,27 @@ public class SpatialOpRecursivePrefixTre
     List<Cell> cells = grid.getCells(snapMe, detailLevel, false, true);
 
     //calc bounding box of cells.
-    double minX = Double.POSITIVE_INFINITY, maxX = Double.NEGATIVE_INFINITY;
-    double minY = Double.POSITIVE_INFINITY, maxY = Double.NEGATIVE_INFINITY;
+    List<Shape> cellShapes = new ArrayList<Shape>(cells.size());
     for (Cell cell : cells) {
-      assert cell.getLevel() <= detailLevel;
-      Rectangle cellR = cell.getShape().getBoundingBox();
-
-      minX = Math.min(minX, cellR.getMinX());
-      maxX = Math.max(maxX, cellR.getMaxX());
-      minY = Math.min(minY, cellR.getMinY());
-      maxY = Math.max(maxY, cellR.getMaxY());
+      cellShapes.add(cell.getShape());
     }
-    return ctx.makeRectangle(minX, maxX, minY, maxY);
+    return new ShapeCollection<Shape>(cellShapes, ctx).getBoundingBox();
   }
 
   /**
-   * An aggregate of 2 shapes. Only implements what's necessary for the test
-   * here. TODO replace with Spatial4j trunk ShapeCollection.
+   * An aggregate of 2 shapes. Unfortunately we can't simply use a ShapeCollection because:
+   * (a) ambiguity between CONTAINS & WITHIN for equal shapes, and
+   * (b) adjacent pairs could as a whole contain the input shape.
+   * The tests here are sensitive to these matters, although in practice ShapeCollection
+   * is fine.
    */
-  private class ShapePair implements Shape {
+  private class ShapePair extends ShapeCollection<Rectangle> {
 
     final Rectangle shape1, shape2;
     final boolean biasContainsThenWithin;//a hack
 
     public ShapePair(Rectangle shape1, Rectangle shape2, boolean containsThenWithin) {
+      super(Arrays.asList(shape1, shape2), ctx);
       this.shape1 = shape1;
       this.shape2 = shape2;
       biasContainsThenWithin = containsThenWithin;
@@ -359,15 +363,20 @@ public class SpatialOpRecursivePrefixTre
     @Override
     public SpatialRelation relate(Shape other) {
       SpatialRelation r = relateApprox(other);
-      if (r != INTERSECTS && !(r == WITHIN && biasContainsThenWithin))
+      if (r == CONTAINS)
+        return r;
+      if (r == DISJOINT)
+        return r;
+      if (r == WITHIN && !biasContainsThenWithin)
         return r;
+
       //See if the correct answer is actually Contains, when the indexed shapes are adjacent,
       // creating a larger shape that contains the input shape.
-      Rectangle oRect = (Rectangle)other;
       boolean pairTouches = shape1.relate(shape2).intersects();
       if (!pairTouches)
         return r;
       //test all 4 corners
+      Rectangle oRect = (Rectangle)other;
       if (relate(ctx.makePoint(oRect.getMinX(), oRect.getMinY())) == CONTAINS
           && relate(ctx.makePoint(oRect.getMinX(), oRect.getMaxY())) == CONTAINS
           && relate(ctx.makePoint(oRect.getMaxX(), oRect.getMinY())) == CONTAINS
@@ -391,41 +400,11 @@ public class SpatialOpRecursivePrefixTre
       }
 
       if (shape1.relate(other).intersects() || shape2.relate(other).intersects())
-        return INTERSECTS;//might actually be 'CONTAINS' if these 2 are adjacent
+        return INTERSECTS;//might actually be 'CONTAINS' if the pair are adjacent but we handle that later
       return DISJOINT;
     }
 
     @Override
-    public Rectangle getBoundingBox() {
-      return ctx.getWorldBounds();//good enough
-    }
-
-    @Override
-    public boolean hasArea() {
-      return true;
-    }
-
-    @Override
-    public double getArea(SpatialContext ctx) {
-      throw new UnsupportedOperationException("TODO unimplemented");//TODO
-    }
-
-    @Override
-    public Point getCenter() {
-      throw new UnsupportedOperationException("TODO unimplemented");//TODO
-    }
-
-    @Override
-    public Shape getBuffered(double distance, SpatialContext ctx) {
-      throw new UnsupportedOperationException("TODO unimplemented");//TODO
-    }
-
-    @Override
-    public boolean isEmpty() {
-      return false;
-    }
-
-    @Override
     public String toString() {
       return "ShapePair(" + shape1 + " , " + shape2 + ")";
     }

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/analyzing/AnalyzingInfixSuggester.java Wed Feb 26 14:43:56 2014
@@ -44,11 +44,13 @@ import org.apache.lucene.index.AtomicRea
 import org.apache.lucene.index.BinaryDocValues;
 import org.apache.lucene.index.DirectoryReader;
 import org.apache.lucene.index.FieldInfo.IndexOptions;
+import org.apache.lucene.index.FilterAtomicReader;
 import org.apache.lucene.index.IndexReader;
 import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.index.IndexWriterConfig;
 import org.apache.lucene.index.MultiDocValues;
 import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.index.SegmentReader;
 import org.apache.lucene.index.SlowCompositeReaderWrapper;
 import org.apache.lucene.index.Term;
 import org.apache.lucene.index.sorter.Sorter;
@@ -644,7 +646,16 @@ public class AnalyzingInfixSuggester ext
 
   @Override
   public long sizeInBytes() {
-    return RamUsageEstimator.sizeOf(this);
+    long mem = RamUsageEstimator.shallowSizeOf(this);
+    if (searcher != null) {
+      for (AtomicReaderContext context : searcher.getIndexReader().leaves()) {
+        AtomicReader reader = FilterAtomicReader.unwrap(context.reader());
+        if (reader instanceof SegmentReader) {
+          mem += ((SegmentReader) context.reader()).ramBytesUsed();
+        }
+      }
+    }
+    return mem;
   }
 
   @Override

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/fst/FSTCompletionLookup.java Wed Feb 26 14:43:56 2014
@@ -291,7 +291,15 @@ public class FSTCompletionLookup extends
 
   @Override
   public long sizeInBytes() {
-    return RamUsageEstimator.sizeOf(this);
+    long mem = RamUsageEstimator.shallowSizeOf(this) + RamUsageEstimator.shallowSizeOf(normalCompletion) + RamUsageEstimator.shallowSizeOf(higherWeightsCompletion);
+    if (normalCompletion != null) {
+      mem += normalCompletion.getFST().sizeInBytes();
+    }
+    if (higherWeightsCompletion != null && (normalCompletion == null || normalCompletion.getFST() != higherWeightsCompletion.getFST())) {
+      // the fst should be shared between the 2 completion instances, don't count it twice
+      mem += higherWeightsCompletion.getFST().sizeInBytes();
+    }
+    return mem;
   }
 
   @Override

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellLookup.java Wed Feb 26 14:43:56 2014
@@ -198,7 +198,7 @@ public class JaspellLookup extends Looku
   /** Returns byte size of the underlying TST. */
   @Override
   public long sizeInBytes() {
-    return RamUsageEstimator.sizeOf(trie);
+    return trie.sizeInBytes();
   }
   
   @Override

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellTernarySearchTrie.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellTernarySearchTrie.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellTernarySearchTrie.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/jaspell/JaspellTernarySearchTrie.java Wed Feb 26 14:43:56 2014
@@ -40,6 +40,7 @@ import java.util.Vector;
 import java.util.zip.GZIPInputStream;
 
 import org.apache.lucene.util.IOUtils;
+import org.apache.lucene.util.RamUsageEstimator;
 
 /**
  * Implementation of a Ternary Search Trie, a data structure for storing
@@ -75,7 +76,7 @@ public class JaspellTernarySearchTrie {
     protected Object data;
 
     /** The relative nodes. */
-    protected TSTNode[] relatives = new TSTNode[4];
+    protected final TSTNode[] relatives = new TSTNode[4];
 
     /** The char used in the split. */
     protected char splitchar;
@@ -92,6 +93,17 @@ public class JaspellTernarySearchTrie {
       this.splitchar = splitchar;
       relatives[PARENT] = parent;
     }
+
+    public long sizeInBytes() {
+      long mem = RamUsageEstimator.shallowSizeOf(this) + RamUsageEstimator.shallowSizeOf(relatives);
+      for (TSTNode node : relatives) {
+        if (node != null) {
+          mem += node.sizeInBytes();
+        }
+      }
+      return mem;
+    }
+
   }
 
   /**
@@ -873,4 +885,14 @@ public class JaspellTernarySearchTrie {
             sortKeysNumReturnValues, sortKeysResult);
   }
 
+  /** Return an approximate memory usage for this trie. */
+  public long sizeInBytes() {
+    long mem = RamUsageEstimator.shallowSizeOf(this);
+    final TSTNode root = getRoot();
+    if (root != null) {
+      mem += root.sizeInBytes();
+    }
+    return mem;
+  }
+
 }

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TSTLookup.java Wed Feb 26 14:43:56 2014
@@ -216,7 +216,11 @@ public class TSTLookup extends Lookup {
   /** Returns byte size of the underlying TST */
   @Override
   public long sizeInBytes() {
-    return RamUsageEstimator.sizeOf(autocomplete);
+    long mem = RamUsageEstimator.shallowSizeOf(this);
+    if (root != null) {
+      mem += root.sizeInBytes();
+    }
+    return mem;
   }
   
   @Override

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TernaryTreeNode.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TernaryTreeNode.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TernaryTreeNode.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/java/org/apache/lucene/search/suggest/tst/TernaryTreeNode.java Wed Feb 26 14:43:56 2014
@@ -1,5 +1,7 @@
 package org.apache.lucene.search.suggest.tst;
 
+import org.apache.lucene.util.RamUsageEstimator;
+
 /*
  * Licensed to the Apache Software Foundation (ASF) under one or more
  * contributor license agreements.  See the NOTICE file distributed with
@@ -42,4 +44,22 @@ public class TernaryTreeNode {
    */
   String token;
   Object val;
+
+  long sizeInBytes() {
+    long mem = RamUsageEstimator.shallowSizeOf(this);
+    if (loKid != null) {
+      mem += loKid.sizeInBytes();
+    }
+    if (eqKid != null) {
+      mem += eqKid.sizeInBytes();
+    }
+    if (hiKid != null) {
+      mem += hiKid.sizeInBytes();
+    }
+    if (token != null) {
+      mem += RamUsageEstimator.shallowSizeOf(token) + RamUsageEstimator.NUM_BYTES_ARRAY_HEADER + RamUsageEstimator.NUM_BYTES_CHAR * token.length();
+    }
+    mem += RamUsageEstimator.shallowSizeOf(val);
+    return mem;
+  }
 }

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/spell/TestWordBreakSpellChecker.java Wed Feb 26 14:43:56 2014
@@ -35,7 +35,7 @@ import org.apache.lucene.search.spell.Wo
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.English;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
 
 public class TestWordBreakSpellChecker extends LuceneTestCase {
   private Directory dir = null;
@@ -262,7 +262,7 @@ public class TestWordBreakSpellChecker e
     }    
   }
   public void testRandom() throws Exception {
-    int numDocs = _TestUtil.nextInt(random(), (10 * RANDOM_MULTIPLIER),
+    int numDocs = TestUtil.nextInt(random(), (10 * RANDOM_MULTIPLIER),
         (100 * RANDOM_MULTIPLIER));
     Directory dir = null;
     RandomIndexWriter writer = null;
@@ -271,24 +271,24 @@ public class TestWordBreakSpellChecker e
       dir = newDirectory();
       writer = new RandomIndexWriter(random(), dir, new MockAnalyzer(random(),
           MockTokenizer.WHITESPACE, false));
-      int maxLength = _TestUtil.nextInt(random(), 5, 50);
+      int maxLength = TestUtil.nextInt(random(), 5, 50);
       List<String> originals = new ArrayList<String>(numDocs);
       List<String[]> breaks = new ArrayList<String[]>(numDocs);
       for (int i = 0; i < numDocs; i++) {
         String orig = "";
         if (random().nextBoolean()) {
           while (!goodTestString(orig)) {
-            orig = _TestUtil.randomSimpleString(random(), maxLength);
+            orig = TestUtil.randomSimpleString(random(), maxLength);
           }
         } else {
           while (!goodTestString(orig)) {
-            orig = _TestUtil.randomUnicodeString(random(), maxLength);
+            orig = TestUtil.randomUnicodeString(random(), maxLength);
           }
         }
         originals.add(orig);
         int totalLength = orig.codePointCount(0, orig.length());
         int breakAt = orig.offsetByCodePoints(0,
-            _TestUtil.nextInt(random(), 1, totalLength - 1));
+            TestUtil.nextInt(random(), 1, totalLength - 1));
         String[] broken = new String[2];
         broken[0] = orig.substring(0, breakAt);
         broken[1] = orig.substring(breakAt);

Modified: lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java?rev=1572063&r1=1572062&r2=1572063&view=diff
==============================================================================
--- lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java (original)
+++ lucene/dev/branches/lucene5376/lucene/suggest/src/test/org/apache/lucene/search/suggest/FileDictionaryTest.java Wed Feb 26 14:43:56 2014
@@ -10,7 +10,8 @@ import java.util.Map;
 
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+import org.apache.lucene.util.TestUtil;
+import org.apache.lucene.util.TestUtil;
 import org.junit.Test;
 
 
@@ -36,18 +37,18 @@ public class FileDictionaryTest extends 
   private Map.Entry<List<String>, String> generateFileEntry(String fieldDelimiter, boolean hasWeight, boolean hasPayload) {
     List<String> entryValues = new ArrayList<>();
     StringBuilder sb = new StringBuilder();
-    String term = _TestUtil.randomSimpleString(random(), 1, 300);
+    String term = TestUtil.randomSimpleString(random(), 1, 300);
     sb.append(term);
     entryValues.add(term);
     if (hasWeight) {
       sb.append(fieldDelimiter);
-      long weight = _TestUtil.nextLong(random(), Long.MIN_VALUE, Long.MAX_VALUE);
+      long weight = TestUtil.nextLong(random(), Long.MIN_VALUE, Long.MAX_VALUE);
       sb.append(weight);
       entryValues.add(String.valueOf(weight));
     }
     if (hasPayload) {
       sb.append(fieldDelimiter);
-      String payload = _TestUtil.randomSimpleString(random(), 1, 300);
+      String payload = TestUtil.randomSimpleString(random(), 1, 300);
       sb.append(payload);
       entryValues.add(payload);
     }