otis 2004/03/04 06:31:53 Modified: src/java/org/apache/lucene/index IndexWriter.java Log: - Added Javadocs to constructors - Removed trailing spaces and added ASL 2.0 Revision Changes Path 1.23 +72 -77 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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- IndexWriter.java 19 Feb 2004 18:12:03 -0000 1.22 +++ IndexWriter.java 4 Mar 2004 14:31:53 -0000 1.23 @@ -1,57 +1,19 @@ package org.apache.lucene.index; -/* ==================================================================== - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2001 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, - * if any, must include the following acknowledgment: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, - * if and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Apache" and "Apache Software Foundation" and - * "Apache Lucene" must not be used to endorse or promote products - * derived from this software without prior written permission. For - * written permission, please contact [EMAIL PROTECTED] +/** + * Copyright 2004 The Apache Software Foundation * - * 5. Products derived from this software may not be called "Apache", - * "Apache Lucene", nor may "Apache" appear in their name, without - * prior written permission of the Apache Software Foundation. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== + * http://www.apache.org/licenses/LICENSE-2.0 * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - * <http://www.apache.org/>. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ import java.io.IOException; @@ -92,7 +54,7 @@ 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 @@ -103,12 +65,12 @@ private Lock writeLock; - /** Use compound file setting. Defaults to false to maintain multiple files + /** Use compound file setting. Defaults to false to maintain multiple files * per segment behavior. - */ + */ private boolean useCompoundFile = false; - - + + /** Setting to turn on usage of a compound file. When on, multiple files * for each segment are merged into a single file once the segment creation * is finished. This is done regardless of what directory is in use. @@ -116,7 +78,7 @@ public boolean getUseCompoundFile() { return useCompoundFile; } - + /** Setting to turn on usage of a compound file. When on, multiple files * for each segment are merged into a single file once the segment creation * is finished. This is done regardless of what directory is in use. @@ -125,7 +87,7 @@ useCompoundFile = value; } - + /** Expert: Set the Similarity implementation used by this IndexWriter. * * @see Similarity#setDefault(Similarity) @@ -142,28 +104,61 @@ return this.similarity; } - /** Constructs an IndexWriter for the index in <code>path</code>. Text will - be analyzed with <code>a</code>. If <code>create</code> is true, then a - new, empty index will be created in <code>path</code>, replacing the index - already there, if any. */ + /** + * Constructs an IndexWriter for the index in <code>path</code>. + * Text will be analyzed with <code>a</code>. If <code>create</code> + * is true, then a new, empty index will be created in + * <code>path</code>, replacing the index already there, if any. + * + * @param path the path to the index directory + * @param a the analyzer to use + * @param create <code>true</code> to create the index or overwrite + * the existing one; <code>false</code> to append to the existing + * index + * @param IOException if the directory cannot be read/written to, or + * if it does not exist, and <code>create</code> is + * <code>false</code> + */ public IndexWriter(String path, Analyzer a, boolean create) throws IOException { this(FSDirectory.getDirectory(path, create), a, create); } - /** Constructs an IndexWriter for the index in <code>path</code>. Text will - be analyzed with <code>a</code>. If <code>create</code> is true, then a - new, empty index will be created in <code>path</code>, replacing the index - already there, if any. */ + /** + * Constructs an IndexWriter for the index in <code>path</code>. + * Text will be analyzed with <code>a</code>. If <code>create</code> + * is true, then a new, empty index will be created in + * <code>path</code>, replacing the index already there, if any. + * + * @param path the path to the index directory + * @param a the analyzer to use + * @param create <code>true</code> to create the index or overwrite + * the existing one; <code>false</code> to append to the existing + * index + * @param IOException if the directory cannot be read/written to, or + * if it does not exist, and <code>create</code> is + * <code>false</code> + */ public IndexWriter(File path, Analyzer a, boolean create) throws IOException { this(FSDirectory.getDirectory(path, create), a, create); } - /** Constructs an IndexWriter for the index in <code>d</code>. Text will be - analyzed with <code>a</code>. If <code>create</code> is true, then a new, - empty index will be created in <code>d</code>, replacing the index already - there, if any. */ + /** + * Constructs an IndexWriter for the index in <code>d</code>. + * Text will be analyzed with <code>a</code>. If <code>create</code> + * is true, then a new, empty index will be created in + * <code>d</code>, replacing the index already there, if any. + * + * @param path the path to the index directory + * @param a the analyzer to use + * @param create <code>true</code> to create the index or overwrite + * the existing one; <code>false</code> to append to the existing + * index + * @param IOException if the directory cannot be read/written to, or + * if it does not exist, and <code>create</code> is + * <code>false</code> + */ public IndexWriter(Directory d, Analyzer a, final boolean create) throws IOException { directory = d; @@ -275,13 +270,13 @@ * * <p>This must never be less than 2. The default value is 10.*/ public int mergeFactor = 10; - + /** Determines the minimal number of documents required before the buffered * in-memory documents are merging and a new Segment is created. * Since Documents are merged in a [EMAIL PROTECTED] org.apache.lucene.store.RAMDirectory}, * large value gives faster indexing. At the same time, mergeFactor limits * the number of files open in a FSDirectory. - * + * * <p> The default value is 10.*/ public int minMergeDocs = 10; @@ -304,12 +299,12 @@ while (segmentInfos.size() > 1 || (segmentInfos.size() == 1 && (SegmentReader.hasDeletions(segmentInfos.info(0)) || - (useCompoundFile && + (useCompoundFile && !SegmentReader.usesCompoundFile(segmentInfos.info(0))) || segmentInfos.info(0).dir != directory))) { int minSegment = segmentInfos.size() - mergeFactor; mergeSegments(minSegment < 0 ? 0 : minSegment); - } + } } /** Merges all segments from an array of indexes into this index. @@ -412,9 +407,9 @@ throws IOException { String mergedName = newSegmentName(); if (infoStream != null) infoStream.print("merging segments"); - SegmentMerger merger = + SegmentMerger merger = new SegmentMerger(directory, mergedName, useCompoundFile); - + final Vector segmentsToDelete = new Vector(); for (int i = minSegment; i < segmentInfos.size(); i++) { SegmentInfo si = segmentInfos.info(i); @@ -426,14 +421,14 @@ (reader.directory()==this.ramDirectory)) segmentsToDelete.addElement(reader); // queue segment for deletion } - + int mergedDocCount = merger.merge(); - + if (infoStream != null) { infoStream.println(); infoStream.println(" into "+mergedName+" ("+mergedDocCount+" docs)"); } - + segmentInfos.setSize(minSegment); // pop old infos & add new segmentInfos.addElement(new SegmentInfo(mergedName, mergedDocCount, directory));
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]