- Added support for setting various Lucene properties via system properties.

git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150233 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2004-03-18 19:05:18 +00:00
parent 2e297fe08d
commit 712e742b78
4 changed files with 44 additions and 12 deletions

View File

@ -61,6 +61,16 @@ $Id$
strings: http://issues.apache.org/bugzilla/show_bug.cgi?id=24665 strings: http://issues.apache.org/bugzilla/show_bug.cgi?id=24665
(Jean-Francois Halleux via Otis) (Jean-Francois Halleux via Otis)
12. Added support for overriding default values for the following,
using system properties:
- default commit lock timeout
- default maxFieldLength
- default maxMergeDocs
- default mergeFactor
- default minMergeDocs
- default write lock timeout
(Otis)
1.3 final 1.3 final

View File

@ -49,14 +49,31 @@ import org.apache.lucene.analysis.Analyzer;
*/ */
public class IndexWriter { public class IndexWriter {
public static long WRITE_LOCK_TIMEOUT = 1000; public static long WRITE_LOCK_TIMEOUT =
public static long COMMIT_LOCK_TIMEOUT = 10000; Integer.parseInt(System.getProperty("org.apache.lucene.writeLockTimeout",
"1000"));
public static long COMMIT_LOCK_TIMEOUT =
Integer.parseInt(System.getProperty("org.apache.lucene.commitLockTimeout",
"10000"));
public static final String WRITE_LOCK_NAME = "write.lock"; public static final String WRITE_LOCK_NAME = "write.lock";
public static final String COMMIT_LOCK_NAME = "commit.lock"; public static final String COMMIT_LOCK_NAME = "commit.lock";
private Directory directory; // where this index resides private static final int DEFAULT_MERGE_FACTOR =
private Analyzer analyzer; // how to analyze text Integer.parseInt(System.getProperty("org.apache.lucene.mergeFactor",
"10"));
private static final int DEFAULT_MIN_MERGE_DOCS =
Integer.parseInt(System.getProperty("org.apache.lucene.minMergeDocs",
"10"));
private static final int DEFAULT_MAX_FIELD_LENGTH =
Integer.parseInt(System.getProperty("org.apache.lucene.maxFieldLength",
"10000"));
private static final int DEFAULT_MAX_MERGE_DOCS =
Integer.parseInt(System.getProperty("org.apache.lucene.maxMergeDocs",
String.valueOf(Integer.MAX_VALUE)));
private Directory directory; // where this index resides
private Analyzer analyzer; // how to analyze text
private Similarity similarity = Similarity.getDefault(); // how to normalize private Similarity similarity = Similarity.getDefault(); // how to normalize
@ -228,7 +245,7 @@ public class IndexWriter {
* is your memory, but you should anticipate an OutOfMemoryError.<p/> * is your memory, but you should anticipate an OutOfMemoryError.<p/>
* By default, no more than 10,000 terms will be indexed for a field. * By default, no more than 10,000 terms will be indexed for a field.
*/ */
public int maxFieldLength = 10000; public int maxFieldLength = DEFAULT_MAX_FIELD_LENGTH;
/** /**
* Adds a document to this index. If the document contains more than * Adds a document to this index. If the document contains more than
@ -269,7 +286,7 @@ public class IndexWriter {
* interactively maintained. * interactively maintained.
* *
* <p>This must never be less than 2. The default value is 10.*/ * <p>This must never be less than 2. The default value is 10.*/
public int mergeFactor = 10; public int mergeFactor = DEFAULT_MERGE_FACTOR;
/** Determines the minimal number of documents required before the buffered /** Determines the minimal number of documents required before the buffered
* in-memory documents are merging and a new Segment is created. * in-memory documents are merging and a new Segment is created.
@ -278,7 +295,7 @@ public class IndexWriter {
* the number of files open in a FSDirectory. * the number of files open in a FSDirectory.
* *
* <p> The default value is 10.*/ * <p> The default value is 10.*/
public int minMergeDocs = 10; public int minMergeDocs = DEFAULT_MIN_MERGE_DOCS;
/** Determines the largest number of documents ever merged by addDocument(). /** Determines the largest number of documents ever merged by addDocument().
@ -287,7 +304,7 @@ public class IndexWriter {
* Larger values are best for batched indexing and speedier searches. * Larger values are best for batched indexing and speedier searches.
* *
* <p>The default value is {@link Integer#MAX_VALUE}. */ * <p>The default value is {@link Integer#MAX_VALUE}. */
public int maxMergeDocs = Integer.MAX_VALUE; public int maxMergeDocs = DEFAULT_MAX_MERGE_DOCS;
/** If non-null, information about merges will be printed to this. */ /** If non-null, information about merges will be printed to this. */
public PrintStream infoStream = null; public PrintStream infoStream = null;

View File

@ -62,7 +62,9 @@ import org.apache.lucene.index.IndexReader;
queries, typically {@link TermQuery}s or {@link PhraseQuery}s. queries, typically {@link TermQuery}s or {@link PhraseQuery}s.
*/ */
public class BooleanQuery extends Query { public class BooleanQuery extends Query {
private static int maxClauseCount = 1024; private static int maxClauseCount =
Integer.parseInt(System.getProperty("org.apache.lucene.maxClauseCount",
"1024"));
/** Thrown when an attempt is made to add more than {@link /** Thrown when an attempt is made to add more than {@link
* #getMaxClauseCount()} clauses. */ * #getMaxClauseCount()} clauses. */

View File

@ -74,6 +74,9 @@ import java.io.IOException;
public abstract class Lock { public abstract class Lock {
public static long LOCK_POLL_INTERVAL = 1000; public static long LOCK_POLL_INTERVAL = 1000;
private static final String LOCK_DIR =
System.getProperty("org.apache.lucene.lockdir",
System.getProperty("java.io.tmpdir"));
/** Attempts to obtain exclusive access and immediately return /** Attempts to obtain exclusive access and immediately return
* upon success or failure. * upon success or failure.