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/11/27 12:34:48 UTC

svn commit: r1642110 [10/12] - in /lucene/dev/branches/lucene6005/lucene: analysis/uima/src/test/org/apache/lucene/analysis/uima/ backward-codecs/src/test/org/apache/lucene/index/ benchmark/src/java/org/apache/lucene/benchmark/byTask/feeds/ benchmark/s...

Modified: lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java (original)
+++ lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/TestTermQueryPrefixGridStrategy.java Thu Nov 27 11:34:43 2014
@@ -17,8 +17,10 @@ package org.apache.lucene.spatial.prefix
  * limitations under the License.
  */
 
-import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.shape.Shape;
+import java.io.IOException;
+import java.util.Arrays;
+
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StoredField;
@@ -27,9 +29,8 @@ import org.apache.lucene.spatial.Spatial
 import org.apache.lucene.spatial.prefix.tree.QuadPrefixTree;
 import org.apache.lucene.spatial.query.SpatialArgsParser;
 import org.junit.Test;
-
-import java.io.IOException;
-import java.util.Arrays;
+import com.spatial4j.core.context.SpatialContext;
+import com.spatial4j.core.shape.Shape;
 
 
 public class TestTermQueryPrefixGridStrategy extends SpatialTestCase {
@@ -41,12 +42,12 @@ public class TestTermQueryPrefixGridStra
 
     Shape point = ctx.makePoint(-118.243680, 34.052230);
 
-    Document losAngeles = new Document();
-    losAngeles.add(new StringField("name", "Los Angeles", Field.Store.YES));
-    for (Field field : prefixGridStrategy.createIndexableFields(point)) {
-      losAngeles.add(field);
-    }
-    losAngeles.add(new StoredField(prefixGridStrategy.getFieldName(), point.toString()));//just for diagnostics
+    Document2 losAngeles = indexWriter.newDocument();
+    losAngeles.addAtom("name", "Los Angeles");
+
+    fieldTypes.setMultiValued(prefixGridStrategy.getFieldName());
+    prefixGridStrategy.addFields(losAngeles, point);
+    losAngeles.addStored(prefixGridStrategy.getFieldName(), point.toString());//just for diagnostics
 
     addDocumentsAndCommit(Arrays.asList(losAngeles));
 

Modified: lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeTest.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/prefix/tree/SpatialPrefixTreeTest.java Thu Nov 27 11:34:43 2014
@@ -17,13 +17,13 @@ package org.apache.lucene.spatial.prefix
  * limitations under the License.
  */
 
-import com.spatial4j.core.context.SpatialContext;
-import com.spatial4j.core.shape.Point;
-import com.spatial4j.core.shape.Rectangle;
-import com.spatial4j.core.shape.Shape;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.document.Field;
 import org.apache.lucene.document.Field.Store;
+import org.apache.lucene.document.Field;
 import org.apache.lucene.document.TextField;
 import org.apache.lucene.search.Query;
 import org.apache.lucene.search.ScoreDoc;
@@ -34,9 +34,10 @@ import org.apache.lucene.spatial.query.S
 import org.apache.lucene.spatial.query.SpatialOperation;
 import org.junit.Before;
 import org.junit.Test;
-
-import java.util.ArrayList;
-import java.util.List;
+import com.spatial4j.core.context.SpatialContext;
+import com.spatial4j.core.shape.Point;
+import com.spatial4j.core.shape.Rectangle;
+import com.spatial4j.core.shape.Shape;
 
 public class SpatialPrefixTreeTest extends SpatialTestCase {
 
@@ -85,21 +86,18 @@ public class SpatialPrefixTreeTest exten
 
     trie = new QuadPrefixTree(ctx, 12);
     TermQueryPrefixTreeStrategy strategy = new TermQueryPrefixTreeStrategy(trie, "geo");
-    Document doc = new Document();
-    doc.add(new TextField("id", "1", Store.YES));
+    Document2 doc = indexWriter.newDocument();
+    doc.addAtom("id", "1");
 
     Shape area = ctx.makeRectangle(-122.82, -122.78, 48.54, 48.56);
 
-    Field[] fields = strategy.createIndexableFields(area, 0.025);
-    for (Field field : fields) {
-      doc.add(field);
-    }
+    strategy.addFields(doc, area, 0.025);
     addDocument(doc);
 
     Point upperleft = ctx.makePoint(-122.88, 48.54);
     Point lowerright = ctx.makePoint(-122.82, 48.62);
 
-    Query query = strategy.makeQuery(new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));
+    Query query = strategy.makeQuery(fieldTypes, new SpatialArgs(SpatialOperation.Intersects, ctx.makeRectangle(upperleft, lowerright)));
 
     commit();
 
@@ -112,4 +110,4 @@ public class SpatialPrefixTreeTest exten
     assertEquals(1, search.totalHits);
   }
 
-}
\ No newline at end of file
+}

Modified: lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/serialized/SerializedStrategyTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/serialized/SerializedStrategyTest.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/serialized/SerializedStrategyTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/serialized/SerializedStrategyTest.java Thu Nov 27 11:34:43 2014
@@ -47,7 +47,7 @@ public class SerializedStrategyTest exte
   //called by StrategyTestCase; we can't let it call our makeQuery which will UOE ex.
   @Override
   protected Query makeQuery(SpatialTestQuery q) {
-    return new FilteredQuery(new MatchAllDocsQuery(), strategy.makeFilter(q.args),
+    return new FilteredQuery(new MatchAllDocsQuery(), strategy.makeFilter(fieldTypes, q.args),
         FilteredQuery.QUERY_FIRST_FILTER_STRATEGY);
   }
 

Modified: lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java (original)
+++ lucene/dev/branches/lucene6005/lucene/spatial/src/test/org/apache/lucene/spatial/vector/TestPointVectorStrategy.java Thu Nov 27 11:34:43 2014
@@ -41,10 +41,11 @@ public class TestPointVectorStrategy ext
   }
 
   @Test
-  public void testCircleShapeSupport() {
+  public void testCircleShapeSupport() throws Exception {
+    adoc("1", ctx.makePoint(0, 0));
     Circle circle = ctx.makeCircle(ctx.makePoint(0, 0), 10);
     SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, circle);
-    Query query = this.strategy.makeQuery(args);
+    Query query = this.strategy.makeQuery(fieldTypes, args);
 
     assertNotNull(query);
   }
@@ -53,7 +54,7 @@ public class TestPointVectorStrategy ext
   public void testInvalidQueryShape() {
     Point point = ctx.makePoint(0, 0);
     SpatialArgs args = new SpatialArgs(SpatialOperation.Intersects, point);
-    this.strategy.makeQuery(args);
+    this.strategy.makeQuery(fieldTypes, args);
   }
 
   @Test

Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/AnalyzingSuggesterTest.java Thu Nov 27 11:34:43 2014
@@ -47,13 +47,17 @@ import org.apache.lucene.analysis.TokenS
 import org.apache.lucene.analysis.Tokenizer;
 import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
 import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.search.suggest.Lookup.LookupResult;
+import org.apache.lucene.index.IndexWriter;
 import org.apache.lucene.search.suggest.Input;
 import org.apache.lucene.search.suggest.InputArrayIterator;
+import org.apache.lucene.search.suggest.Lookup.LookupResult;
+import org.apache.lucene.store.Directory;
 import org.apache.lucene.util.AttributeFactory;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LineFileDocsText;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.TestUtil;
 
@@ -159,14 +163,13 @@ public class AnalyzingSuggesterTest exte
   }
   
   public void testRandomRealisticKeys() throws IOException {
-    LineFileDocs lineFile = new LineFileDocs(random());
+    LineFileDocsText lineFile = new LineFileDocsText(random());
     Map<String, Long> mapping = new HashMap<>();
     List<Input> keys = new ArrayList<>();
     
     int howMany = atLeast(100); // this might bring up duplicates
     for (int i = 0; i < howMany; i++) {
-      Document nextDoc = lineFile.nextDoc();
-      String title = nextDoc.getField("title").stringValue();
+      String title = lineFile.nextDoc().title;
       int randomWeight = random().nextInt(100);
       keys.add(new Input(title, randomWeight));
       if (!mapping.containsKey(title) || mapping.get(title) < randomWeight) {

Modified: lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java (original)
+++ lucene/dev/branches/lucene6005/lucene/suggest/src/test/org/apache/lucene/search/suggest/analyzing/TestFreeTextSuggester.java Thu Nov 27 11:34:43 2014
@@ -38,11 +38,12 @@ import org.apache.lucene.analysis.MockTo
 import org.apache.lucene.analysis.Tokenizer;
 import org.apache.lucene.analysis.core.StopFilter;
 import org.apache.lucene.analysis.util.CharArraySet;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
-import org.apache.lucene.search.suggest.Lookup.LookupResult;
 import org.apache.lucene.search.suggest.Input;
 import org.apache.lucene.search.suggest.InputArrayIterator;
 import org.apache.lucene.search.suggest.InputIterator;
+import org.apache.lucene.search.suggest.Lookup.LookupResult;
 import org.apache.lucene.util.BytesRef;
 import org.apache.lucene.util.LineFileDocs;
 import org.apache.lucene.util.LuceneTestCase;
@@ -131,7 +132,7 @@ public class TestFreeTextSuggester exten
 
   @Ignore
   public void testWiki() throws Exception {
-    final LineFileDocs lfd = new LineFileDocs(null, "/lucenedata/enwiki/enwiki-20120502-lines-1k.txt", false);
+    final LineFileDocs lfd = new LineFileDocs(null, null, "/lucenedata/enwiki/enwiki-20120502-lines-1k.txt");
     // Skip header:
     lfd.nextDoc();
     FreeTextSuggester sug = new FreeTextSuggester(new MockAnalyzer(random()));
@@ -146,7 +147,7 @@ public class TestFreeTextSuggester exten
 
         @Override
         public BytesRef next() {
-          Document doc;
+          Document2 doc;
           try {
             doc = lfd.nextDoc();
           } catch (IOException ioe) {
@@ -158,7 +159,7 @@ public class TestFreeTextSuggester exten
           if (count++ == 10000) {
             return null;
           }
-          return new BytesRef(doc.get("body"));
+          return new BytesRef(doc.getString("body"));
         }
 
         @Override

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/BaseTokenStreamTestCase.java Thu Nov 27 11:34:43 2014
@@ -44,6 +44,7 @@ import org.apache.lucene.util.AttributeF
 import org.apache.lucene.util.AttributeImpl;
 import org.apache.lucene.util.IOUtils;
 import org.apache.lucene.util.LineFileDocs;
+import org.apache.lucene.util.LineFileDocsText;
 import org.apache.lucene.util.LuceneTestCase;
 import org.apache.lucene.util.Rethrow;
 import org.apache.lucene.util.TestUtil;
@@ -551,9 +552,9 @@ public abstract class BaseTokenStreamTes
 
   private static void checkRandomData(Random random, Analyzer a, int iterations, int maxWordLength, boolean useCharFilter, boolean simple, boolean offsetsAreCorrect, RandomIndexWriter iw) throws IOException {
 
-    final LineFileDocs docs = new LineFileDocs(random);
     StringReader bogus = new StringReader("");
     Document2 doc = null;
+    final LineFileDocsText docs = new LineFileDocsText(random);
     if (iw != null) {
       FieldTypes fieldTypes = iw.getFieldTypes();
       doc = iw.newDocument();
@@ -598,6 +599,7 @@ public abstract class BaseTokenStreamTes
       fieldTypes.disableHighlighting("dummy");
       fieldTypes.disableStored("dummy");
       fieldTypes.setIndexOptions("dummy", indexOptions);
+      fieldTypes.setMultiValued("dummy");
     }
     
     try {
@@ -606,7 +608,7 @@ public abstract class BaseTokenStreamTes
         
         if (random.nextInt(10) == 7) {
           // real data from linedocs
-          text = docs.nextDoc().get("body");
+          text = docs.nextDoc().body;
           if (text.length() > maxWordLength) {
             
             // Take a random slice from the text...:

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/analysis/CollationTestBase.java Thu Nov 27 11:34:43 2014
@@ -62,9 +62,9 @@ public abstract class CollationTestBase 
                                             BytesRef secondEnd) throws Exception {
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(analyzer));
-    Document doc = new Document();
-    doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
-    doc.add(new StringField("body", "body", Field.Store.YES));
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "\u0633\u0627\u0628");
+    doc.addAtom("body", "body");
     writer.addDocument(doc);
     writer.close();
     IndexReader reader = DirectoryReader.open(dir);
@@ -93,13 +93,13 @@ public abstract class CollationTestBase 
                                             BytesRef secondEnd) throws Exception {
     Directory dir = newDirectory();
     IndexWriter writer = new IndexWriter(dir, new IndexWriterConfig(analyzer));
-    Document doc = new Document();
+    Document2 doc = writer.newDocument();
 
     // Unicode order would include U+0633 in [ U+062F - U+0698 ], but Farsi
     // orders the U+0698 character before the U+0633 character, so the single
     // index Term below should NOT be returned by a TermRangeQuery with a Farsi
     // Collator (or an Arabic one for the case when Farsi is not supported).
-    doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
+    doc.addLargeText("content", "\u0633\u0627\u0628");
     writer.addDocument(doc);
     writer.close();
     IndexReader reader = DirectoryReader.open(dir);
@@ -121,9 +121,9 @@ public abstract class CollationTestBase 
 
     Directory farsiIndex = newDirectory();
     IndexWriter writer = new IndexWriter(farsiIndex, new IndexWriterConfig(analyzer));
-    Document doc = new Document();
-    doc.add(new TextField("content", "\u0633\u0627\u0628", Field.Store.YES));
-    doc.add(new StringField("body", "body", Field.Store.YES));
+    Document2 doc = writer.newDocument();
+    doc.addLargeText("content", "\u0633\u0627\u0628");
+    doc.addAtom("body", "body");
     writer.addDocument(doc);
     writer.close();
 

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/asserting/AssertingDocValuesFormat.java Thu Nov 27 11:34:43 2014
@@ -67,6 +67,11 @@ public class AssertingDocValuesFormat ex
     assert producer != null;
     return new AssertingDocValuesProducer(producer, state.segmentInfo.getDocCount());
   }
+
+  @Override
+  public String toString() {
+    return "AssertingDocValuesFormat(" + in + ")";
+  }
   
   static class AssertingDocValuesConsumer extends DocValuesConsumer {
     private final DocValuesConsumer in;

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/codecs/mockrandom/MockRandomPostingsFormat.java Thu Nov 27 11:34:43 2014
@@ -98,7 +98,7 @@ public final class MockRandomPostingsFor
     int skipInterval = TestUtil.nextInt(seedRandom, minSkipInterval, 10);
     
     if (LuceneTestCase.VERBOSE) {
-      System.out.println("MockRandomCodec: skipInterval=" + skipInterval);
+      System.out.println("MockRandomCodec: skipInterval=" + skipInterval + " seedRandom=" + seedRandom);
     }
     
     final long seed = seedRandom.nextLong();

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/document/LowSchemaField.java Thu Nov 27 11:34:43 2014
@@ -29,7 +29,8 @@ import org.apache.lucene.index.Indexable
 import org.apache.lucene.util.BytesRef;
 
 /**
- * A minimal implementation of Lucene's low-schema API, for abusing your schema.
+ * A minimal implementation of Lucene's low-schema API, that does absolutely no "user space" validation, for abusing your schema and
+ * stressing out Lucene's IndexWriter to ensure it never corrupts the index on abuse.
  */
 
 public class LowSchemaField implements IndexableFieldType, IndexableField {

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompoundFormatTestCase.java Thu Nov 27 11:34:43 2014
@@ -24,6 +24,7 @@ import java.util.Collections;
 import java.util.List;
 
 import org.apache.lucene.codecs.Codec;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
 import org.apache.lucene.document.Field;
 import org.apache.lucene.document.StoredField;
@@ -734,8 +735,8 @@ public abstract class BaseCompoundFormat
   }
 
   @Override
-  protected void addRandomFields(Document doc) {
-    doc.add(new StoredField("foobar", TestUtil.randomSimpleString(random())));
+  protected void addRandomFields(Document2 doc) {
+    doc.addStored("foobar", TestUtil.randomSimpleString(random()));
   }
 
   @Override

Modified: lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java?rev=1642110&r1=1642109&r2=1642110&view=diff
==============================================================================
--- lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java (original)
+++ lucene/dev/branches/lucene6005/lucene/test-framework/src/java/org/apache/lucene/index/BaseCompressingDocValuesFormatTestCase.java Thu Nov 27 11:34:43 2014
@@ -22,13 +22,14 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.lucene.analysis.MockAnalyzer;
+import org.apache.lucene.document.Document2;
 import org.apache.lucene.document.Document;
+import org.apache.lucene.document.FieldTypes;
 import org.apache.lucene.document.NumericDocValuesField;
 import org.apache.lucene.store.Directory;
 import org.apache.lucene.store.RAMDirectory;
 import org.apache.lucene.util.TestUtil;
 import org.apache.lucene.util.packed.PackedInts;
-
 import com.carrotsearch.randomizedtesting.generators.RandomPicks;
 
 /** Extends {@link BaseDocValuesFormatTestCase} to add compression checks. */
@@ -46,13 +47,14 @@ public abstract class BaseCompressingDoc
     final Directory dir = new RAMDirectory();
     final IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     final IndexWriter iwriter = new IndexWriter(dir, iwc);
+    FieldTypes fieldTypes = iwriter.getFieldTypes();
+    fieldTypes.setIndexOptions("dv", IndexOptions.NONE);
+    fieldTypes.disableStored("dv");
+
 
     final int uniqueValueCount = TestUtil.nextInt(random(), 1, 256);
     final List<Long> values = new ArrayList<>();
 
-    final Document doc = new Document();
-    final NumericDocValuesField dvf = new NumericDocValuesField("dv", 0);
-    doc.add(dvf);
     for (int i = 0; i < 300; ++i) {
       final long value;
       if (values.size() < uniqueValueCount) {
@@ -61,13 +63,15 @@ public abstract class BaseCompressingDoc
       } else {
         value = RandomPicks.randomFrom(random(), values);
       }
-      dvf.setLongValue(value);
+      final Document2 doc = iwriter.newDocument();
+      doc.addLong("dv", value);
       iwriter.addDocument(doc);
     }
     iwriter.forceMerge(1);
     final long size1 = dirSize(dir);
     for (int i = 0; i < 20; ++i) {
-      dvf.setLongValue(RandomPicks.randomFrom(random(), values));
+      final Document2 doc = iwriter.newDocument();
+      doc.addLong("dv", RandomPicks.randomFrom(random(), values));
       iwriter.addDocument(doc);
     }
     iwriter.forceMerge(1);
@@ -80,21 +84,23 @@ public abstract class BaseCompressingDoc
     final Directory dir = new RAMDirectory();
     final IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     final IndexWriter iwriter = new IndexWriter(dir, iwc);
+    FieldTypes fieldTypes = iwriter.getFieldTypes();
+    fieldTypes.setIndexOptions("dv", IndexOptions.NONE);
+    fieldTypes.disableStored("dv");
 
     final long base = 13; // prime
     final long day = 1000L * 60 * 60 * 24;
 
-    final Document doc = new Document();
-    final NumericDocValuesField dvf = new NumericDocValuesField("dv", 0);
-    doc.add(dvf);
     for (int i = 0; i < 300; ++i) {
-      dvf.setLongValue(base + random().nextInt(1000) * day);
+      final Document2 doc = iwriter.newDocument();
+      doc.addLong("dv", base + random().nextInt(1000) * day);
       iwriter.addDocument(doc);
     }
     iwriter.forceMerge(1);
     final long size1 = dirSize(dir);
     for (int i = 0; i < 50; ++i) {
-      dvf.setLongValue(base + random().nextInt(1000) * day);
+      final Document2 doc = iwriter.newDocument();
+      doc.addLong("dv", base + random().nextInt(1000) * day);
       iwriter.addDocument(doc);
     }
     iwriter.forceMerge(1);
@@ -107,17 +113,19 @@ public abstract class BaseCompressingDoc
     final Directory dir = new RAMDirectory();
     final IndexWriterConfig iwc = new IndexWriterConfig(new MockAnalyzer(random()));
     final IndexWriter iwriter = new IndexWriter(dir, iwc);
+    FieldTypes fieldTypes = iwriter.getFieldTypes();
+    fieldTypes.setIndexOptions("dv", IndexOptions.NONE);
+    fieldTypes.disableStored("dv");
 
-    final Document doc = new Document();
-    final NumericDocValuesField dvf = new NumericDocValuesField("dv", 0);
-    doc.add(dvf);
     for (int i = 0; i < 20000; ++i) {
-      dvf.setLongValue(i & 1023);
+      final Document2 doc = iwriter.newDocument();
+      doc.addLong("dv", i & 1023);
       iwriter.addDocument(doc);
     }
     iwriter.forceMerge(1);
     final long size1 = dirSize(dir);
-    dvf.setLongValue(Long.MAX_VALUE);
+    final Document2 doc = iwriter.newDocument();
+    doc.addLong("dv", Long.MAX_VALUE);
     iwriter.addDocument(doc);
     iwriter.forceMerge(1);
     final long size2 = dirSize(dir);