From a40530e4a488424ebc7c8fa834218a7dc07ec5ed Mon Sep 17 00:00:00 2001 From: Michael McCandless Date: Thu, 25 Sep 2008 12:04:38 +0000 Subject: [PATCH] LUCENE-1401: remove new deprecated IndexWriter ctors; default autoCommit=false for new ctors git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@698932 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 3 +- .../byTask/tasks/CreateIndexTask.java | 3 +- .../benchmark/byTask/tasks/OpenIndexTask.java | 2 +- .../org/apache/lucene/index/IndexWriter.java | 236 ++++++------------ .../org/apache/lucene/index/SegmentInfo.java | 2 +- .../lucene/TestMergeSchedulerExternal.java | 2 +- .../lucene/TestSnapshotDeletionPolicy.java | 12 +- .../index/TestAddIndexesNoOptimize.java | 6 +- .../apache/lucene/index/TestAtomicUpdate.java | 6 +- .../index/TestBackwardsCompatibility.java | 8 +- .../index/TestConcurrentMergeScheduler.java | 12 +- .../lucene/index/TestDeletionPolicy.java | 28 +-- .../apache/lucene/index/TestIndexWriter.java | 111 ++++---- .../lucene/index/TestIndexWriterDelete.java | 20 +- .../index/TestIndexWriterExceptions.java | 2 +- .../index/TestIndexWriterMergePolicy.java | 8 +- .../lucene/index/TestStressIndexing.java | 2 +- .../lucene/index/TestStressIndexing2.java | 6 +- .../lucene/index/TestThreadedOptimize.java | 4 +- .../apache/lucene/index/TestTransactions.java | 6 +- 20 files changed, 191 insertions(+), 288 deletions(-) diff --git a/CHANGES.txt b/CHANGES.txt index c52da8e822b..9bc0dd1f1d0 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -67,7 +67,8 @@ API Changes 1. LUCENE-1084: Changed all IndexWriter constructors to take an explicit parameter for maximum field size. Deprecated all the pre-existing constructors; these will be removed in release 3.0. - (Steven Rowe via Mike McCandless) + NOTE: these new constructors set autoCommit to false. (Steven + Rowe via Mike McCandless) 2. LUCENE-584: Changed Filter API to return a DocIdSet instead of a java.util.BitSet. This allows using more efficient data structures diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java index a38fe955f3e..d1d716bfeb7 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/CreateIndexTask.java @@ -97,8 +97,7 @@ public class CreateIndexTask extends PerfTask { Config config = runData.getConfig(); IndexWriter writer = new IndexWriter(runData.getDirectory(), runData.getConfig().get("autocommit", OpenIndexTask.DEFAULT_AUTO_COMMIT), - runData.getAnalyzer(), - true, IndexWriter.MaxFieldLength.LIMITED); + runData.getAnalyzer()); CreateIndexTask.setIndexWriterConfig(writer, config); runData.setIndexWriter(writer); return 1; diff --git a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java index 6ff0a567309..84fd99c40e2 100644 --- a/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java +++ b/contrib/benchmark/src/java/org/apache/lucene/benchmark/byTask/tasks/OpenIndexTask.java @@ -50,7 +50,7 @@ public class OpenIndexTask extends PerfTask { IndexWriter writer = new IndexWriter(runData.getDirectory(), config.get("autocommit", DEFAULT_AUTO_COMMIT), runData.getAnalyzer(), - false, IndexWriter.MaxFieldLength.LIMITED); + false); CreateIndexTask.setIndexWriterConfig(writer, config); runData.setIndexWriter(writer); return 1; diff --git a/src/java/org/apache/lucene/index/IndexWriter.java b/src/java/org/apache/lucene/index/IndexWriter.java index 793d5e17665..93fe6f234fc 100644 --- a/src/java/org/apache/lucene/index/IndexWriter.java +++ b/src/java/org/apache/lucene/index/IndexWriter.java @@ -121,7 +121,7 @@ import java.util.Iterator;

When autoCommit is true then the writer will periodically commit on its own. [Deprecated: Note that in 3.0, IndexWriter will no longer accept autoCommit=true (it will be hardwired to - false). You can always call {@link IndexWriter#commit()} yourself + false). You can always call {@link #commit()} yourself when needed]. There is no guarantee when exactly an auto commit will occur (it used to be after every flush, but it is now after every @@ -523,8 +523,11 @@ public class IndexWriter { * Text will be analyzed with a. If create * is true, then a new, empty index will be created in * path, replacing the index already there, - * if any. Note that autoCommit defaults to true, but - * starting in 3.0 it will be hardwired to false. + * if any. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param path the path to the index directory * @param a the analyzer to use @@ -544,7 +547,7 @@ public class IndexWriter { */ public IndexWriter(String path, Analyzer a, boolean create, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(FSDirectory.getDirectory(path), a, create, true, null, true, mfl.getLimit()); + init(FSDirectory.getDirectory(path), a, create, true, null, false, mfl.getLimit()); } /** @@ -567,7 +570,9 @@ public class IndexWriter { * false or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(String,Analyzer,boolean,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(String,Analyzer,boolean,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(String path, Analyzer a, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -579,8 +584,10 @@ public class IndexWriter { * Text will be analyzed with a. If create * is true, then a new, empty index will be created in * path, replacing the index already there, if any. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param path the path to the index directory * @param a the analyzer to use @@ -600,7 +607,7 @@ public class IndexWriter { */ public IndexWriter(File path, Analyzer a, boolean create, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(FSDirectory.getDirectory(path), a, create, true, null, true, mfl.getLimit()); + init(FSDirectory.getDirectory(path), a, create, true, null, false, mfl.getLimit()); } /** @@ -623,7 +630,9 @@ public class IndexWriter { * false or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(File,Analyzer,boolean,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(File,Analyzer,boolean,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(File path, Analyzer a, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -635,8 +644,10 @@ public class IndexWriter { * Text will be analyzed with a. If create * is true, then a new, empty index will be created in * d, replacing the index already there, if any. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param d the index directory * @param a the analyzer to use @@ -656,7 +667,7 @@ public class IndexWriter { */ public IndexWriter(Directory d, Analyzer a, boolean create, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, create, false, null, true, mfl.getLimit()); + init(d, a, create, false, null, false, mfl.getLimit()); } /** @@ -678,7 +689,8 @@ public class IndexWriter { * if it does not exist and create is * false or if there is any other low-level * IO error - * @deprecated This constructor will be removed in the 3.0 release. + * @deprecated This constructor will be removed in the 3.0 + * release, and call {@link #commit()} when needed. * Use {@link #IndexWriter(Directory,Analyzer,boolean,MaxFieldLength)} instead. */ public IndexWriter(Directory d, Analyzer a, boolean create) @@ -691,8 +703,10 @@ public class IndexWriter { * path, first creating it if it does not * already exist. Text will be analyzed with * a. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param path the path to the index directory * @param a the analyzer to use @@ -708,7 +722,7 @@ public class IndexWriter { */ public IndexWriter(String path, Analyzer a, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(FSDirectory.getDirectory(path), a, true, null, true, mfl.getLimit()); + init(FSDirectory.getDirectory(path), a, true, null, false, mfl.getLimit()); } /** @@ -726,7 +740,8 @@ public class IndexWriter { * @throws IOException if the directory cannot be * read/written to or if there is any other low-level * IO error - * @deprecated This constructor will be removed in the 3.0 release. + * @deprecated This constructor will be removed in the 3.0 + * release, and call {@link #commit()} when needed. * Use {@link #IndexWriter(String,Analyzer,MaxFieldLength)} instead. */ public IndexWriter(String path, Analyzer a) @@ -739,8 +754,10 @@ public class IndexWriter { * path, first creating it if it does not * already exist. Text will be analyzed with * a. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param path the path to the index directory * @param a the analyzer to use @@ -756,7 +773,7 @@ public class IndexWriter { */ public IndexWriter(File path, Analyzer a, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(FSDirectory.getDirectory(path), a, true, null, true, mfl.getLimit()); + init(FSDirectory.getDirectory(path), a, true, null, false, mfl.getLimit()); } /** @@ -775,7 +792,8 @@ public class IndexWriter { * read/written to or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(File,Analyzer,MaxFieldLength)} instead. + * Use {@link #IndexWriter(File,Analyzer,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(File path, Analyzer a) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -787,8 +805,10 @@ public class IndexWriter { * d, first creating it if it does not * already exist. Text will be analyzed with * a. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param d the index directory * @param a the analyzer to use @@ -804,7 +824,7 @@ public class IndexWriter { */ public IndexWriter(Directory d, Analyzer a, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, false, null, true, mfl.getLimit()); + init(d, a, false, null, false, mfl.getLimit()); } /** @@ -823,41 +843,15 @@ public class IndexWriter { * read/written to or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(Directory,Analyzer,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(Directory,Analyzer,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(Directory d, Analyzer a) throws CorruptIndexException, LockObtainFailedException, IOException { init(d, a, false, null, true, DEFAULT_MAX_FIELD_LENGTH); } - /** - * Constructs an IndexWriter for the index in - * d, first creating it if it does not - * already exist. Text will be analyzed with - * a. - * - * @param d the index directory - * @param autoCommit see above - * @param a the analyzer to use - * @param mfl Maximum field length: LIMITED, UNLIMITED, or user-specified - * via the MaxFieldLength constructor. - * @throws CorruptIndexException if the index is corrupt - * @throws LockObtainFailedException if another writer - * has this index open (write.lock could not - * be obtained) - * @throws IOException if the directory cannot be - * read/written to or if there is any other low-level - * IO error - * @deprecated This will be removed in 3.0, when - * autoCommit will be hardwired to false. Use {@link - * #IndexWriter(Directory,Analyzer,MaxFieldLength)} - * instead, and call {@link #commit()} when needed. - */ - public IndexWriter(Directory d, boolean autoCommit, Analyzer a, MaxFieldLength mfl) - throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, false, null, autoCommit, mfl.getLimit()); - } - /** * Constructs an IndexWriter for the index in * d, first creating it if it does not @@ -875,45 +869,15 @@ public class IndexWriter { * read/written to or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(Directory,Analyzer,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(Directory,Analyzer,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(Directory d, boolean autoCommit, Analyzer a) throws CorruptIndexException, LockObtainFailedException, IOException { init(d, a, false, null, autoCommit, DEFAULT_MAX_FIELD_LENGTH); } - /** - * Constructs an IndexWriter for the index in d. - * Text will be analyzed with a. If create - * is true, then a new, empty index will be created in - * d, replacing the index already there, if any. - * - * @param d the index directory - * @param autoCommit see above - * @param a the analyzer to use - * @param create true to create the index or overwrite - * the existing one; false to append to the existing - * index - * @param mfl Maximum field length: LIMITED, UNLIMITED, or user-specified - * via the MaxFieldLength constructor. - * @throws CorruptIndexException if the index is corrupt - * @throws LockObtainFailedException if another writer - * has this index open (write.lock could not - * be obtained) - * @throws IOException if the directory cannot be read/written to, or - * if it does not exist and create is - * false or if there is any other low-level - * IO error - * @deprecated This will be removed in 3.0, when - * autoCommit will be hardwired to false. Use {@link - * #IndexWriter(Directory,Analyzer,boolean,MaxFieldLength)} - * instead, and call {@link #commit()} when needed. - */ - public IndexWriter(Directory d, boolean autoCommit, Analyzer a, boolean create, MaxFieldLength mfl) - throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, create, false, null, autoCommit, mfl.getLimit()); - } - /** * Constructs an IndexWriter for the index in d. * Text will be analyzed with a. If create @@ -935,7 +899,9 @@ public class IndexWriter { * false or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(Directory,Analyzer,boolean,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(Directory,Analyzer,boolean,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(Directory d, boolean autoCommit, Analyzer a, boolean create) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -947,8 +913,10 @@ public class IndexWriter { * IndexDeletionPolicy}, for the index in d, * first creating it if it does not already exist. Text * will be analyzed with a. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param d the index directory * @param a the analyzer to use @@ -964,36 +932,7 @@ public class IndexWriter { */ public IndexWriter(Directory d, Analyzer a, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, false, deletionPolicy, true, mfl.getLimit()); - } - - /** - * Expert: constructs an IndexWriter with a custom {@link - * IndexDeletionPolicy}, for the index in d, - * first creating it if it does not already exist. Text - * will be analyzed with a. - * - * @param d the index directory - * @param autoCommit see above - * @param a the analyzer to use - * @param deletionPolicy see above - * @param mfl Maximum field length: LIMITED, UNLIMITED, or user-specified - * via the MaxFieldLength constructor. - * @throws CorruptIndexException if the index is corrupt - * @throws LockObtainFailedException if another writer - * has this index open (write.lock could not - * be obtained) - * @throws IOException if the directory cannot be - * read/written to or if there is any other low-level - * IO error - * @deprecated This will be removed in 3.0, when - * autoCommit will be hardwired to false. Use {@link - * #IndexWriter(Directory,Analyzer,IndexDeletionPolicy,MaxFieldLength)} - * instead, and call {@link #commit()} when needed. - */ - public IndexWriter(Directory d, boolean autoCommit, Analyzer a, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl) - throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, false, deletionPolicy, autoCommit, mfl.getLimit()); + init(d, a, false, deletionPolicy, false, mfl.getLimit()); } /** @@ -1014,7 +953,9 @@ public class IndexWriter { * read/written to or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(Directory,Analyzer,IndexDeletionPolicy,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(Directory,Analyzer,IndexDeletionPolicy,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(Directory d, boolean autoCommit, Analyzer a, IndexDeletionPolicy deletionPolicy) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -1028,8 +969,10 @@ public class IndexWriter { * create is true, then a new, empty index * will be created in d, replacing the index * already there, if any. - * Note that autoCommit defaults to true, but starting in 3.0 - * it will be hardwired to false. + * + *

NOTE: autoCommit (see above) is set to false with this + * constructor. * * @param d the index directory * @param a the analyzer to use @@ -1049,42 +992,7 @@ public class IndexWriter { */ public IndexWriter(Directory d, Analyzer a, boolean create, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl) throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, create, false, deletionPolicy, true, mfl.getLimit()); - } - - /** - * Expert: constructs an IndexWriter with a custom {@link - * IndexDeletionPolicy}, for the index in d. - * Text will be analyzed with a. If - * create is true, then a new, empty index - * will be created in d, replacing the index - * already there, if any. - * - * @param d the index directory - * @param autoCommit see above - * @param a the analyzer to use - * @param create true to create the index or overwrite - * the existing one; false to append to the existing - * index - * @param deletionPolicy see above - * @param mfl Maximum field length: LIMITED, UNLIMITED, or user-specified - * via the MaxFieldLength constructor. - * @throws CorruptIndexException if the index is corrupt - * @throws LockObtainFailedException if another writer - * has this index open (write.lock could not - * be obtained) - * @throws IOException if the directory cannot be read/written to, or - * if it does not exist and create is - * false or if there is any other low-level - * IO error - * @deprecated This will be removed in 3.0, when - * autoCommit will be hardwired to false. Use {@link - * #IndexWriter(Directory,Analyzer,boolean,IndexDeletionPolicy,MaxFieldLength)} - * instead, and call {@link #commit()} when needed. - */ - public IndexWriter(Directory d, boolean autoCommit, Analyzer a, boolean create, IndexDeletionPolicy deletionPolicy, MaxFieldLength mfl) - throws CorruptIndexException, LockObtainFailedException, IOException { - init(d, a, create, false, deletionPolicy, autoCommit, mfl.getLimit()); + init(d, a, create, false, deletionPolicy, false, mfl.getLimit()); } /** @@ -1111,7 +1019,9 @@ public class IndexWriter { * false or if there is any other low-level * IO error * @deprecated This constructor will be removed in the 3.0 release. - * Use {@link #IndexWriter(Directory,Analyzer,boolean,IndexDeletionPolicy,MaxFieldLength)} instead. + * Use {@link + * #IndexWriter(Directory,Analyzer,boolean,IndexDeletionPolicy,MaxFieldLength)} + * instead, and call {@link #commit()} when needed. */ public IndexWriter(Directory d, boolean autoCommit, Analyzer a, boolean create, IndexDeletionPolicy deletionPolicy) throws CorruptIndexException, LockObtainFailedException, IOException { @@ -1309,7 +1219,7 @@ public class IndexWriter { * documents are large, be sure to set this value high enough to accomodate * the expected size. If you set it to Integer.MAX_VALUE, then the only limit * is your memory, but you should anticipate an OutOfMemoryError.

- * By default, no more than {@link IndexWriter#DEFAULT_MAX_FIELD_LENGTH} terms + * By default, no more than {@link #DEFAULT_MAX_FIELD_LENGTH} terms * will be indexed for a field. */ public void setMaxFieldLength(int maxFieldLength) { @@ -2594,7 +2504,7 @@ public class IndexWriter { } success = true; } finally { - // Releaes the write lock if our caller held it, on + // Release the write lock if our caller held it, on // hitting an exception if (!success && haveWriteLock) releaseWrite(); @@ -4795,7 +4705,7 @@ public class IndexWriter { /** * Specifies maximum field length in {@link IndexWriter} constructors. - * {@link IndexWriter#setMaxFieldLength(int)} overrides the value set by + * {@link #setMaxFieldLength(int)} overrides the value set by * the constructor. */ public static final class MaxFieldLength { @@ -4838,7 +4748,7 @@ public class IndexWriter { /** * Sets the maximum field length to - * {@link IndexWriter#DEFAULT_MAX_FIELD_LENGTH} + * {@link #DEFAULT_MAX_FIELD_LENGTH} * */ public static final MaxFieldLength LIMITED = new MaxFieldLength("LIMITED", DEFAULT_MAX_FIELD_LENGTH); diff --git a/src/java/org/apache/lucene/index/SegmentInfo.java b/src/java/org/apache/lucene/index/SegmentInfo.java index 8bb87caf2dd..60ca3b839c8 100644 --- a/src/java/org/apache/lucene/index/SegmentInfo.java +++ b/src/java/org/apache/lucene/index/SegmentInfo.java @@ -109,7 +109,7 @@ final class SegmentInfo { this.docStoreIsCompoundFile = docStoreIsCompoundFile; this.hasProx = hasProx; delCount = 0; - assert docStoreOffset == -1 || docStoreSegment != null; + assert docStoreOffset == -1 || docStoreSegment != null: "dso=" + docStoreOffset + " dss=" + docStoreSegment + " docCount=" + docCount; } /** diff --git a/src/test/org/apache/lucene/TestMergeSchedulerExternal.java b/src/test/org/apache/lucene/TestMergeSchedulerExternal.java index 6030d891a77..c3608163261 100644 --- a/src/test/org/apache/lucene/TestMergeSchedulerExternal.java +++ b/src/test/org/apache/lucene/TestMergeSchedulerExternal.java @@ -91,7 +91,7 @@ public class TestMergeSchedulerExternal extends LuceneTestCase { Field idField = new Field("id", "", Field.Store.YES, Field.Index.NOT_ANALYZED); doc.add(idField); - IndexWriter writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); MyMergeScheduler ms = new MyMergeScheduler(); writer.setMergeScheduler(ms); writer.setMaxBufferedDocs(2); diff --git a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java index bd0db8761d6..f856ef75209 100644 --- a/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java +++ b/src/test/org/apache/lucene/TestSnapshotDeletionPolicy.java @@ -67,8 +67,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase Directory dir = new MockRAMDirectory(); SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy()); - IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp, - IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, true,new StandardAnalyzer(), dp); // Force frequent commits writer.setMaxBufferedDocs(2); Document doc = new Document(); @@ -80,8 +79,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase writer.close(); copyFiles(dir, cp); - writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp, - IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp); copyFiles(dir, cp); for(int i=0;i<7;i++) writer.addDocument(doc); @@ -89,8 +87,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase writer.close(); copyFiles(dir, cp); dp.release(); - writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp, - IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp); writer.close(); try { copyFiles(dir, cp); @@ -106,8 +103,7 @@ public class TestSnapshotDeletionPolicy extends LuceneTestCase final long stopTime = System.currentTimeMillis() + 7000; SnapshotDeletionPolicy dp = new SnapshotDeletionPolicy(new KeepOnlyLastCommitDeletionPolicy()); - final IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp, - IndexWriter.MaxFieldLength.LIMITED); + final IndexWriter writer = new IndexWriter(dir, true, new StandardAnalyzer(), dp); // Force frequent commits writer.setMaxBufferedDocs(2); diff --git a/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java b/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java index f6a25ee343e..d61dcebcd05 100755 --- a/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java +++ b/src/test/org/apache/lucene/index/TestAddIndexesNoOptimize.java @@ -425,7 +425,7 @@ public class TestAddIndexesNoOptimize extends LuceneTestCase { private IndexWriter newWriter(Directory dir, boolean create) throws IOException { - final IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), create, IndexWriter.MaxFieldLength.LIMITED); + final IndexWriter writer = new IndexWriter(dir, true, new WhitespaceAnalyzer(), create); writer.setMergePolicy(new LogDocMergePolicy()); return writer; } @@ -499,7 +499,7 @@ public class TestAddIndexesNoOptimize extends LuceneTestCase { public void testHangOnClose() throws IOException { Directory dir = new MockRAMDirectory(); - IndexWriter writer = new IndexWriter(dir, false, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); writer.setMergePolicy(new LogByteSizeMergePolicy()); writer.setMaxBufferedDocs(5); writer.setUseCompoundFile(false); @@ -525,7 +525,7 @@ public class TestAddIndexesNoOptimize extends LuceneTestCase { writer.close(); Directory dir2 = new MockRAMDirectory(); - writer = new IndexWriter(dir2, false, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir2, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); LogByteSizeMergePolicy lmp = new LogByteSizeMergePolicy(); lmp.setMinMergeMB(0.0001); writer.setMergePolicy(lmp); diff --git a/src/test/org/apache/lucene/index/TestAtomicUpdate.java b/src/test/org/apache/lucene/index/TestAtomicUpdate.java index ba534c5d571..31617e80cdc 100644 --- a/src/test/org/apache/lucene/index/TestAtomicUpdate.java +++ b/src/test/org/apache/lucene/index/TestAtomicUpdate.java @@ -33,8 +33,8 @@ public class TestAtomicUpdate extends LuceneTestCase { public class MockIndexWriter extends IndexWriter { - public MockIndexWriter(Directory dir, boolean autoCommit, Analyzer a, boolean create, MaxFieldLength mfl) throws IOException { - super(dir, autoCommit, a, create, mfl); + public MockIndexWriter(Directory dir, boolean autoCommit, Analyzer a, boolean create) throws IOException { + super(dir, autoCommit, a, create); } boolean testPoint(String name) { @@ -125,7 +125,7 @@ public class TestAtomicUpdate extends LuceneTestCase { TimedThread[] threads = new TimedThread[4]; - IndexWriter writer = new MockIndexWriter(directory, true, ANALYZER, true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new MockIndexWriter(directory, true, ANALYZER, true); writer.setMaxBufferedDocs(7); writer.setMergeFactor(3); diff --git a/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java b/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java index ec4c99f30ec..fe5d1f7e13a 100644 --- a/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java +++ b/src/test/org/apache/lucene/index/TestBackwardsCompatibility.java @@ -257,7 +257,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase Directory dir = FSDirectory.getDirectory(dirName); // open writer - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false); // add 10 docs for(int i=0;i<10;i++) { @@ -295,7 +295,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase searcher.close(); // optimize - writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false); writer.optimize(); writer.close(); @@ -345,7 +345,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase searcher.close(); // optimize - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false); writer.optimize(); writer.close(); @@ -402,7 +402,7 @@ public class TestBackwardsCompatibility extends LuceneTestCase boolean autoCommit = 0 == pass; - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true); writer.setRAMBufferSizeMB(16.0); for(int i=0;i<35;i++) { addDoc(writer, i); diff --git a/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java b/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java index d150c6d624d..4a59c239fef 100644 --- a/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java +++ b/src/test/org/apache/lucene/index/TestConcurrentMergeScheduler.java @@ -63,7 +63,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { FailOnlyOnFlush failure = new FailOnlyOnFlush(); directory.failOn(failure); - IndexWriter writer = new IndexWriter(directory, ANALYZER, true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(directory, true, ANALYZER, true); ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler(); writer.setMergeScheduler(cms); writer.setMaxBufferedDocs(2); @@ -100,7 +100,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { RAMDirectory directory = new MockRAMDirectory(); - IndexWriter writer = new IndexWriter(directory, ANALYZER, true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(directory, true, ANALYZER, true); ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler(); writer.setMergeScheduler(cms); @@ -145,7 +145,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { for(int pass=0;pass<2;pass++) { boolean autoCommit = pass==0; - IndexWriter writer = new IndexWriter(directory, autoCommit, ANALYZER, true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(directory, autoCommit, ANALYZER, true); for(int iter=0;iter<7;iter++) { ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler(); @@ -162,7 +162,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { TestIndexWriter.assertNoUnreferencedFiles(directory, "testNoExtraFiles autoCommit=" + autoCommit); // Reopen - writer = new IndexWriter(directory, autoCommit, ANALYZER, false, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(directory, autoCommit, ANALYZER, false); } writer.close(); @@ -180,7 +180,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { for(int pass=0;pass<2;pass++) { boolean autoCommit = pass==0; - IndexWriter writer = new IndexWriter(directory, autoCommit, ANALYZER, true, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(directory, autoCommit, ANALYZER, true); for(int iter=0;iter<10;iter++) { ConcurrentMergeScheduler cms = new ConcurrentMergeScheduler(); @@ -212,7 +212,7 @@ public class TestConcurrentMergeScheduler extends LuceneTestCase { reader.close(); // Reopen - writer = new IndexWriter(directory, autoCommit, ANALYZER, false, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(directory, autoCommit, ANALYZER, false); } writer.close(); } diff --git a/src/test/org/apache/lucene/index/TestDeletionPolicy.java b/src/test/org/apache/lucene/index/TestDeletionPolicy.java index 647f02d5a36..aca0277fe70 100644 --- a/src/test/org/apache/lucene/index/TestDeletionPolicy.java +++ b/src/test/org/apache/lucene/index/TestDeletionPolicy.java @@ -206,7 +206,7 @@ public class TestDeletionPolicy extends LuceneTestCase Directory dir = new RAMDirectory(); ExpirationTimeDeletionPolicy policy = new ExpirationTimeDeletionPolicy(dir, SECONDS); - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy); writer.setUseCompoundFile(useCompoundFile); writer.close(); @@ -215,7 +215,7 @@ public class TestDeletionPolicy extends LuceneTestCase // Record last time when writer performed deletes of // past commits lastDeleteTime = System.currentTimeMillis(); - writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy); writer.setUseCompoundFile(useCompoundFile); for(int j=0;j<17;j++) { addDoc(writer); @@ -277,7 +277,7 @@ public class TestDeletionPolicy extends LuceneTestCase Directory dir = new RAMDirectory(); policy.dir = dir; - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy); writer.setMaxBufferedDocs(10); writer.setUseCompoundFile(useCompoundFile); writer.setMergeScheduler(new SerialMergeScheduler()); @@ -288,7 +288,7 @@ public class TestDeletionPolicy extends LuceneTestCase } writer.close(); - writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy); writer.setUseCompoundFile(useCompoundFile); writer.optimize(); writer.close(); @@ -333,7 +333,7 @@ public class TestDeletionPolicy extends LuceneTestCase // Open & close a writer and assert that it // actually removed something: int preCount = dir.list().length; - writer = new IndexWriter(dir, false, new WhitespaceAnalyzer(), false, policy, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, new WhitespaceAnalyzer(), false, policy, IndexWriter.MaxFieldLength.LIMITED); writer.close(); int postCount = dir.list().length; assertTrue(postCount < preCount); @@ -359,7 +359,7 @@ public class TestDeletionPolicy extends LuceneTestCase Directory dir = new RAMDirectory(); - IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy, IndexWriter.MaxFieldLength.LIMITED); + IndexWriter writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), true, policy); writer.setMaxBufferedDocs(10); writer.setUseCompoundFile(useCompoundFile); for(int i=0;i<107;i++) { @@ -367,7 +367,7 @@ public class TestDeletionPolicy extends LuceneTestCase } writer.close(); - writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy, IndexWriter.MaxFieldLength.LIMITED); + writer = new IndexWriter(dir, autoCommit, new WhitespaceAnalyzer(), false, policy); writer.setUseCompoundFile(useCompoundFile); writer.optimize(); writer.close(); @@ -404,7 +404,7 @@ public class TestDeletionPolicy extends LuceneTestCase KeepLastNDeletionPolicy policy = new KeepLastNDeletionPolicy(N); for(int j=0;j