You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by ot...@apache.org on 2004/03/18 20:05:18 UTC

cvs commit: jakarta-lucene/src/java/org/apache/lucene/store Lock.java

otis        2004/03/18 11:05:18

  Modified:    .        CHANGES.txt
               src/java/org/apache/lucene/index IndexWriter.java
               src/java/org/apache/lucene/search BooleanQuery.java
               src/java/org/apache/lucene/store Lock.java
  Log:
  - Added support for setting various Lucene properties via system properties.
  
  Revision  Changes    Path
  1.76      +11 -1     jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.75
  retrieving revision 1.76
  diff -u -r1.75 -r1.76
  --- CHANGES.txt	3 Mar 2004 11:24:48 -0000	1.75
  +++ CHANGES.txt	18 Mar 2004 19:05:18 -0000	1.76
  @@ -61,6 +61,16 @@
       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
   
  
  
  
  1.24      +25 -8     jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java
  
  Index: IndexWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java,v
  retrieving revision 1.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- IndexWriter.java	4 Mar 2004 14:31:53 -0000	1.23
  +++ IndexWriter.java	18 Mar 2004 19:05:18 -0000	1.24
  @@ -49,14 +49,31 @@
     */
   
   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 @@
      * 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 @@
      * 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 @@
      * 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 @@
      * 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;
  
  
  
  1.20      +6 -4      jakarta-lucene/src/java/org/apache/lucene/search/BooleanQuery.java
  
  Index: BooleanQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/BooleanQuery.java,v
  retrieving revision 1.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- BooleanQuery.java	6 Feb 2004 19:19:20 -0000	1.19
  +++ BooleanQuery.java	18 Mar 2004 19:05:18 -0000	1.20
  @@ -62,7 +62,9 @@
     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 void add(BooleanClause clause) {
       if (clauses.size() >= maxClauseCount)
         throw new TooManyClauses();
  -    
  +
       clauses.addElement(clause);
     }
   
  @@ -140,7 +142,7 @@
           if (!c.prohibited)
             sum += w.sumOfSquaredWeights();         // sum sub weights
         }
  -      
  +
         sum *= getBoost() * getBoost();             // boost each sub-weight
   
         return sum ;
  @@ -164,7 +166,7 @@
         // 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);
  
  
  
  1.6       +4 -1      jakarta-lucene/src/java/org/apache/lucene/store/Lock.java
  
  Index: Lock.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Lock.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Lock.java	13 Oct 2003 14:29:47 -0000	1.5
  +++ Lock.java	18 Mar 2004 19:05:18 -0000	1.6
  @@ -74,6 +74,9 @@
   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.
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-lucene/src/java/org/apache/lucene/store Lock.java

Posted by Otis Gospodnetic <ot...@yahoo.com>.
I actually already documented these properties in xdocs format (commit
coming).  But making things public and using Javadocs is also a good
idea.

LOCK_DIR - good catch - changed things.

Otis

--- Doug Cutting <cu...@apache.org> wrote:
> otis@apache.org wrote:
> >   - Added support for setting various Lucene properties via system
> properties.
> 
> Otis,
> 
> Thanks for doing this.
> 
> Now we need to get these properties into the documentation.  The
> easiest 
> approach is simply to make all of these 'private static final' fields
> 
> into 'public static final' fields which then mention the system
> property 
> which can be used to override their default.
> 
> Also, is Lock.LOCK_DIR actually used?  The diff didn't show that. 
> Since 
> this is to be used by FSDirectory, the parameter should probably be
> in 
> FSDirectory.java, not Lock.java.  It wouldn't be relevant to, e.g., a
> 
> database-based lock implementation.
> 
> And when it is used we should permit it to be relative to the index 
> directory.  So, in FSDirectory, we might have a field like:
> 
>    private File lockDir;
> 
> and in FSDirectory ctor, add something like:
> 
>    lockDir = new File(LOCK_DIR);
>    if (!lockDir.isAbsolute()) {
>      lockDir = new File(directory, LOCK_DIR);
>    }
> 
> Then use lockDir when creating lock file names.  This will permit 
> someone to simply set org.apache.lucene.lockdir to "." to get the old
> 
> behaviour where lock files are placed alongside indexes.
> 
> Does that makes sense?
> 
> Doug
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: lucene-dev-help@jakarta.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org


Re: cvs commit: jakarta-lucene/src/java/org/apache/lucene/store Lock.java

Posted by Doug Cutting <cu...@apache.org>.
otis@apache.org wrote:
>   - Added support for setting various Lucene properties via system properties.

Otis,

Thanks for doing this.

Now we need to get these properties into the documentation.  The easiest 
approach is simply to make all of these 'private static final' fields 
into 'public static final' fields which then mention the system property 
which can be used to override their default.

Also, is Lock.LOCK_DIR actually used?  The diff didn't show that.  Since 
this is to be used by FSDirectory, the parameter should probably be in 
FSDirectory.java, not Lock.java.  It wouldn't be relevant to, e.g., a 
database-based lock implementation.

And when it is used we should permit it to be relative to the index 
directory.  So, in FSDirectory, we might have a field like:

   private File lockDir;

and in FSDirectory ctor, add something like:

   lockDir = new File(LOCK_DIR);
   if (!lockDir.isAbsolute()) {
     lockDir = new File(directory, LOCK_DIR);
   }

Then use lockDir when creating lock file names.  This will permit 
someone to simply set org.apache.lucene.lockdir to "." to get the old 
behaviour where lock files are placed alongside indexes.

Does that makes sense?

Doug

---------------------------------------------------------------------
To unsubscribe, e-mail: lucene-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: lucene-dev-help@jakarta.apache.org