lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rm...@apache.org
Subject svn commit: r1441302 - in /lucene/dev/branches/lucene4547/lucene: core/src/test/org/apache/lucene/codecs/lucene41/ test-framework/src/java/org/apache/lucene/index/
Date Fri, 01 Feb 2013 03:22:13 GMT
Author: rmuir
Date: Fri Feb  1 03:22:12 2013
New Revision: 1441302

URL: http://svn.apache.org/viewvc?rev=1441302&view=rev
Log:
remove the crutch

Modified:
    lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
    lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
    lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java

Modified: lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java?rev=1441302&r1=1441301&r2=1441302&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/core/src/test/org/apache/lucene/codecs/lucene41/TestBlockPostingsFormat2.java
Fri Feb  1 03:22:12 2013
@@ -47,7 +47,6 @@ public class TestBlockPostingsFormat2 ex
     iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
     iwc.setCodec(_TestUtil.alwaysPostingsFormat(new Lucene41PostingsFormat()));
     iw = new RandomIndexWriter(random(), dir, iwc);
-    iw.setAddDocValuesFields(false);
     iw.setDoRandomForceMerge(false); // we will ourselves
   }
   

Modified: lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java?rev=1441302&r1=1441301&r2=1441302&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/BaseDocValuesFormatTestCase.java
Fri Feb  1 03:22:12 2013
@@ -79,12 +79,8 @@ public abstract class BaseDocValuesForma
   }
 
   public void testOneNumber() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -115,12 +111,8 @@ public abstract class BaseDocValuesForma
   }
 
   public void testOneFloat() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -151,12 +143,8 @@ public abstract class BaseDocValuesForma
   }
   
   public void testTwoNumbers() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -190,12 +178,8 @@ public abstract class BaseDocValuesForma
   }
 
   public void testTwoFieldsMixed() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -231,12 +215,8 @@ public abstract class BaseDocValuesForma
   }
   
   public void testThreeFieldsMixed() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -277,12 +257,8 @@ public abstract class BaseDocValuesForma
   }
   
   public void testThreeFieldsMixed2() throws IOException {
-    Analyzer analyzer = new MockAnalyzer(random());
-
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
-    IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -326,10 +302,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", 1));
     iwriter.addDocument(doc);
@@ -354,10 +329,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(newField("id", "0", StringField.TYPE_STORED));
     doc.add(new NumericDocValuesField("dv", -10));
@@ -393,10 +367,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", Long.MIN_VALUE));
     iwriter.addDocument(doc);
@@ -421,10 +394,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new NumericDocValuesField("dv", -8841491950446638677L));
     iwriter.addDocument(doc);
@@ -449,9 +421,8 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -487,10 +458,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(newField("id", "0", StringField.TYPE_STORED));
     doc.add(new BinaryDocValuesField("dv", new BytesRef("hello world 1")));
@@ -528,9 +498,8 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     String longTerm = "longtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongtermlongterm";
     String text = "This is the text to be indexed. " + longTerm;
@@ -566,10 +535,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 1")));
     iwriter.addDocument(doc);
@@ -597,10 +565,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 1")));
     iwriter.addDocument(doc);
@@ -635,10 +602,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(newField("id", "0", StringField.TYPE_STORED));
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 1")));
@@ -681,10 +647,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("hello\nworld\r1")));
     iwriter.addDocument(doc);
@@ -706,10 +671,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("hello world 2")));
     iwriter.addDocument(doc);
@@ -734,10 +698,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("")));
     iwriter.addDocument(doc);
@@ -765,10 +728,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("")));
     iwriter.addDocument(doc);
@@ -796,10 +758,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     byte bytes[] = new byte[32766];
     BytesRef b = new BytesRef(bytes);
@@ -824,10 +785,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     byte bytes[] = new byte[32766];
     BytesRef b = new BytesRef(bytes);
@@ -851,10 +811,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("boo!")));
     iwriter.addDocument(doc);
@@ -878,10 +837,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("boo!")));
     iwriter.addDocument(doc);
@@ -905,10 +863,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new BinaryDocValuesField("dv", new BytesRef("foo!")));
     iwriter.addDocument(doc);
@@ -939,10 +896,9 @@ public abstract class BaseDocValuesForma
     Analyzer analyzer = new MockAnalyzer(random());
 
     Directory directory = newDirectory();
-    // we don't use RandomIndexWriter because it might add more docvalues than we expect
!!!!
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, analyzer);
     conf.setMergePolicy(newLogMergePolicy());
-    IndexWriter iwriter = new IndexWriter(directory, conf);
+    RandomIndexWriter iwriter = new RandomIndexWriter(random(), directory, conf);
     Document doc = new Document();
     doc.add(new SortedDocValuesField("dv", new BytesRef("foo!")));
     iwriter.addDocument(doc);
@@ -1016,7 +972,7 @@ public abstract class BaseDocValuesForma
   public void testRandomSortedBytes() throws IOException {
     Directory dir = newDirectory();
     IndexWriterConfig cfg = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
-    IndexWriter w = new IndexWriter(dir, cfg);
+    RandomIndexWriter w = new RandomIndexWriter(random(), dir, cfg);
     int numDocs = atLeast(100);
     BytesRefHash hash = new BytesRefHash();
     Map<String, String> docToString = new HashMap<String, String>();
@@ -1090,7 +1046,7 @@ public abstract class BaseDocValuesForma
   private void doTestNumericsVsStoredFields(long minValue, long maxValue) throws Exception
{
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
-    IndexWriter writer = new IndexWriter(dir, conf);
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
     Document doc = new Document();
     Field idField = new StringField("id", "", Field.Store.NO);
     Field storedField = newStringField("stored", "", Field.Store.YES);
@@ -1157,7 +1113,7 @@ public abstract class BaseDocValuesForma
   private void doTestBinaryVsStoredFields(int minLength, int maxLength) throws Exception
{
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
-    IndexWriter writer = new IndexWriter(dir, conf);
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
     Document doc = new Document();
     Field idField = new StringField("id", "", Field.Store.NO);
     Field storedField = new StoredField("stored", new byte[0]);
@@ -1222,7 +1178,7 @@ public abstract class BaseDocValuesForma
   private void doTestSortedVsStoredFields(int minLength, int maxLength) throws Exception
{
     Directory dir = newDirectory();
     IndexWriterConfig conf = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
-    IndexWriter writer = new IndexWriter(dir, conf);
+    RandomIndexWriter writer = new RandomIndexWriter(random(), dir, conf);
     Document doc = new Document();
     Field idField = new StringField("id", "", Field.Store.NO);
     Field storedField = new StoredField("stored", new byte[0]);

Modified: lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java?rev=1441302&r1=1441301&r2=1441302&view=diff
==============================================================================
--- lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
(original)
+++ lucene/dev/branches/lucene4547/lucene/test-framework/src/java/org/apache/lucene/index/RandomIndexWriter.java
Fri Feb  1 03:22:12 2013
@@ -53,11 +53,6 @@ public class RandomIndexWriter implement
   int flushAt;
   private double flushAtFactor = 1.0;
   private boolean getReaderCalled;
-  private final int fixedBytesLength;
-  private final long docValuesFieldPrefix;
-  // nocommit: remove this test coverage hack once we have a 
-  // good set of real tests.
-  private volatile boolean doDocValues;
   private final Codec codec; // sugar
 
   // Randomly calls Thread.yield so we mixup thread scheduling
@@ -105,49 +100,12 @@ public class RandomIndexWriter implement
       System.out.println("RIW dir=" + dir + " config=" + w.getConfig());
       System.out.println("codec default=" + codec.getName());
     }
-    /* TODO: find some way to make this random...
-     * This must be fixed across all fixed bytes 
-     * fields in one index. so if you open another writer
-     * this might change if I use r.nextInt(x)
-     * maybe we can peek at the existing files here? 
-     */
-    fixedBytesLength = 17; 
-
-    // NOTE: this means up to 13 * 5 unique fields (we have
-    // 13 different DV types):
-    docValuesFieldPrefix = r.nextInt(5);
-    switchDoDocValues();
 
     // Make sure we sometimes test indices that don't get
     // any forced merges:
     doRandomForceMerge = r.nextBoolean();
   } 
   
-  private boolean addDocValuesFields = true;
-  
-  /**
-   * set to false if you don't want RandomIndexWriter
-   * adding docvalues fields.
-   */
-  public void setAddDocValuesFields(boolean v) {
-    addDocValuesFields = v;
-    switchDoDocValues();
-  }
-
-  private void switchDoDocValues() {
-    if (addDocValuesFields == false) {
-      doDocValues = false;
-      return;
-    }
-    // randomly enable / disable docValues 
-    doDocValues = LuceneTestCase.rarely(r);
-    if (LuceneTestCase.VERBOSE) {
-      if (doDocValues) {
-        System.out.println("NOTE: RIW: turning on random DocValues fields");
-      }
-    }
-  }
-  
   /**
    * Adds a Document.
    * @see IndexWriter#addDocument(org.apache.lucene.index.IndexDocument)
@@ -157,9 +115,6 @@ public class RandomIndexWriter implement
   }
 
   public <T extends IndexableField> void addDocument(final IndexDocument doc, Analyzer
a) throws IOException {
-    if (doDocValues && doc instanceof Document) {
-      randomPerDocFieldValues((Document) doc);
-    }
     if (r.nextInt(5) == 3) {
       // TODO: maybe, we should simply buffer up added docs
       // (but we need to clone them), and only when
@@ -200,43 +155,6 @@ public class RandomIndexWriter implement
     maybeCommit();
   }
 
-  private BytesRef getFixedRandomBytes() {
-    final String randomUnicodeString = _TestUtil.randomFixedByteLengthUnicodeString(r, fixedBytesLength);
-    BytesRef fixedRef = new BytesRef(randomUnicodeString);
-    if (fixedRef.length > fixedBytesLength) {
-      fixedRef = new BytesRef(fixedRef.bytes, 0, fixedBytesLength);
-    } else {
-      fixedRef.grow(fixedBytesLength);
-      fixedRef.length = fixedBytesLength;
-    }
-    return fixedRef;
-  }
-  
-  private void randomPerDocFieldValues(Document doc) {
-    
-    DocValuesType[] values = DocValuesType.values();
-    DocValuesType type = values[r.nextInt(values.length)];
-    String name = "random_" + type.name() + "" + docValuesFieldPrefix;
-    if (doc.getField(name) != null) {
-      return;
-    }
-    final Field f;
-    switch (type) {
-    case BINARY:
-      f = new BinaryDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)));
-      break;
-    case SORTED:
-      f = new SortedDocValuesField(name, new BytesRef(_TestUtil.randomUnicodeString(r, 20)));
-      break;
-    case NUMERIC:
-      f = new NumericDocValuesField(name, r.nextLong());
-      break;
-    default:
-      throw new IllegalArgumentException("no such type: " + type);
-    }
-    doc.add(f);
-  }
-
   private void maybeCommit() throws IOException {
     if (docCount++ == flushAt) {
       if (LuceneTestCase.VERBOSE) {
@@ -248,7 +166,6 @@ public class RandomIndexWriter implement
         // gradually but exponentially increase time b/w flushes
         flushAtFactor *= 1.05;
       }
-      switchDoDocValues();
     }
   }
   
@@ -267,9 +184,6 @@ public class RandomIndexWriter implement
    * @see IndexWriter#updateDocument(Term, org.apache.lucene.index.IndexDocument)
    */
   public <T extends IndexableField> void updateDocument(Term t, final IndexDocument
doc) throws IOException {
-    if (doDocValues) {
-      randomPerDocFieldValues((Document) doc);
-    }
     if (r.nextInt(5) == 3) {
       w.updateDocuments(t, new Iterable<IndexDocument>() {
 
@@ -323,7 +237,6 @@ public class RandomIndexWriter implement
   
   public void commit() throws IOException {
     w.commit();
-    switchDoDocValues();
   }
   
   public int numDocs() {
@@ -380,7 +293,6 @@ public class RandomIndexWriter implement
         assert !doRandomForceMergeAssert || w.getSegmentCount() <= limit: "limit=" + limit
+ " actual=" + w.getSegmentCount();
       }
     }
-    switchDoDocValues();
   }
 
   public DirectoryReader getReader(boolean applyDeletions) throws IOException {
@@ -401,7 +313,6 @@ public class RandomIndexWriter implement
         System.out.println("RIW.getReader: open new reader");
       }
       w.commit();
-      switchDoDocValues();
       if (r.nextBoolean()) {
         return DirectoryReader.open(w.getDirectory(), _TestUtil.nextInt(r, 1, 10));
       } else {



Mime
View raw message