You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ro...@apache.org on 2013/01/18 19:31:23 UTC
svn commit: r1435287 [11/41] - in /lucene/dev/branches/LUCENE-2878: ./
dev-tools/ dev-tools/eclipse/ dev-tools/idea/.idea/libraries/
dev-tools/idea/lucene/analysis/icu/ dev-tools/maven/
dev-tools/maven/lucene/benchmark/ dev-tools/maven/solr/ dev-tools/...
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/BinaryTokenStream.java Fri Jan 18 18:30:54 2013
@@ -58,18 +58,22 @@ public final class BinaryTokenStream ext
public static class ByteTermAttributeImpl extends AttributeImpl implements ByteTermAttribute,TermToBytesRefAttribute {
private BytesRef bytes;
+ @Override
public int fillBytesRef() {
return bytes.hashCode();
}
+ @Override
public BytesRef getBytesRef() {
return bytes;
}
+ @Override
public void setBytesRef(BytesRef bytes) {
this.bytes = bytes;
}
+ @Override
public void clear() {}
@Override
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/Test2BTerms.java Fri Jan 18 18:30:54 2013
@@ -86,10 +86,12 @@ public class Test2BTerms extends LuceneT
}
private final static class MyTermAttributeImpl extends AttributeImpl implements TermToBytesRefAttribute {
+ @Override
public int fillBytesRef() {
return bytes.hashCode();
}
+ @Override
public BytesRef getBytesRef() {
return bytes;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestAddIndexes.java Fri Jan 18 18:30:54 2013
@@ -537,7 +537,7 @@ public class TestAddIndexes extends Luce
private void verifyTermDocs(Directory dir, Term term, int numDocs)
throws IOException {
IndexReader reader = DirectoryReader.open(dir);
- DocsEnum docsEnum = _TestUtil.docs(random(), reader, term.field, term.bytes, null, null, 0);
+ DocsEnum docsEnum = _TestUtil.docs(random(), reader, term.field, term.bytes, null, null, DocsEnum.FLAG_NONE);
int count = 0;
while (docsEnum.nextDoc() != DocIdSetIterator.NO_MORE_DOCS)
count++;
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java Fri Jan 18 18:30:54 2013
@@ -58,7 +58,6 @@ import org.apache.lucene.search.ScoreDoc
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.store.BaseDirectoryWrapper;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
@@ -82,14 +81,22 @@ import org.junit.BeforeClass;
@SuppressCodecs({"MockFixedIntBlock", "MockVariableIntBlock", "MockSep", "MockRandom"})
public class TestBackwardsCompatibility extends LuceneTestCase {
- // Uncomment these cases & run them on an older Lucene
- // version, to generate an index to test backwards
- // compatibility. Then, cd to build/test/index.cfs and
- // run "zip index.<VERSION>.cfs.zip *"; cd to
- // build/test/index.nocfs and run "zip
- // index.<VERSION>.nocfs.zip *". Then move those 2 zip
- // files to your trunk checkout and add them to the
- // oldNames array.
+ // Uncomment these cases & run them on an older Lucene version,
+ // to generate indexes to test backwards compatibility. These
+ // indexes will be created under directory /tmp/idx/.
+ //
+ // However, you must first disable the Lucene TestSecurityManager,
+ // which will otherwise disallow writing outside of the build/
+ // directory - to do this, comment out the "java.security.manager"
+ // <sysproperty> under the "test-macro" <macrodef>.
+ //
+ // Zip up the generated indexes:
+ //
+ // cd /tmp/idx/index.cfs ; zip index.<VERSION>.cfs.zip *
+ // cd /tmp/idx/index.nocfs ; zip index.<VERSION>.nocfs.zip *
+ //
+ // Then move those 2 zip files to your trunk checkout and add them
+ // to the oldNames array.
/*
public void testCreateCFS() throws IOException {
@@ -100,7 +107,7 @@ public class TestBackwardsCompatibility
createIndex("index.nocfs", false, false);
}
*/
-
+
/*
// These are only needed for the special upgrade test to verify
// that also single-segment indexes are correctly upgraded by IndexUpgrader.
@@ -116,8 +123,42 @@ public class TestBackwardsCompatibility
}
*/
+
+ /*
+ public void testCreateMoreTermsIndex() throws Exception {
+ // we use a real directory name that is not cleaned up,
+ // because this method is only used to create backwards
+ // indexes:
+ File indexDir = new File("moreterms");
+ _TestUtil.rmDir(indexDir);
+ Directory dir = newFSDirectory(indexDir);
+
+ LogByteSizeMergePolicy mp = new LogByteSizeMergePolicy();
+ mp.setUseCompoundFile(false);
+ mp.setNoCFSRatio(1.0);
+ mp.setMaxCFSSegmentSizeMB(Double.POSITIVE_INFINITY);
+ // TODO: remove randomness
+ IndexWriterConfig conf = new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()))
+ .setMergePolicy(mp);
+ conf.setCodec(Codec.forName("Lucene40"));
+ IndexWriter writer = new IndexWriter(dir, conf);
+ LineFileDocs docs = new LineFileDocs(null, true);
+ for(int i=0;i<50;i++) {
+ writer.addDocument(docs.nextDoc());
+ }
+ writer.close();
+ dir.close();
+
+ // Gives you time to copy the index out!: (there is also
+ // a test option to not remove temp dir...):
+ Thread.sleep(100000);
+ }
+ */
+
final static String[] oldNames = {"40.cfs",
- "40.nocfs",
+ "40.nocfs",
+ "41.cfs",
+ "41.nocfs",
};
final String[] unsupportedNames = {"19.cfs",
@@ -145,7 +186,7 @@ public class TestBackwardsCompatibility
};
final static String[] oldSingleSegmentNames = {"40.optimized.cfs",
- "40.optimized.nocfs",
+ "40.optimized.nocfs",
};
static Map<String,Directory> oldIndexDirs;
@@ -506,7 +547,7 @@ public class TestBackwardsCompatibility
public File createIndex(String dirName, boolean doCFS, boolean fullyMerged) throws IOException {
// we use a real directory name that is not cleaned up, because this method is only used to create backwards indexes:
- File indexDir = new File("/tmp/4x", dirName);
+ File indexDir = new File("/tmp/idx", dirName);
_TestUtil.rmDir(indexDir);
Directory dir = newFSDirectory(indexDir);
LogByteSizeMergePolicy mp = new LogByteSizeMergePolicy();
@@ -725,7 +766,7 @@ public class TestBackwardsCompatibility
// should be found exactly
assertEquals(TermsEnum.SeekStatus.FOUND,
terms.seekCeil(aaaTerm));
- assertEquals(35, countDocs(_TestUtil.docs(random(), terms, null, null, 0)));
+ assertEquals(35, countDocs(_TestUtil.docs(random(), terms, null, null, DocsEnum.FLAG_NONE)));
assertNull(terms.next());
// should hit end of field
@@ -737,12 +778,12 @@ public class TestBackwardsCompatibility
assertEquals(TermsEnum.SeekStatus.NOT_FOUND,
terms.seekCeil(new BytesRef("a")));
assertTrue(terms.term().bytesEquals(aaaTerm));
- assertEquals(35, countDocs(_TestUtil.docs(random(), terms, null, null, 0)));
+ assertEquals(35, countDocs(_TestUtil.docs(random(), terms, null, null, DocsEnum.FLAG_NONE)));
assertNull(terms.next());
assertEquals(TermsEnum.SeekStatus.FOUND,
terms.seekCeil(aaaTerm));
- assertEquals(35, countDocs(_TestUtil.docs(random(), terms,null, null, 0)));
+ assertEquals(35, countDocs(_TestUtil.docs(random(), terms,null, null, DocsEnum.FLAG_NONE)));
assertNull(terms.next());
r.close();
@@ -908,4 +949,15 @@ public class TestBackwardsCompatibility
dir.close();
}
}
+
+ public static final String moreTermsIndex = "moreterms.40.zip";
+
+ public void testMoreTerms() throws Exception {
+ File oldIndexDir = _TestUtil.getTempDir("moreterms");
+ _TestUtil.unzip(getDataFile(moreTermsIndex), oldIndexDir);
+ Directory dir = newFSDirectory(oldIndexDir);
+ // TODO: more tests
+ _TestUtil.checkIndex(dir);
+ dir.close();
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPositions.java Fri Jan 18 18:30:54 2013
@@ -24,6 +24,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
+import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.FieldType;
@@ -47,7 +48,9 @@ public class TestBagOfPositions extends
final int maxTermsPerDoc = _TestUtil.nextInt(random(), 10, 20);
boolean isSimpleText = "SimpleText".equals(_TestUtil.getPostingsFormat("field"));
- if (isSimpleText && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
+ IndexWriterConfig iwc = newIndexWriterConfig(random(), TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+
+ if ((isSimpleText || iwc.getMergePolicy() instanceof MockRandomMergePolicy) && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
// Otherwise test can take way too long (> 2 hours)
numTerms /= 2;
}
@@ -66,7 +69,8 @@ public class TestBagOfPositions extends
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<String>(postingsList);
Directory dir = newFSDirectory(_TestUtil.getTempDir("bagofpositions"));
- final RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+
+ final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
int threadCount = _TestUtil.nextInt(random(), 1, 5);
if (VERBOSE) {
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestBagOfPostings.java Fri Jan 18 18:30:54 2013
@@ -25,6 +25,7 @@ import java.util.Set;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CountDownLatch;
+import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
@@ -46,7 +47,9 @@ public class TestBagOfPostings extends L
boolean isSimpleText = "SimpleText".equals(_TestUtil.getPostingsFormat("field"));
- if (isSimpleText && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
+ IndexWriterConfig iwc = newIndexWriterConfig(random(), TEST_VERSION_CURRENT, new MockAnalyzer(random()));
+
+ if ((isSimpleText || iwc.getMergePolicy() instanceof MockRandomMergePolicy) && (TEST_NIGHTLY || RANDOM_MULTIPLIER > 1)) {
// Otherwise test can take way too long (> 2 hours)
numTerms /= 2;
}
@@ -67,7 +70,7 @@ public class TestBagOfPostings extends L
final ConcurrentLinkedQueue<String> postings = new ConcurrentLinkedQueue<String>(postingsList);
Directory dir = newFSDirectory(_TestUtil.getTempDir("bagofpostings"));
- final RandomIndexWriter iw = new RandomIndexWriter(random(), dir);
+ final RandomIndexWriter iw = new RandomIndexWriter(random(), dir, iwc);
int threadCount = _TestUtil.nextInt(random(), 1, 5);
if (VERBOSE) {
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCodecs.java Fri Jan 18 18:30:54 2013
@@ -21,6 +21,7 @@ import java.io.IOException;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.codecs.Codec;
@@ -31,7 +32,9 @@ import org.apache.lucene.codecs.TermStat
import org.apache.lucene.codecs.TermsConsumer;
import org.apache.lucene.codecs.mocksep.MockSepPostingsFormat;
import org.apache.lucene.document.Document;
+import org.apache.lucene.document.Field.Store;
import org.apache.lucene.document.FieldType;
+import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.FieldInfo.IndexOptions;
import org.apache.lucene.search.DocIdSetIterator;
@@ -100,6 +103,7 @@ public class TestCodecs extends LuceneTe
Arrays.sort(terms);
}
+ @Override
public int compareTo(final FieldData other) {
return fieldInfo.name.compareTo(other.fieldInfo.name);
}
@@ -145,6 +149,7 @@ public class TestCodecs extends LuceneTe
this.positions = positions;
}
+ @Override
public int compareTo(final TermData o) {
return text.compareTo(o.text);
}
@@ -277,7 +282,7 @@ public class TestCodecs extends LuceneTe
// make sure it properly fully resets (rewinds) its
// internal state:
for(int iter=0;iter<2;iter++) {
- docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, 0);
+ docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, DocsEnum.FLAG_NONE);
assertEquals(terms[i].docs[0], docsEnum.nextDoc());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, docsEnum.nextDoc());
}
@@ -474,7 +479,7 @@ public class TestCodecs extends LuceneTe
assertEquals(status, TermsEnum.SeekStatus.FOUND);
assertEquals(term.docs.length, termsEnum.docFreq());
if (field.omitTF) {
- this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random(), termsEnum, null, null, 0), false);
+ this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random(), termsEnum, null, null, DocsEnum.FLAG_NONE), false);
} else {
this.verifyDocs(term.docs, term.positions, termsEnum.docsAndPositions(null, null), true);
}
@@ -494,7 +499,7 @@ public class TestCodecs extends LuceneTe
assertTrue(termsEnum.term().bytesEquals(new BytesRef(term.text2)));
assertEquals(term.docs.length, termsEnum.docFreq());
if (field.omitTF) {
- this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random(), termsEnum, null, null, 0), false);
+ this.verifyDocs(term.docs, term.positions, _TestUtil.docs(random(), termsEnum, null, null, DocsEnum.FLAG_NONE), false);
} else {
this.verifyDocs(term.docs, term.positions, termsEnum.docsAndPositions(null, null), true);
}
@@ -557,7 +562,7 @@ public class TestCodecs extends LuceneTe
} else {
postings = null;
docsAndFreqs = null;
- docs = _TestUtil.docs(random(), termsEnum, null, null, 0);
+ docs = _TestUtil.docs(random(), termsEnum, null, null, DocsEnum.FLAG_NONE);
}
assertNotNull(docs);
int upto2 = -1;
@@ -628,4 +633,33 @@ public class TestCodecs extends LuceneTe
}
consumer.close();
}
+
+ public void testDocsOnlyFreq() throws Exception {
+ // tests that when fields are indexed with DOCS_ONLY, the Codec
+ // returns 1 in docsEnum.freq()
+ Directory dir = newDirectory();
+ Random random = random();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
+ TEST_VERSION_CURRENT, new MockAnalyzer(random)));
+ // we don't need many documents to assert this, but don't use one document either
+ int numDocs = atLeast(random, 50);
+ for (int i = 0; i < numDocs; i++) {
+ Document doc = new Document();
+ doc.add(new StringField("f", "doc", Store.NO));
+ writer.addDocument(doc);
+ }
+ writer.close();
+
+ Term term = new Term("f", new BytesRef("doc"));
+ DirectoryReader reader = DirectoryReader.open(dir);
+ for (AtomicReaderContext ctx : reader.leaves()) {
+ DocsEnum de = ctx.reader().termDocsEnum(term);
+ while (de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
+ assertEquals("wrong freq for doc " + de.docID(), 1, de.freq());
+ }
+ }
+ reader.close();
+
+ dir.close();
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestCustomNorms.java Fri Jan 18 18:30:54 2013
@@ -22,7 +22,6 @@ import java.util.Random;
import org.apache.lucene.analysis.MockAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
-import org.apache.lucene.document.StringField;
import org.apache.lucene.document.TextField;
import org.apache.lucene.index.DocValues.Source;
import org.apache.lucene.index.DocValues.Type;
@@ -31,12 +30,14 @@ import org.apache.lucene.search.TermStat
import org.apache.lucene.search.similarities.DefaultSimilarity;
import org.apache.lucene.search.similarities.PerFieldSimilarityWrapper;
import org.apache.lucene.search.similarities.Similarity;
+import org.apache.lucene.search.similarities.Similarity.ExactSimScorer;
+import org.apache.lucene.search.similarities.Similarity.SimWeight;
+import org.apache.lucene.search.similarities.Similarity.SloppySimScorer;
import org.apache.lucene.store.Directory;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.apache.lucene.util.LineFileDocs;
import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
/**
*
@@ -86,39 +87,6 @@ public class TestCustomNorms extends Luc
dir.close();
docs.close();
}
-
- public void testPackedNorms() throws IOException {
- Directory dir = newDirectory();
- IndexWriterConfig config = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
- config.setSimilarity(new PackedNormSimilarity());
- RandomIndexWriter writer = new RandomIndexWriter(random(), dir, config);
- int num = _TestUtil.nextInt(random(), 1, 1000);
- for (int i = 0; i < num; i++) {
- Document doc = new Document();
- doc.add(new StringField("len", Integer.toString(i), Field.Store.YES));
- StringBuilder sb = new StringBuilder();
- for (int j = 0; j < i; j++) {
- sb.append(" token");
- }
- doc.add(new TextField("content", sb.toString(), Field.Store.NO));
- writer.addDocument(doc);
- }
-
- DirectoryReader ir = writer.getReader();
- writer.close();
- for (AtomicReaderContext context : ir.leaves()) {
- AtomicReader reader = context.reader();
- DocValues norms = reader.normValues("content");
- assertNotNull(norms);
- Source source = norms.getSource();
- assertEquals(Type.VAR_INTS, source.getType());
- for (int i = 0; i < reader.maxDoc(); i++) {
- assertEquals(source.getInt(i), Long.parseLong(reader.document(i).get("len")));
- }
- }
- ir.close();
- dir.close();
- }
public void testExceptionOnRandomType() throws IOException {
Directory dir = newDirectory();
@@ -334,28 +302,5 @@ public class TestCustomNorms extends Luc
throw new UnsupportedOperationException();
}
}
-
- class PackedNormSimilarity extends Similarity {
-
- @Override
- public void computeNorm(FieldInvertState state, Norm norm) {
- norm.setPackedLong(state.getLength());
- }
-
- @Override
- public SimWeight computeWeight(float queryBoost, CollectionStatistics collectionStats, TermStatistics... termStats) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public ExactSimScorer exactSimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public SloppySimScorer sloppySimScorer(SimWeight weight, AtomicReaderContext context) throws IOException {
- throw new UnsupportedOperationException();
- }
- }
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDeletionPolicy.java Fri Jan 18 18:30:54 2013
@@ -61,10 +61,12 @@ public class TestDeletionPolicy extends
int numOnInit;
int numOnCommit;
Directory dir;
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
verifyCommitOrder(commits);
numOnInit++;
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
IndexCommit lastCommit = commits.get(commits.size()-1);
DirectoryReader r = DirectoryReader.open(dir);
@@ -82,6 +84,7 @@ public class TestDeletionPolicy extends
class KeepNoneOnInitDeletionPolicy implements IndexDeletionPolicy {
int numOnInit;
int numOnCommit;
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
verifyCommitOrder(commits);
numOnInit++;
@@ -91,6 +94,7 @@ public class TestDeletionPolicy extends
assertTrue(commit.isDeleted());
}
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
verifyCommitOrder(commits);
int size = commits.size();
@@ -113,6 +117,7 @@ public class TestDeletionPolicy extends
this.numToKeep = numToKeep;
}
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
if (VERBOSE) {
System.out.println("TEST: onInit");
@@ -123,6 +128,7 @@ public class TestDeletionPolicy extends
doDeletes(commits, false);
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
if (VERBOSE) {
System.out.println("TEST: onCommit");
@@ -170,11 +176,13 @@ public class TestDeletionPolicy extends
this.expirationTimeSeconds = seconds;
}
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
verifyCommitOrder(commits);
onCommit(commits);
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
verifyCommitOrder(commits);
@@ -212,7 +220,8 @@ public class TestDeletionPolicy extends
IndexWriter writer = new IndexWriter(dir, conf);
Map<String,String> commitData = new HashMap<String,String>();
commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
- writer.commit(commitData);
+ writer.setCommitData(commitData);
+ writer.commit();
writer.close();
long lastDeleteTime = 0;
@@ -234,7 +243,8 @@ public class TestDeletionPolicy extends
}
commitData = new HashMap<String,String>();
commitData.put("commitTime", String.valueOf(System.currentTimeMillis()));
- writer.commit(commitData);
+ writer.setCommitData(commitData);
+ writer.commit();
writer.close();
Thread.sleep((int) (1000.0*(SECONDS/5.0)));
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReader.java Fri Jan 18 18:30:54 2013
@@ -720,7 +720,9 @@ public void testFilesOpenClose() throws
// DirectoryReader on a non-existent directory, you get a
// good exception
public void testNoDir() throws Throwable {
- Directory dir = newFSDirectory(_TestUtil.getTempDir("doesnotexist"));
+ File tempDir = _TestUtil.getTempDir("doesnotexist");
+ _TestUtil.rmDir(tempDir);
+ Directory dir = newFSDirectory(tempDir);
try {
DirectoryReader.open(dir);
fail("did not hit expected exception");
@@ -966,6 +968,7 @@ public void testFilesOpenClose() throws
final DirectoryReader reader = writer.getReader();
final int[] closeCount = new int[1];
final IndexReader.ReaderClosedListener listener = new IndexReader.ReaderClosedListener() {
+ @Override
public void onClose(IndexReader reader) {
closeCount[0]++;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDirectoryReaderReopen.java Fri Jan 18 18:30:54 2013
@@ -533,8 +533,10 @@ public class TestDirectoryReaderReopen e
}
static class KeepAllCommits implements IndexDeletionPolicy {
+ @Override
public void onInit(List<? extends IndexCommit> commits) {
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) {
}
}
@@ -554,13 +556,15 @@ public class TestDirectoryReaderReopen e
writer.addDocument(doc);
Map<String,String> data = new HashMap<String,String>();
data.put("index", i+"");
- writer.commit(data);
+ writer.setCommitData(data);
+ writer.commit();
}
for(int i=0;i<4;i++) {
writer.deleteDocuments(new Term("id", ""+i));
Map<String,String> data = new HashMap<String,String>();
data.put("index", (4+i)+"");
- writer.commit(data);
+ writer.setCommitData(data);
+ writer.commit();
}
writer.close();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocCount.java Fri Jan 18 18:30:54 2013
@@ -70,7 +70,7 @@ public class TestDocCount extends Lucene
FixedBitSet visited = new FixedBitSet(ir.maxDoc());
TermsEnum te = terms.iterator(null);
while (te.next() != null) {
- DocsEnum de = _TestUtil.docs(random(), te, null, null, 0);
+ DocsEnum de = _TestUtil.docs(random(), te, null, null, DocsEnum.FLAG_NONE);
while (de.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
visited.set(de.docID());
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocsAndPositions.java Fri Jan 18 18:30:54 2013
@@ -334,7 +334,7 @@ public class TestDocsAndPositions extend
writer.addDocument(doc);
DirectoryReader reader = writer.getReader();
AtomicReader r = getOnlySegmentReader(reader);
- DocsEnum disi = _TestUtil.docs(random(), r, "foo", new BytesRef("bar"), null, null, 0);
+ DocsEnum disi = _TestUtil.docs(random(), r, "foo", new BytesRef("bar"), null, null, DocsEnum.FLAG_NONE);
int docid = disi.docID();
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
@@ -342,7 +342,7 @@ public class TestDocsAndPositions extend
// now reuse and check again
TermsEnum te = r.terms("foo").iterator(null);
assertTrue(te.seekExact(new BytesRef("bar"), true));
- disi = _TestUtil.docs(random(), te, null, disi, 0);
+ disi = _TestUtil.docs(random(), te, null, disi, DocsEnum.FLAG_NONE);
docid = disi.docID();
assertTrue(docid == -1 || docid == DocIdSetIterator.NO_MORE_DOCS);
assertTrue(disi.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterDeleteQueue.java Fri Jan 18 18:30:54 2013
@@ -155,6 +155,7 @@ public class TestDocumentsWriterDeleteQu
ReentrantLock lock = (ReentrantLock) field.get(queue);
lock.lock();
Thread t = new Thread() {
+ @Override
public void run() {
queue.addDelete(new Term("foo", "bar"));
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDocumentsWriterStallControl.java Fri Jan 18 18:30:54 2013
@@ -62,6 +62,7 @@ public class TestDocumentsWriterStallCon
for (int i = 0; i < stallThreads.length; i++) {
final int stallProbability = 1 +random().nextInt(10);
stallThreads[i] = new Thread() {
+ @Override
public void run() {
int iters = atLeast(1000);
@@ -220,6 +221,7 @@ public class TestDocumentsWriterStallCon
this.exceptions = exceptions;
}
+ @Override
public void run() {
try {
while (!stop.get()) {
@@ -261,6 +263,7 @@ public class TestDocumentsWriterStallCon
this.exceptions = exceptions;
}
+ @Override
public void run() {
try {
@@ -318,6 +321,7 @@ public class TestDocumentsWriterStallCon
Thread[] array = new Thread[num];
for (int i = 0; i < array.length; i++) {
array[i] = new Thread() {
+ @Override
public void run() {
ctrl.waitIfStalled();
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestDuelingCodecs.java Fri Jan 18 18:30:54 2013
@@ -349,11 +349,11 @@ public class TestDuelingCodecs extends L
true);
// w/o freqs:
- assertDocsEnum(leftDocs = leftTermsEnum.docs(null, leftDocs, 0),
- rightDocs = rightTermsEnum.docs(null, rightDocs, 0),
+ assertDocsEnum(leftDocs = leftTermsEnum.docs(null, leftDocs, DocsEnum.FLAG_NONE),
+ rightDocs = rightTermsEnum.docs(null, rightDocs, DocsEnum.FLAG_NONE),
false);
- assertDocsEnum(leftDocs = leftTermsEnum.docs(randomBits, leftDocs, 0),
- rightDocs = rightTermsEnum.docs(randomBits, rightDocs, 0),
+ assertDocsEnum(leftDocs = leftTermsEnum.docs(randomBits, leftDocs, DocsEnum.FLAG_NONE),
+ rightDocs = rightTermsEnum.docs(randomBits, rightDocs, DocsEnum.FLAG_NONE),
false);
// with freqs:
@@ -368,12 +368,12 @@ public class TestDuelingCodecs extends L
// w/o freqs:
assertDocsSkipping(leftTermsEnum.docFreq(),
- leftDocs = leftTermsEnum.docs(null, leftDocs, 0),
- rightDocs = rightTermsEnum.docs(null, rightDocs, 0),
+ leftDocs = leftTermsEnum.docs(null, leftDocs, DocsEnum.FLAG_NONE),
+ rightDocs = rightTermsEnum.docs(null, rightDocs, DocsEnum.FLAG_NONE),
false);
assertDocsSkipping(leftTermsEnum.docFreq(),
- leftDocs = leftTermsEnum.docs(randomBits, leftDocs, 0),
- rightDocs = rightTermsEnum.docs(randomBits, rightDocs, 0),
+ leftDocs = leftTermsEnum.docs(randomBits, leftDocs, DocsEnum.FLAG_NONE),
+ rightDocs = rightTermsEnum.docs(randomBits, rightDocs, DocsEnum.FLAG_NONE),
false);
}
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestFlushByRamOrCountsPolicy.java Fri Jan 18 18:30:54 2013
@@ -302,6 +302,7 @@ public class TestFlushByRamOrCountsPolic
this.doRandomCommit = doRandomCommit;
}
+ @Override
public void run() {
try {
long ramSize = 0;
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriter.java Fri Jan 18 18:30:54 2013
@@ -17,14 +17,17 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Random;
+import java.util.Set;
import org.apache.lucene.analysis.*;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
@@ -55,11 +58,14 @@ import org.apache.lucene.store.NoLockFac
import org.apache.lucene.store.RAMDirectory;
import org.apache.lucene.store.SimpleFSLockFactory;
import org.apache.lucene.store.SingleInstanceLockFactory;
+import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
+import org.apache.lucene.util.IOUtils;
import org.apache.lucene.util.LuceneTestCase;
import org.apache.lucene.util.ThreadInterruptedException;
import org.apache.lucene.util._TestUtil;
import org.apache.lucene.util.packed.PackedInts;
+import org.junit.Test;
public class TestIndexWriter extends LuceneTestCase {
@@ -997,11 +1003,33 @@ public class TestIndexWriter extends Luc
volatile boolean finish;
volatile boolean allowInterrupt = false;
+ final Random random;
+ final Directory adder;
+
+ IndexerThreadInterrupt() throws IOException {
+ this.random = new Random(random().nextLong());
+ // make a little directory for addIndexes
+ // LUCENE-2239: won't work with NIOFS/MMAP
+ adder = new MockDirectoryWrapper(random, new RAMDirectory());
+ IndexWriterConfig conf = newIndexWriterConfig(random,
+ TEST_VERSION_CURRENT, new MockAnalyzer(random));
+ IndexWriter w = new IndexWriter(adder, conf);
+ Document doc = new Document();
+ doc.add(newStringField(random, "id", "500", Field.Store.NO));
+ doc.add(newField(random, "field", "some prepackaged text contents", storedTextType));
+ w.addDocument(doc);
+ doc = new Document();
+ doc.add(newStringField(random, "id", "501", Field.Store.NO));
+ doc.add(newField(random, "field", "some more contents", storedTextType));
+ w.addDocument(doc);
+ w.deleteDocuments(new Term("id", "500"));
+ w.close();
+ }
@Override
public void run() {
// LUCENE-2239: won't work with NIOFS/MMAP
- Directory dir = new MockDirectoryWrapper(random(), new RAMDirectory());
+ Directory dir = new MockDirectoryWrapper(random, new RAMDirectory());
IndexWriter w = null;
while(!finish) {
try {
@@ -1011,17 +1039,44 @@ public class TestIndexWriter extends Luc
w.close();
w = null;
}
- IndexWriterConfig conf = newIndexWriterConfig(
- TEST_VERSION_CURRENT, new MockAnalyzer(random())).setMaxBufferedDocs(2);
+ IndexWriterConfig conf = newIndexWriterConfig(random,
+ TEST_VERSION_CURRENT, new MockAnalyzer(random)).setMaxBufferedDocs(2);
w = new IndexWriter(dir, conf);
Document doc = new Document();
- doc.add(newField("field", "some text contents", storedTextType));
+ Field idField = newStringField(random, "id", "", Field.Store.NO);
+ doc.add(idField);
+ doc.add(newField(random, "field", "some text contents", storedTextType));
for(int i=0;i<100;i++) {
- w.addDocument(doc);
+ idField.setStringValue(Integer.toString(i));
+ int action = random.nextInt(100);
+ if (action == 17) {
+ w.addIndexes(adder);
+ } else if (action%30 == 0) {
+ w.deleteAll();
+ } else if (action%2 == 0) {
+ w.updateDocument(new Term("id", idField.stringValue()), doc);
+ } else {
+ w.addDocument(doc);
+ }
+ if (random.nextInt(3) == 0) {
+ IndexReader r = null;
+ try {
+ r = DirectoryReader.open(w, random.nextBoolean());
+ if (random.nextBoolean() && r.maxDoc() > 0) {
+ int docid = random.nextInt(r.maxDoc());
+ w.tryDeleteDocument(r, docid);
+ }
+ } finally {
+ IOUtils.closeWhileHandlingException(r);
+ }
+ }
if (i%10 == 0) {
w.commit();
}
+ if (random.nextInt(50) == 0) {
+ w.forceMerge(1);
+ }
}
w.close();
w = null;
@@ -1039,10 +1094,12 @@ public class TestIndexWriter extends Luc
allowInterrupt = true;
}
} catch (ThreadInterruptedException re) {
- if (true || VERBOSE) {
- System.out.println("TEST: got interrupt");
- re.printStackTrace(System.out);
- }
+ // NOTE: important to leave this verbosity/noise
+ // on!! This test doesn't repro easily so when
+ // Jenkins hits a fail we need to study where the
+ // interrupts struck!
+ System.out.println("TEST: got interrupt");
+ re.printStackTrace(System.out);
Throwable e = re.getCause();
assertTrue(e instanceof InterruptedException);
if (finish) {
@@ -1085,7 +1142,7 @@ public class TestIndexWriter extends Luc
}
}
try {
- dir.close();
+ IOUtils.close(dir, adder);
} catch (IOException e) {
throw new RuntimeException(e);
}
@@ -1103,9 +1160,12 @@ public class TestIndexWriter extends Luc
// init this class (in servicing a first interrupt):
assertTrue(new ThreadInterruptedException(new InterruptedException()).getCause() instanceof InterruptedException);
- // issue 100 interrupts to child thread
+ // issue 300 interrupts to child thread
+ final int numInterrupts = atLeast(300);
int i = 0;
- while(i < 100) {
+ while(i < numInterrupts) {
+ // TODO: would be nice to also sometimes interrupt the
+ // CMS merge threads too ...
Thread.sleep(10);
if (t.allowInterrupt) {
i++;
@@ -1179,12 +1239,12 @@ public class TestIndexWriter extends Luc
// test that the terms were indexed.
- assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc1field1"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc2field1"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc3field1"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc1field2"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc2field2"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
- assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc3field2"), null, null, 0).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc1field1"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc2field1"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "binary", new BytesRef("doc3field1"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc1field2"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc2field2"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
+ assertTrue(_TestUtil.docs(random(), ir, "string", new BytesRef("doc3field2"), null, null, DocsEnum.FLAG_NONE).nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
ir.close();
dir.close();
@@ -1230,7 +1290,6 @@ public class TestIndexWriter extends Luc
Directory dir = newDirectory();
IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(
TEST_VERSION_CURRENT, new MockAnalyzer(random())));
- ByteArrayOutputStream bos = new ByteArrayOutputStream(1024);
writer.addDocument(new Document());
writer.close();
@@ -1256,7 +1315,7 @@ public class TestIndexWriter extends Luc
TermsEnum t = r.fields().terms("field").iterator(null);
int count = 0;
while(t.next() != null) {
- final DocsEnum docs = _TestUtil.docs(random(), t, null, null, 0);
+ final DocsEnum docs = _TestUtil.docs(random(), t, null, null, DocsEnum.FLAG_NONE);
assertEquals(0, docs.nextDoc());
assertEquals(DocIdSetIterator.NO_MORE_DOCS, docs.nextDoc());
count++;
@@ -1932,4 +1991,153 @@ public class TestIndexWriter extends Luc
w.close();
dir.close();
}
+
+ // LUCENE-4575
+ public void testCommitWithUserDataOnly() throws Exception {
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
+ writer.commit(); // first commit to complete IW create transaction.
+
+ // this should store the commit data, even though no other changes were made
+ writer.setCommitData(new HashMap<String,String>() {{
+ put("key", "value");
+ }});
+ writer.commit();
+
+ DirectoryReader r = DirectoryReader.open(dir);
+ assertEquals("value", r.getIndexCommit().getUserData().get("key"));
+ r.close();
+
+ // now check setCommitData and prepareCommit/commit sequence
+ writer.setCommitData(new HashMap<String,String>() {{
+ put("key", "value1");
+ }});
+ writer.prepareCommit();
+ writer.setCommitData(new HashMap<String,String>() {{
+ put("key", "value2");
+ }});
+ writer.commit(); // should commit the first commitData only, per protocol
+
+ r = DirectoryReader.open(dir);
+ assertEquals("value1", r.getIndexCommit().getUserData().get("key"));
+ r.close();
+
+ // now should commit the second commitData - there was a bug where
+ // IndexWriter.finishCommit overrode the second commitData
+ writer.commit();
+ r = DirectoryReader.open(dir);
+ assertEquals("IndexWriter.finishCommit may have overridden the second commitData",
+ "value2", r.getIndexCommit().getUserData().get("key"));
+ r.close();
+
+ writer.close();
+ dir.close();
+ }
+
+ @Test
+ public void testGetCommitData() throws Exception {
+ Directory dir = newDirectory();
+ IndexWriter writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null));
+ writer.setCommitData(new HashMap<String,String>() {{
+ put("key", "value");
+ }});
+ assertEquals("value", writer.getCommitData().get("key"));
+ writer.close();
+
+ // validate that it's also visible when opening a new IndexWriter
+ writer = new IndexWriter(dir, newIndexWriterConfig(TEST_VERSION_CURRENT, null).setOpenMode(OpenMode.APPEND));
+ assertEquals("value", writer.getCommitData().get("key"));
+ writer.close();
+
+ dir.close();
+ }
+
+ public void testIterableThrowsException() throws IOException {
+ Directory dir = newDirectory();
+ IndexWriter w = new IndexWriter(dir, newIndexWriterConfig(
+ TEST_VERSION_CURRENT, new MockAnalyzer(random())));
+ int iters = atLeast(100);
+ int docCount = 0;
+ int docId = 0;
+ Set<String> liveIds = new HashSet<String>();
+ for (int i = 0; i < iters; i++) {
+ List<Document> docs = new ArrayList<Document>();
+ FieldType ft = new FieldType(TextField.TYPE_NOT_STORED);
+ FieldType idFt = new FieldType(TextField.TYPE_STORED);
+
+ int numDocs = atLeast(4);
+ for (int j = 0; j < numDocs; j++) {
+ Document doc = new Document();
+ doc.add(newField("id", ""+ (docId++), idFt));
+ doc.add(newField("foo", _TestUtil.randomSimpleString(random()), ft));
+ docs.add(doc);
+ }
+ boolean success = false;
+ try {
+ w.addDocuments(new RandomFailingFieldIterable(docs, random()));
+ success = true;
+ } catch (RuntimeException e) {
+ assertEquals("boom", e.getMessage());
+ } finally {
+ if (success) {
+ docCount += docs.size();
+ for (Document indexDocument : docs) {
+ liveIds.add(indexDocument.get("id"));
+ }
+ }
+ }
+ }
+ DirectoryReader reader = w.getReader();
+ assertEquals(docCount, reader.numDocs());
+ List<AtomicReaderContext> leaves = reader.leaves();
+ for (AtomicReaderContext atomicReaderContext : leaves) {
+ AtomicReader ar = atomicReaderContext.reader();
+ Bits liveDocs = ar.getLiveDocs();
+ int maxDoc = ar.maxDoc();
+ for (int i = 0; i < maxDoc; i++) {
+ if (liveDocs == null || liveDocs.get(i)) {
+ assertTrue(liveIds.remove(ar.document(i).get("id")));
+ }
+ }
+ }
+ assertTrue(liveIds.isEmpty());
+ IOUtils.close(reader, w, dir);
+ }
+
+ private static class RandomFailingFieldIterable implements Iterable<IndexDocument> {
+ private final List<? extends IndexDocument> docList;
+ private final Random random;
+
+ public RandomFailingFieldIterable(List<? extends IndexDocument> docList, Random random) {
+ this.docList = docList;
+ this.random = random;
+ }
+
+ @Override
+ public Iterator<IndexDocument> iterator() {
+ final Iterator<? extends IndexDocument> docIter = docList.iterator();
+ return new Iterator<IndexDocument>() {
+
+ @Override
+ public boolean hasNext() {
+ return docIter.hasNext();
+ }
+
+ @Override
+ public IndexDocument next() {
+ if (random.nextInt(5) == 0) {
+ throw new RuntimeException("boom");
+ }
+ return docIter.next();
+ }
+
+ @Override
+ public void remove() {throw new UnsupportedOperationException();}
+
+
+ };
+ }
+
+ }
+
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterCommit.java Fri Jan 18 18:30:54 2013
@@ -428,12 +428,13 @@ public class TestIndexWriterCommit exten
// commit to "first"
Map<String,String> commitData = new HashMap<String,String>();
commitData.put("tag", "first");
- w.commit(commitData);
+ w.setCommitData(commitData);
+ w.commit();
// commit to "second"
w.addDocument(doc);
commitData.put("tag", "second");
- w.commit(commitData);
+ w.setCommitData(commitData);
w.close();
// open "first" with IndexWriter
@@ -454,7 +455,7 @@ public class TestIndexWriterCommit exten
// commit IndexWriter to "third"
w.addDocument(doc);
commitData.put("tag", "third");
- w.commit(commitData);
+ w.setCommitData(commitData);
w.close();
// make sure "second" commit is still there
@@ -635,7 +636,7 @@ public class TestIndexWriterCommit exten
TestIndexWriter.addDoc(w);
Map<String,String> data = new HashMap<String,String>();
data.put("label", "test1");
- w.commit(data);
+ w.setCommitData(data);
w.close();
r = DirectoryReader.open(dir);
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterLockRelease.java Fri Jan 18 18:30:54 2013
@@ -17,73 +17,33 @@ package org.apache.lucene.index;
* limitations under the License.
*/
-import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.lucene.util._TestUtil;
+
import org.apache.lucene.analysis.MockAnalyzer;
-import org.apache.lucene.index.IndexWriter;
import org.apache.lucene.index.IndexWriterConfig.OpenMode;
import org.apache.lucene.store.Directory;
+import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util._TestUtil;
/**
* This tests the patch for issue #LUCENE-715 (IndexWriter does not
* release its write lock when trying to open an index which does not yet
* exist).
*/
-
public class TestIndexWriterLockRelease extends LuceneTestCase {
- private java.io.File __test_dir;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
- if (this.__test_dir == null) {
- this.__test_dir = _TestUtil.getTempDir("testIndexWriter");
-
- if (this.__test_dir.exists()) {
- throw new IOException("test directory \"" + this.__test_dir.getPath() + "\" already exists (please remove by hand)");
- }
-
- if (!this.__test_dir.mkdirs()
- && !this.__test_dir.isDirectory()) {
- throw new IOException("unable to create test directory \"" + this.__test_dir.getPath() + "\"");
- }
- }
- }
-
- @Override
- public void tearDown() throws Exception {
- if (this.__test_dir != null) {
- File[] files = this.__test_dir.listFiles();
-
- for (int i = 0;
- i < files.length;
- ++i) {
- if (!files[i].delete()) {
- throw new IOException("unable to remove file in test directory \"" + this.__test_dir.getPath() + "\" (please remove by hand)");
- }
- }
-
- if (!this.__test_dir.delete()) {
- throw new IOException("unable to remove test directory \"" + this.__test_dir.getPath() + "\" (please remove by hand)");
- }
- }
- super.tearDown();
- }
-
- public void testIndexWriterLockRelease() throws IOException {
- Directory dir = newFSDirectory(this.__test_dir);
+
+ public void testIndexWriterLockRelease() throws IOException {
+ Directory dir = newFSDirectory(_TestUtil.getTempDir("testLockRelease"));
+ try {
+ new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
+ } catch (FileNotFoundException e) {
try {
new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
- } catch (FileNotFoundException e) {
- try {
- new IndexWriter(dir, new IndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random())).setOpenMode(OpenMode.APPEND));
- } catch (FileNotFoundException e1) {
- }
- } finally {
- dir.close();
+ } catch (FileNotFoundException e1) {
}
+ } finally {
+ dir.close();
}
+ }
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterNRTIsCurrent.java Fri Jan 18 18:30:54 2013
@@ -86,6 +86,7 @@ public class TestIndexWriterNRTIsCurrent
this.latch = latch;
}
+ @Override
public void run() {
DirectoryReader currentReader = null;
Random random = LuceneTestCase.random();
@@ -158,6 +159,7 @@ public class TestIndexWriterNRTIsCurrent
this.latch = latch;
}
+ @Override
public void run() {
try {
latch.await();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterReader.java Fri Jan 18 18:30:54 2013
@@ -983,7 +983,7 @@ public class TestIndexWriterReader exten
w.addDocument(doc);
SegmentReader r = getOnlySegmentReader(DirectoryReader.open(w, true));
try {
- _TestUtil.docs(random(), r, "f", new BytesRef("val"), null, null, 0);
+ _TestUtil.docs(random(), r, "f", new BytesRef("val"), null, null, DocsEnum.FLAG_NONE);
fail("should have failed to seek since terms index was not loaded.");
} catch (IllegalStateException e) {
// expected - we didn't load the term index
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIndexWriterWithThreads.java Fri Jan 18 18:30:54 2013
@@ -354,16 +354,20 @@ public class TestIndexWriterWithThreads
StackTraceElement[] trace = new Exception().getStackTrace();
boolean sawAbortOrFlushDoc = false;
boolean sawClose = false;
+ boolean sawMerge = false;
for (int i = 0; i < trace.length; i++) {
if ("abort".equals(trace[i].getMethodName()) ||
"finishDocument".equals(trace[i].getMethodName())) {
sawAbortOrFlushDoc = true;
}
+ if ("merge".equals(trace[i])) {
+ sawMerge = true;
+ }
if ("close".equals(trace[i].getMethodName())) {
sawClose = true;
}
}
- if (sawAbortOrFlushDoc && !sawClose) {
+ if (sawAbortOrFlushDoc && !sawClose && !sawMerge) {
if (onlyOnce)
doFail = false;
//System.out.println(Thread.currentThread().getName() + ": now fail");
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIntBlockPool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIntBlockPool.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIntBlockPool.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestIntBlockPool.java Fri Jan 18 18:30:54 2013
@@ -116,6 +116,7 @@ public class TestIntBlockPool extends Lu
this.bytesUsed = bytesUsed;
}
+ @Override
public int[] getIntBlock() {
bytesUsed.addAndGet(blockSize * RamUsageEstimator.NUM_BYTES_INT);
return new int[blockSize];
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestLongPostings.java Fri Jan 18 18:30:54 2013
@@ -374,7 +374,7 @@ public class TestLongPostings extends Lu
final DocsEnum postings;
if (options == IndexOptions.DOCS_ONLY) {
- docs = _TestUtil.docs(random(), r, "field", new BytesRef(term), null, null, 0);
+ docs = _TestUtil.docs(random(), r, "field", new BytesRef(term), null, null, DocsEnum.FLAG_NONE);
postings = null;
} else {
docs = postings = _TestUtil.docs(random(), r, "field", new BytesRef(term), null, null, DocsEnum.FLAG_FREQS);
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestMultiFields.java Fri Jan 18 18:30:54 2013
@@ -121,7 +121,7 @@ public class TestMultiFields extends Luc
System.out.println("TEST: seek term="+ UnicodeUtil.toHexString(term.utf8ToString()) + " " + term);
}
- DocsEnum docsEnum = _TestUtil.docs(random(), reader, "field", term, liveDocs, null, 0);
+ DocsEnum docsEnum = _TestUtil.docs(random(), reader, "field", term, liveDocs, null, DocsEnum.FLAG_NONE);
assertNotNull(docsEnum);
for(int docID : docs.get(term)) {
@@ -162,8 +162,8 @@ public class TestMultiFields extends Luc
w.addDocument(d);
IndexReader r = w.getReader();
w.close();
- DocsEnum d1 = _TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, 0);
- DocsEnum d2 = _TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, 0);
+ DocsEnum d1 = _TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, DocsEnum.FLAG_NONE);
+ DocsEnum d2 = _TestUtil.docs(random(), r, "f", new BytesRef("j"), null, null, DocsEnum.FLAG_NONE);
assertEquals(0, d1.nextDoc());
assertEquals(0, d2.nextDoc());
r.close();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestNRTThreads.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestNRTThreads.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestNRTThreads.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestNRTThreads.java Fri Jan 18 18:30:54 2013
@@ -99,6 +99,7 @@ public class TestNRTThreads extends Thre
private IndexSearcher fixedSearcher;
+ @Override
protected IndexSearcher getCurrentSearcher() throws Exception {
return fixedSearcher;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestOmitTf.java Fri Jan 18 18:30:54 2013
@@ -37,7 +37,9 @@ import org.apache.lucene.store.Directory
public class TestOmitTf extends LuceneTestCase {
public static class SimpleSimilarity extends TFIDFSimilarity {
+ @Override
public float queryNorm(float sumOfSquaredWeights) { return 1.0f; }
+ @Override
public float coord(int overlap, int maxOverlap) { return 1.0f; }
@Override public float lengthNorm(FieldInvertState state) { return state.getBoost(); }
@Override public float tf(float freq) { return freq; }
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestParallelTermEnum.java Fri Jan 18 18:30:54 2013
@@ -82,7 +82,7 @@ public class TestParallelTermEnum extend
BytesRef b = te.next();
assertNotNull(b);
assertEquals(t, b.utf8ToString());
- DocsEnum td = _TestUtil.docs(random(), te, liveDocs, null, 0);
+ DocsEnum td = _TestUtil.docs(random(), te, liveDocs, null, DocsEnum.FLAG_NONE);
assertTrue(td.nextDoc() != DocIdSetIterator.NO_MORE_DOCS);
assertEquals(0, td.docID());
assertEquals(td.nextDoc(), DocIdSetIterator.NO_MORE_DOCS);
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPerSegmentDeletes.java Fri Jan 18 18:30:54 2013
@@ -228,7 +228,7 @@ public class TestPerSegmentDeletes exten
Terms cterms = fields.terms(term.field);
TermsEnum ctermsEnum = cterms.iterator(null);
if (ctermsEnum.seekExact(new BytesRef(term.text()), false)) {
- DocsEnum docsEnum = _TestUtil.docs(random(), ctermsEnum, bits, null, 0);
+ DocsEnum docsEnum = _TestUtil.docs(random(), ctermsEnum, bits, null, DocsEnum.FLAG_NONE);
return toArray(docsEnum);
}
return null;
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestPostingsOffsets.java Fri Jan 18 18:30:54 2013
@@ -53,6 +53,7 @@ import org.apache.lucene.util._TestUtil;
public class TestPostingsOffsets extends LuceneTestCase {
IndexWriterConfig iwc;
+ @Override
public void setUp() throws Exception {
super.setUp();
iwc = newIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(random()));
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestReaderClosed.java Fri Jan 18 18:30:54 2013
@@ -92,6 +92,7 @@ public class TestReaderClosed extends Lu
}
}
+ @Override
public void tearDown() throws Exception {
dir.close();
super.tearDown();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestRollingUpdates.java Fri Jan 18 18:30:54 2013
@@ -193,6 +193,7 @@ public class TestRollingUpdates extends
this.num = num;
}
+ @Override
public void run() {
try {
DirectoryReader open = null;
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressAdvance.java Fri Jan 18 18:30:54 2013
@@ -82,11 +82,11 @@ public class TestStressAdvance extends L
System.out.println("\nTEST: iter=" + iter + " iter2=" + iter2);
}
assertEquals(TermsEnum.SeekStatus.FOUND, te.seekCeil(new BytesRef("a")));
- de = _TestUtil.docs(random(), te, null, de, 0);
+ de = _TestUtil.docs(random(), te, null, de, DocsEnum.FLAG_NONE);
testOne(de, aDocIDs);
assertEquals(TermsEnum.SeekStatus.FOUND, te.seekCeil(new BytesRef("b")));
- de = _TestUtil.docs(random(), te, null, de, 0);
+ de = _TestUtil.docs(random(), te, null, de, DocsEnum.FLAG_NONE);
testOne(de, bDocIDs);
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestStressIndexing2.java Fri Jan 18 18:30:54 2013
@@ -134,6 +134,7 @@ public class TestStressIndexing2 extends
static Term idTerm = new Term("id","");
IndexingThread[] threads;
static Comparator<GeneralField> fieldNameComparator = new Comparator<GeneralField>() {
+ @Override
public int compare(GeneralField o1, GeneralField o2) {
return o1.name().compareTo(o2.name());
}
@@ -337,7 +338,7 @@ public class TestStressIndexing2 extends
Bits liveDocs = MultiFields.getLiveDocs(r1);
DocsEnum docs = null;
while(termsEnum.next() != null) {
- docs = _TestUtil.docs(random(), termsEnum, liveDocs, docs, 0);
+ docs = _TestUtil.docs(random(), termsEnum, liveDocs, docs, DocsEnum.FLAG_NONE);
while(docs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
fail("r1 is not empty but r2 is");
}
@@ -357,9 +358,9 @@ public class TestStressIndexing2 extends
break;
}
- termDocs1 = _TestUtil.docs(random(), termsEnum, liveDocs1, termDocs1, 0);
+ termDocs1 = _TestUtil.docs(random(), termsEnum, liveDocs1, termDocs1, DocsEnum.FLAG_NONE);
if (termsEnum2.seekExact(term, false)) {
- termDocs2 = _TestUtil.docs(random(), termsEnum2, liveDocs2, termDocs2, 0);
+ termDocs2 = _TestUtil.docs(random(), termsEnum2, liveDocs2, termDocs2, DocsEnum.FLAG_NONE);
} else {
termDocs2 = null;
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermVectorsReader.java Fri Jan 18 18:30:54 2013
@@ -54,6 +54,7 @@ public class TestTermVectorsReader exten
int pos;
int startOffset;
int endOffset;
+ @Override
public int compareTo(TestToken other) {
return pos - other.pos;
}
@@ -225,7 +226,7 @@ public class TestTermVectorsReader exten
//System.out.println("Term: " + term);
assertEquals(testTerms[i], term);
- docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, 0);
+ docsEnum = _TestUtil.docs(random(), termsEnum, null, docsEnum, DocsEnum.FLAG_NONE);
assertNotNull(docsEnum);
int doc = docsEnum.docID();
assertTrue(doc == -1 || doc == DocIdSetIterator.NO_MORE_DOCS);
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermdocPerf.java Fri Jan 18 18:30:54 2013
@@ -124,7 +124,7 @@ public class TestTermdocPerf extends Luc
final Random random = new Random(random().nextLong());
for (int i=0; i<iter; i++) {
tenum.seekCeil(new BytesRef("val"));
- tdocs = _TestUtil.docs(random, tenum, MultiFields.getLiveDocs(reader), tdocs, 0);
+ tdocs = _TestUtil.docs(random, tenum, MultiFields.getLiveDocs(reader), tdocs, DocsEnum.FLAG_NONE);
while (tdocs.nextDoc() != DocIdSetIterator.NO_MORE_DOCS) {
ret += tdocs.docID();
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum.java Fri Jan 18 18:30:54 2013
@@ -332,7 +332,7 @@ public class TestTermsEnum extends Lucen
}
assertEquals(expected, actual);
assertEquals(1, te.docFreq());
- docsEnum = _TestUtil.docs(random(), te, null, docsEnum, 0);
+ docsEnum = _TestUtil.docs(random(), te, null, docsEnum, DocsEnum.FLAG_NONE);
final int docID = docsEnum.nextDoc();
assertTrue(docID != DocIdSetIterator.NO_MORE_DOCS);
assertEquals(docIDToID[docID], termToID.get(expected).intValue());
@@ -747,25 +747,25 @@ public class TestTermsEnum extends Lucen
CompiledAutomaton ca = new CompiledAutomaton(automaton, false, false);
TermsEnum te = terms.intersect(ca, null);
assertEquals("aaa", te.next().utf8ToString());
- assertEquals(0, te.docs(null, null, 0).nextDoc());
+ assertEquals(0, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertEquals("bbb", te.next().utf8ToString());
- assertEquals(1, te.docs(null, null, 0).nextDoc());
+ assertEquals(1, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertEquals("ccc", te.next().utf8ToString());
- assertEquals(2, te.docs(null, null, 0).nextDoc());
+ assertEquals(2, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertNull(te.next());
te = terms.intersect(ca, new BytesRef("abc"));
assertEquals("bbb", te.next().utf8ToString());
- assertEquals(1, te.docs(null, null, 0).nextDoc());
+ assertEquals(1, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertEquals("ccc", te.next().utf8ToString());
- assertEquals(2, te.docs(null, null, 0).nextDoc());
+ assertEquals(2, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertNull(te.next());
te = terms.intersect(ca, new BytesRef("aaa"));
assertEquals("bbb", te.next().utf8ToString());
- assertEquals(1, te.docs(null, null, 0).nextDoc());
+ assertEquals(1, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertEquals("ccc", te.next().utf8ToString());
- assertEquals(2, te.docs(null, null, 0).nextDoc());
+ assertEquals(2, te.docs(null, null, DocsEnum.FLAG_NONE).nextDoc());
assertNull(te.next());
r.close();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTermsEnum2.java Fri Jan 18 18:30:54 2013
@@ -45,6 +45,7 @@ public class TestTermsEnum2 extends Luce
private Automaton termsAutomaton; // automata of the same
int numIterations;
+ @Override
public void setUp() throws Exception {
super.setUp();
numIterations = atLeast(50);
@@ -73,6 +74,7 @@ public class TestTermsEnum2 extends Luce
writer.close();
}
+ @Override
public void tearDown() throws Exception {
reader.close();
dir.close();
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTransactionRollback.java Fri Jan 18 18:30:54 2013
@@ -30,7 +30,6 @@ import org.apache.lucene.analysis.MockAn
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.MockDirectoryWrapper;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.LuceneTestCase;
@@ -72,7 +71,7 @@ public class TestTransactionRollback ext
new RollbackDeletionPolicy(id)).setIndexCommit(last));
Map<String,String> data = new HashMap<String,String>();
data.put("index", "Rolled back to 1-"+id);
- w.commit(data);
+ w.setCommitData(data);
w.close();
}
@@ -142,7 +141,8 @@ public class TestTransactionRollback ext
if (currentRecordId%10 == 0) {
Map<String,String> data = new HashMap<String,String>();
data.put("index", "records 1-"+currentRecordId);
- w.commit(data);
+ w.setCommitData(data);
+ w.commit();
}
}
@@ -163,9 +163,11 @@ public class TestTransactionRollback ext
this.rollbackPoint = rollbackPoint;
}
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {
}
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
for (final IndexCommit commit : commits) {
Map<String,String> userData=commit.getUserData();
@@ -196,8 +198,10 @@ public class TestTransactionRollback ext
class DeleteLastCommitPolicy implements IndexDeletionPolicy {
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {}
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {
commits.get(commits.size()-1).delete();
}
@@ -218,7 +222,9 @@ public class TestTransactionRollback ext
// Keeps all commit points (used to build index)
class KeepAllDeletionPolicy implements IndexDeletionPolicy {
+ @Override
public void onCommit(List<? extends IndexCommit> commits) throws IOException {}
+ @Override
public void onInit(List<? extends IndexCommit> commits) throws IOException {}
}
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTwoPhaseCommitTool.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTwoPhaseCommitTool.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTwoPhaseCommitTool.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/index/TestTwoPhaseCommitTool.java Fri Jan 18 18:30:54 2013
@@ -18,10 +18,8 @@ package org.apache.lucene.index;
*/
import java.io.IOException;
-import java.util.HashMap;
import java.util.Map;
-import org.apache.lucene.index.TwoPhaseCommitTool.TwoPhaseCommitWrapper;
import org.apache.lucene.util.LuceneTestCase;
public class TestTwoPhaseCommitTool extends LuceneTestCase {
@@ -41,6 +39,7 @@ public class TestTwoPhaseCommitTool exte
this.failOnRollback = failOnRollback;
}
+ @Override
public void prepareCommit() throws IOException {
prepareCommit(null);
}
@@ -53,6 +52,7 @@ public class TestTwoPhaseCommitTool exte
}
}
+ @Override
public void commit() throws IOException {
commit(null);
}
@@ -65,6 +65,7 @@ public class TestTwoPhaseCommitTool exte
}
}
+ @Override
public void rollback() throws IOException {
rollbackCalled = true;
if (failOnRollback) {
@@ -117,27 +118,6 @@ public class TestTwoPhaseCommitTool exte
}
}
- public void testWrapper() throws Exception {
- // tests that TwoPhaseCommitWrapper delegates prepare/commit w/ commitData
- TwoPhaseCommitImpl impl = new TwoPhaseCommitImpl(false, false, false);
- HashMap<String, String> commitData = new HashMap<String, String>();
- TwoPhaseCommitWrapper wrapper = new TwoPhaseCommitWrapper(impl, commitData);
-
- wrapper.prepareCommit();
- assertSame(commitData, impl.prepareCommitData);
-
- // wrapper should ignore passed commitData
- wrapper.prepareCommit(new HashMap<String, String>());
- assertSame(commitData, impl.prepareCommitData);
-
- wrapper.commit();
- assertSame(commitData, impl.commitData);
-
- // wrapper should ignore passed commitData
- wrapper.commit(new HashMap<String, String>());
- assertSame(commitData, impl.commitData);
- }
-
public void testNullTPCs() throws Exception {
int numObjects = random().nextInt(4) + 3; // between [3, 6]
TwoPhaseCommit[] tpcs = new TwoPhaseCommit[numObjects];
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/JustCompileSearch.java Fri Jan 18 18:30:54 2013
@@ -94,6 +94,7 @@ final class JustCompileSearch {
static final class JustCompileExtendedFieldCacheLongParser implements FieldCache.LongParser {
+ @Override
public long parseLong(BytesRef string) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
@@ -102,6 +103,7 @@ final class JustCompileSearch {
static final class JustCompileExtendedFieldCacheDoubleParser implements FieldCache.DoubleParser {
+ @Override
public double parseDouble(BytesRef term) {
throw new UnsupportedOperationException(UNSUPPORTED_MSG);
}
Modified: lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java?rev=1435287&r1=1435286&r2=1435287&view=diff
==============================================================================
--- lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java (original)
+++ lucene/dev/branches/LUCENE-2878/lucene/core/src/test/org/apache/lucene/search/TestBooleanMinShouldMatch.java Fri Jan 18 18:30:54 2013
@@ -306,6 +306,7 @@ public class TestBooleanMinShouldMatch e
// callback object to set a random setMinimumNumberShouldMatch
TestBoolean2.Callback minNrCB = new TestBoolean2.Callback() {
+ @Override
public void postCreate(BooleanQuery q) {
BooleanClause[] c =q.getClauses();
int opt=0;