- 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
(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

View File

@ -49,14 +49,31 @@ import org.apache.lucene.analysis.Analyzer;
*/
public class IndexWriter {
public static long WRITE_LOCK_TIMEOUT = 1000;
public static long COMMIT_LOCK_TIMEOUT = 10000;
public static long WRITE_LOCK_TIMEOUT =
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 COMMIT_LOCK_NAME = "commit.lock";
private Directory directory; // where this index resides
private Analyzer analyzer; // how to analyze text
private static final int DEFAULT_MERGE_FACTOR =
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
@ -228,7 +245,7 @@ public class IndexWriter {
* is your memory, but you should anticipate an OutOfMemoryError.<p/>
* 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
@ -269,7 +286,7 @@ public class IndexWriter {
* interactively maintained.
*
* <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
* 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.
*
* <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().
@ -287,7 +304,7 @@ public class IndexWriter {
* Larger values are best for batched indexing and speedier searches.
*
* <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. */
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.
*/
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
* #getMaxClauseCount()} clauses. */
@ -107,7 +109,7 @@ public class BooleanQuery extends Query {
public void add(BooleanClause clause) {
if (clauses.size() >= maxClauseCount)
throw new TooManyClauses();
clauses.addElement(clause);
}
@ -140,7 +142,7 @@ public class BooleanQuery extends Query {
if (!c.prohibited)
sum += w.sumOfSquaredWeights(); // sum sub weights
}
sum *= getBoost() * getBoost(); // boost each sub-weight
return sum ;
@ -164,7 +166,7 @@ public class BooleanQuery extends Query {
// from a BooleanScorer are not always sorted by document number (sigh)
// and hence BooleanScorer cannot implement skipTo() correctly, which is
// required by ConjunctionScorer.
boolean allRequired = true;
boolean allRequired = true;
boolean noneBoolean = true;
for (int i = 0 ; i < weights.size(); i++) {
BooleanClause c = (BooleanClause)clauses.elementAt(i);

View File

@ -74,6 +74,9 @@ import java.io.IOException;
public abstract class Lock {
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
* upon success or failure.