lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From o...@apache.org
Subject cvs commit: jakarta-lucene/src/java/org/apache/lucene/util PriorityQueue.java
Date Thu, 07 Nov 2002 05:55:40 GMT
otis        2002/11/06 21:55:40

  Modified:    src/java/org/apache/lucene/analysis Analyzer.java
                        CharTokenizer.java StopFilter.java TokenFilter.java
                        TokenStream.java Tokenizer.java
               src/java/org/apache/lucene/index DocumentWriter.java
                        IndexReader.java IndexWriter.java
                        MultipleTermPositions.java SegmentReader.java
                        SegmentsReader.java TermEnum.java
                        TermInfosWriter.java
               src/java/org/apache/lucene/queryParser FastCharStream.java
                        QueryParser.jj
               src/java/org/apache/lucene/search Filter.java
                        FilteredTermEnum.java FuzzyQuery.java
                        FuzzyTermEnum.java MultiTermQuery.java
                        PhraseScorer.java Query.java Searcher.java
                        Similarity.java WildcardTermEnum.java
               src/java/org/apache/lucene/store Directory.java
                        FSDirectory.java InputStream.java OutputStream.java
                        RAMDirectory.java
               src/java/org/apache/lucene/util PriorityQueue.java
  Log:
  - Removed compiler warnings (jikes 1.17).  Style stuff only.
  
  Revision  Changes    Path
  1.3       +1 -1      jakarta-lucene/src/java/org/apache/lucene/analysis/Analyzer.java
  
  Index: Analyzer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/Analyzer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Analyzer.java	25 Sep 2001 18:38:50 -0000	1.2
  +++ Analyzer.java	7 Nov 2002 05:55:39 -0000	1.3
  @@ -66,7 +66,7 @@
    *  WARNING: You must override one of the methods defined by this class in your
    *  subclass or the Analyzer will enter an infinite loop.
    */
  -abstract public class Analyzer {
  +public abstract class Analyzer {
     /** Creates a TokenStream which tokenizes all the text in the provided
       Reader.  Default implementation forwards to tokenStream(Reader) for 
       compatibility with older version.  Override to allow Analyzer to choose 
  
  
  
  1.2       +2 -2      jakarta-lucene/src/java/org/apache/lucene/analysis/CharTokenizer.java
  
  Index: CharTokenizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/CharTokenizer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CharTokenizer.java	24 Jan 2002 19:02:52 -0000	1.1
  +++ CharTokenizer.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -63,8 +63,8 @@
     }
   
     private int offset = 0, bufferIndex=0, dataLen=0;
  -  private final static int MAX_WORD_LEN = 255;
  -  private final static int IO_BUFFER_SIZE = 1024;
  +  private static final int MAX_WORD_LEN = 255;
  +  private static final int IO_BUFFER_SIZE = 1024;
     private final char[] buffer = new char[MAX_WORD_LEN];
     private final char[] ioBuffer = new char[IO_BUFFER_SIZE];
   
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/analysis/StopFilter.java
  
  Index: StopFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/StopFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StopFilter.java	18 Sep 2001 16:29:50 -0000	1.1
  +++ StopFilter.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -80,7 +80,7 @@
     /** Builds a Hashtable from an array of stop words, appropriate for passing
       into the StopFilter constructor.  This permits this table construction to
       be cached once when an Analyzer is constructed. */
  -  public final static Hashtable makeStopTable(String[] stopWords) {
  +  public static final Hashtable makeStopTable(String[] stopWords) {
       Hashtable stopTable = new Hashtable(stopWords.length);
       for (int i = 0; i < stopWords.length; i++)
         stopTable.put(stopWords[i], stopWords[i]);
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/analysis/TokenFilter.java
  
  Index: TokenFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/TokenFilter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TokenFilter.java	18 Sep 2001 16:29:51 -0000	1.1
  +++ TokenFilter.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -61,7 +61,7 @@
     This is an abstract class.
     */
   
  -abstract public class TokenFilter extends TokenStream {
  +public abstract class TokenFilter extends TokenStream {
     /** The source of tokens for this filter. */
     protected TokenStream input;
   
  
  
  
  1.2       +2 -2      jakarta-lucene/src/java/org/apache/lucene/analysis/TokenStream.java
  
  Index: TokenStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/TokenStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TokenStream.java	18 Sep 2001 16:29:51 -0000	1.1
  +++ TokenStream.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -68,9 +68,9 @@
     </ul>
     */
   
  -abstract public class TokenStream {
  +public abstract class TokenStream {
     /** Returns the next token in the stream, or null at EOS. */
  -  abstract public Token next() throws IOException;
  +  public abstract Token next() throws IOException;
   
     /** Releases resources associated with this stream. */
     public void close() throws IOException {}
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/analysis/Tokenizer.java
  
  Index: Tokenizer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/analysis/Tokenizer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Tokenizer.java	18 Sep 2001 16:29:51 -0000	1.1
  +++ Tokenizer.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -62,7 +62,7 @@
     This is an abstract class.
    */
   
  -abstract public class Tokenizer extends TokenStream {
  +public abstract class Tokenizer extends TokenStream {
     /** The text source for this Tokenizer. */
     protected Reader input;
   
  
  
  
  1.4       +14 -14    jakarta-lucene/src/java/org/apache/lucene/index/DocumentWriter.java
  
  Index: DocumentWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/DocumentWriter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- DocumentWriter.java	5 Aug 2002 17:15:00 -0000	1.3
  +++ DocumentWriter.java	7 Nov 2002 05:55:39 -0000	1.4
  @@ -75,13 +75,13 @@
     private Directory directory;
     private FieldInfos fieldInfos;
     private int maxFieldLength;
  -  
  +
     DocumentWriter(Directory d, Analyzer a, int mfl) {
       directory = d;
       analyzer = a;
       maxFieldLength = mfl;
     }
  -  
  +
     final void addDocument(String segment, Document doc)
          throws IOException {
       // write field names
  @@ -97,7 +97,7 @@
       } finally {
         fieldsWriter.close();
       }
  -      
  +
       // invert doc into postingTable
       postingTable.clear();			  // clear postingTable
       fieldLengths = new int[fieldInfos.size()];	  // init fieldLengths
  @@ -128,7 +128,7 @@
   
       // write norms of indexed fields
       writeNorms(doc, segment);
  -    
  +
     }
   
     // Keys are Terms, values are Postings.
  @@ -216,7 +216,7 @@
       return array;
     }
   
  -  static private final void quickSort(Posting[] postings, int lo, int hi) {
  +  private static final void quickSort(Posting[] postings, int lo, int hi) {
       if(lo >= hi)
         return;
   
  @@ -232,7 +232,7 @@
         Posting tmp = postings[mid];
         postings[mid] = postings[hi];
         postings[hi] = tmp;
  -      
  +
         if(postings[lo].term.compareTo(postings[mid].term) > 0) {
   	Posting tmp2 = postings[lo];
           postings[lo] = postings[mid];
  @@ -244,17 +244,17 @@
       int right = hi - 1;
   
       if (left >= right)
  -      return; 
  +      return;
   
       Term partition = postings[mid].term;
  -    
  +
       for( ;; ) {
         while(postings[right].term.compareTo(partition) > 0)
   	--right;
  -      
  +
         while(left < right && postings[left].term.compareTo(partition) <= 0)
   	++left;
  -      
  +
         if(left < right) {
           Posting tmp = postings[left];
           postings[left] = postings[right];
  @@ -264,7 +264,7 @@
   	break;
         }
       }
  -    
  +
       quickSort(postings, lo, left);
       quickSort(postings, left + 1, hi);
     }
  @@ -286,7 +286,7 @@
   	// add an entry to the dictionary with pointers to prox and freq files
   	ti.set(1, freq.getFilePointer(), prox.getFilePointer());
   	tis.add(posting.term, ti);
  -	
  +
   	// add an entry to the freq file
   	int f = posting.freq;
   	if (f == 1)				  // optimize freq=1
  @@ -295,7 +295,7 @@
   	  freq.writeVInt(0);			  // the document number
   	  freq.writeVInt(f);			  // frequency in doc
   	}
  -	
  +
   	int lastPosition = 0;			  // write positions
   	int[] positions = posting.positions;
   	for (int j = 0; j < f; j++) {		  // use delta-encoding
  @@ -336,7 +336,7 @@
     Term term;					  // the Term
     int freq;					  // its frequency in doc
     int[] positions;				  // positions it occurs at
  -  
  +
     Posting(Term t, int position) {
       term = t;
       freq = 1;
  
  
  
  1.11      +12 -12    jakarta-lucene/src/java/org/apache/lucene/index/IndexReader.java
  
  Index: IndexReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/IndexReader.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- IndexReader.java	29 Jul 2002 19:11:15 -0000	1.10
  +++ IndexReader.java	7 Nov 2002 05:55:39 -0000	1.11
  @@ -75,7 +75,7 @@
     as documents are added to and deleted from an index.  Clients should thus not
     rely on a given document having the same number between sessions. */
   
  -abstract public class IndexReader {
  +public abstract class IndexReader {
     protected IndexReader(Directory directory) {
       this.directory = directory;
     }
  @@ -162,42 +162,42 @@
     }
   
     /** Returns the number of documents in this index. */
  -  abstract public int numDocs();
  +  public abstract int numDocs();
   
     /** Returns one greater than the largest possible document number.
       This may be used to, e.g., determine how big to allocate an array which
       will have an element for every document number in an index.
      */
  -  abstract public int maxDoc();
  +  public abstract int maxDoc();
   
     /** Returns the stored fields of the <code>n</code><sup>th</sup>
         <code>Document</code> in this index. */
  -  abstract public Document document(int n) throws IOException;
  +  public abstract Document document(int n) throws IOException;
   
     /** Returns true if document <i>n</i> has been deleted */
  -  abstract public boolean isDeleted(int n);
  +  public abstract boolean isDeleted(int n);
   
     /** Returns the byte-encoded normalization factor for the named field of
      * every document.  This is used by the search code to score documents.
      *
      * @see Field#setBoost(float)
      */
  -  abstract public byte[] norms(String field) throws IOException;
  +  public abstract byte[] norms(String field) throws IOException;
   
     /** Returns an enumeration of all the terms in the index.
       The enumeration is ordered by Term.compareTo().  Each term
       is greater than all that precede it in the enumeration.
      */
  -  abstract public TermEnum terms() throws IOException;
  +  public abstract TermEnum terms() throws IOException;
   
     /** Returns an enumeration of all terms after a given term.
       The enumeration is ordered by Term.compareTo().  Each term
       is greater than all that precede it in the enumeration.
      */
  -  abstract public TermEnum terms(Term t) throws IOException;
  +  public abstract TermEnum terms(Term t) throws IOException;
   
     /** Returns the number of documents containing the term <code>t</code>. */
  -  abstract public int docFreq(Term t) throws IOException;
  +  public abstract int docFreq(Term t) throws IOException;
   
     /** Returns an enumeration of all the documents which contain
       <code>term</code>. For each document, the document number, the frequency
of
  @@ -215,7 +215,7 @@
     }
   
     /** Returns an unpositioned {@link TermDocs} enumerator. */
  -  abstract public TermDocs termDocs() throws IOException;
  +  public abstract TermDocs termDocs() throws IOException;
   
     /** Returns an enumeration of all the documents which contain
       <code>term</code>.  For each document, in addition to the document number
  @@ -239,7 +239,7 @@
     }
   
     /** Returns an unpositioned {@link TermPositions} enumerator. */
  -  abstract public TermPositions termPositions() throws IOException;
  +  public abstract TermPositions termPositions() throws IOException;
   
     /** Deletes the document numbered <code>docNum</code>.  Once a document is
       deleted it will not appear in TermDocs or TermPostitions enumerations.
  @@ -247,7 +247,7 @@
       method will result in an error.  The presence of this document may still be
       reflected in the {@link #docFreq} statistic, though
       this will be corrected eventually as the index is further modified.  */
  -  public synchronized final void delete(int docNum) throws IOException {
  +  public final synchronized void delete(int docNum) throws IOException {
       if (writeLock == null) {
         Lock writeLock = directory.makeLock("write.lock");
         if (!writeLock.obtain())			  // obtain write lock
  
  
  
  1.9       +12 -0     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- IndexWriter.java	7 Aug 2002 16:28:08 -0000	1.8
  +++ IndexWriter.java	7 Nov 2002 05:55:39 -0000	1.9
  @@ -65,6 +65,7 @@
   import org.apache.lucene.store.Lock;
   import org.apache.lucene.store.InputStream;
   import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.search.Similarity;
   import org.apache.lucene.document.Document;
   import org.apache.lucene.analysis.Analyzer;
   
  @@ -93,6 +94,8 @@
   
     private Lock writeLock;
   
  +  private Similarity 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
  @@ -403,5 +406,14 @@
         output.close();
       }
       directory.renameFile("deleteable.new", "deletable");
  +  }
  +
  +  /**
  +   * Sets the <code>Similarity</code> implementation to use.
  +   *
  +   * @param sim an instance of a class that implements  <code>Similarity</code
  +   */
  +  public void setSimilarity(Similarity sim) {
  +    similarity = sim;
     }
   }
  
  
  
  1.2       +2 -2      jakarta-lucene/src/java/org/apache/lucene/index/MultipleTermPositions.java
  
  Index: MultipleTermPositions.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/MultipleTermPositions.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MultipleTermPositions.java	18 Jul 2002 14:39:58 -0000	1.1
  +++ MultipleTermPositions.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -72,7 +72,7 @@
   public class MultipleTermPositions
       implements TermPositions
   {
  -    private final static class TermPositionsQueue
  +    private static final class TermPositionsQueue
   	extends PriorityQueue
       {
   	TermPositionsQueue(List termPositions)
  @@ -100,7 +100,7 @@
   	}
       }
   
  -    private final static class IntQueue
  +    private static final class IntQueue
       {
   	private int _arraySize = 16;
   
  
  
  
  1.6       +1 -1      jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java
  
  Index: SegmentReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentReader.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SegmentReader.java	8 Aug 2002 17:56:19 -0000	1.5
  +++ SegmentReader.java	7 Nov 2002 05:55:39 -0000	1.6
  @@ -143,7 +143,7 @@
         directory.close();
     }
   
  -  final static boolean hasDeletions(SegmentInfo si) throws IOException {
  +  static final boolean hasDeletions(SegmentInfo si) throws IOException {
       return si.dir.fileExists(si.name + ".del");
     }
   
  
  
  
  1.9       +3 -3      jakarta-lucene/src/java/org/apache/lucene/index/SegmentsReader.java
  
  Index: SegmentsReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentsReader.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SegmentsReader.java	20 Sep 2002 17:25:13 -0000	1.8
  +++ SegmentsReader.java	7 Nov 2002 05:55:39 -0000	1.9
  @@ -84,7 +84,7 @@
       starts[readers.length] = maxDoc;
     }
   
  -  public synchronized final int numDocs() {
  +  public final synchronized int numDocs() {
       if (numDocs == -1) {			  // check cache
         int n = 0;				  // cache miss--recompute
         for (int i = 0; i < readers.length; i++)
  @@ -108,7 +108,7 @@
       return readers[i].isDeleted(n - starts[i]);	  // dispatch to segment reader
     }
   
  -  synchronized final void doDelete(int n) throws IOException {
  +  final synchronized void doDelete(int n) throws IOException {
       numDocs = -1;				  // invalidate cache
       int i = readerIndex(n);			  // find segment num
       readers[i].doDelete(n - starts[i]);		  // dispatch to segment reader
  
  
  
  1.3       +4 -4      jakarta-lucene/src/java/org/apache/lucene/index/TermEnum.java
  
  Index: TermEnum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermEnum.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TermEnum.java	21 Jan 2002 17:07:23 -0000	1.2
  +++ TermEnum.java	7 Nov 2002 05:55:39 -0000	1.3
  @@ -63,14 +63,14 @@
   
   public abstract class TermEnum {
     /** Increments the enumeration to the next element.  True if one exists.*/
  -  abstract public boolean next() throws IOException;
  +  public abstract boolean next() throws IOException;
   
     /** Returns the current Term in the enumeration.*/
  -  abstract public Term term();
  +  public abstract Term term();
   
     /** Returns the docFreq of the current Term in the enumeration.*/
  -  abstract public int docFreq();
  +  public abstract int docFreq();
   
     /** Closes the enumeration to further activity, freeing resources. */
  -  abstract public void close() throws IOException;
  +  public abstract void close() throws IOException;
   }
  
  
  
  1.2       +6 -6      jakarta-lucene/src/java/org/apache/lucene/index/TermInfosWriter.java
  
  Index: TermInfosWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermInfosWriter.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TermInfosWriter.java	18 Sep 2001 16:29:55 -0000	1.1
  +++ TermInfosWriter.java	7 Nov 2002 05:55:39 -0000	1.2
  @@ -67,7 +67,7 @@
     private Term lastTerm = new Term("", "");
     private TermInfo lastTi = new TermInfo();
     private int size = 0;
  -  
  +
     static final int INDEX_INTERVAL = 128;
     private long lastIndexPointer = 0;
     private boolean isIndex = false;
  @@ -75,7 +75,7 @@
     private TermInfosWriter other = null;
   
     TermInfosWriter(Directory directory, String segment, FieldInfos fis)
  -       throws IOException, SecurityException {
  +       throws IOException {
       initialize(directory, segment, fis, false);
       other = new TermInfosWriter(directory, segment, fis, true);
       other.other = this;
  @@ -98,7 +98,7 @@
       Term must be lexicographically greater than all previous Terms added.
       TermInfo pointers must be positive and greater than all previous.*/
     final void add(Term term, TermInfo ti)
  -       throws IOException, SecurityException {
  +       throws IOException {
       if (!isIndex && term.compareTo(lastTerm) <= 0)
         throw new IOException("term out of order");
       if (ti.freqPointer < lastTi.freqPointer)
  @@ -127,7 +127,7 @@
          throws IOException {
       int start = stringDifference(lastTerm.text, term.text);
       int length = term.text.length() - start;
  -    
  +
       output.writeVInt(start);			  // write shared prefix length
       output.writeVInt(length);			  // write delta length
       output.writeChars(term.text, start, length);  // write delta chars
  @@ -148,11 +148,11 @@
     }
   
     /** Called to complete TermInfos creation. */
  -  final void close() throws IOException, SecurityException {
  +  final void close() throws IOException {
       output.seek(0);				  // write size at start
       output.writeInt(size);
       output.close();
  -    
  +
       if (!isIndex)
         other.close();
     }
  
  
  
  1.2       +2 -2      jakarta-lucene/src/java/org/apache/lucene/queryParser/FastCharStream.java
  
  Index: FastCharStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/FastCharStream.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FastCharStream.java	1 Nov 2001 01:12:37 -0000	1.1
  +++ FastCharStream.java	7 Nov 2002 05:55:40 -0000	1.2
  @@ -66,7 +66,7 @@
   
     int bufferLength = 0;				  // end of valid chars
     int bufferPosition = 0;			  // next char to read
  -  
  +
     int tokenStart = 0;				  // offset in buffer
     int bufferStart = 0;				  // position in file of buffer
   
  @@ -88,7 +88,7 @@
   
       if (tokenStart == 0) {			  // token won't fit in buffer
         if (buffer == null) {			  // first time: alloc buffer
  -	buffer = new char[2048];		  
  +	buffer = new char[2048];
         } else if (bufferLength == buffer.length) { // grow buffer
   	char[] newBuffer = new char[buffer.length*2];
   	System.arraycopy(buffer, 0, newBuffer, 0, bufferLength);
  
  
  
  1.22      +9 -0      jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj
  
  Index: QueryParser.jj
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/queryParser/QueryParser.jj,v
  retrieving revision 1.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- QueryParser.jj	18 Jul 2002 14:18:42 -0000	1.21
  +++ QueryParser.jj	7 Nov 2002 05:55:40 -0000	1.22
  @@ -328,6 +328,15 @@
     <<_WHITESPACE>>
   }
   
  +// OG: to support prefix queries:
  +// http://nagoya.apache.org/bugzilla/show_bug.cgi?id=12137
  +// Change from:
  +// | <WILDTERM:  <_TERM_START_CHAR>
  +//              (<_TERM_CHAR> | ( [ "*", "?" ] ))* >
  +// To:
  +//
  +// | <WILDTERM:  (<_TERM_CHAR> | ( [ "*", "?" ] ))* >
  +
   <DEFAULT> TOKEN : {
     <AND:       ("AND" | "&&") >
   | <OR:        ("OR" | "||") >
  
  
  
  1.3       +2 -2      jakarta-lucene/src/java/org/apache/lucene/search/Filter.java
  
  Index: Filter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Filter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Filter.java	17 Jul 2002 21:54:38 -0000	1.2
  +++ Filter.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -60,8 +60,8 @@
   
   /** Abstract base class providing a mechanism to restrict searches to a subset
    of an index. */
  -abstract public class Filter implements java.io.Serializable {
  +public abstract class Filter implements java.io.Serializable {
     /** Returns a BitSet with true for documents which should be permitted in
       search results, and false for those that should not. */
  -  abstract public BitSet bits(IndexReader reader) throws IOException;
  +  public abstract BitSet bits(IndexReader reader) throws IOException;
   }
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/search/FilteredTermEnum.java
  
  Index: FilteredTermEnum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/FilteredTermEnum.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FilteredTermEnum.java	18 Sep 2001 16:29:56 -0000	1.1
  +++ FilteredTermEnum.java	7 Nov 2002 05:55:40 -0000	1.2
  @@ -82,7 +82,7 @@
           this.actualEnum = actualEnum;
           // Find the first term that matches
           Term term = actualEnum.term();
  -        if (termCompare(term)) 
  +        if (term != null && termCompare(term)) 
               currentTerm = term;
           else next();
       }
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/search/FuzzyQuery.java
  
  Index: FuzzyQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/FuzzyQuery.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FuzzyQuery.java	18 Sep 2001 16:29:56 -0000	1.1
  +++ FuzzyQuery.java	7 Nov 2002 05:55:40 -0000	1.2
  @@ -59,7 +59,7 @@
   import java.io.IOException;
   
   /** Implements the fuzzy search query */
  -final public class FuzzyQuery extends MultiTermQuery {
  +public final class FuzzyQuery extends MultiTermQuery {
       private Term fuzzyTerm;
       
       public FuzzyQuery(Term term) {
  
  
  
  1.2       +5 -5      jakarta-lucene/src/java/org/apache/lucene/search/FuzzyTermEnum.java
  
  Index: FuzzyTermEnum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/FuzzyTermEnum.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- FuzzyTermEnum.java	18 Sep 2001 16:29:56 -0000	1.1
  +++ FuzzyTermEnum.java	7 Nov 2002 05:55:40 -0000	1.2
  @@ -63,7 +63,7 @@
   
     <p>Term enumerations are always ordered by Term.compareTo().  Each term in
     the enumeration is greater than all that precede it.  */
  -final public class FuzzyTermEnum extends FilteredTermEnum {
  +public final class FuzzyTermEnum extends FilteredTermEnum {
       double distance;
       boolean fieldMatch = false;
       boolean endEnum = false;
  @@ -86,7 +86,7 @@
        The termCompare method in FuzzyTermEnum uses Levenshtein distance to 
        calculate the distance between the given term and the comparing term. 
        */
  -    final protected boolean termCompare(Term term) {
  +    protected final boolean termCompare(Term term) {
           if (field == term.field()) {
               String target = term.text();
               int targetlen = target.length();
  @@ -98,11 +98,11 @@
           return false;
       }
       
  -    final protected float difference() {
  +    protected final float difference() {
           return (float)((distance - FUZZY_THRESHOLD) * SCALE_FACTOR);
       }
       
  -    final public boolean endEnum() {
  +    public final boolean endEnum() {
           return endEnum;
       }
       
  @@ -116,7 +116,7 @@
       /**
        Finds and returns the smallest of three integers 
        */
  -    private final static int min(int a, int b, int c) {
  +    private static final int min(int a, int b, int c) {
           int t = (a < b) ? a : b;
           return (t < c) ? t : c;
       }
  
  
  
  1.5       +1 -1      jakarta-lucene/src/java/org/apache/lucene/search/MultiTermQuery.java
  
  Index: MultiTermQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/MultiTermQuery.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MultiTermQuery.java	21 Feb 2002 20:22:45 -0000	1.4
  +++ MultiTermQuery.java	7 Nov 2002 05:55:40 -0000	1.5
  @@ -109,7 +109,7 @@
           return getQuery().scorer(reader);
       }
       
  -    final private BooleanQuery getQuery() throws IOException {
  +    private final BooleanQuery getQuery() throws IOException {
           if (query == null) {
               BooleanQuery q = new BooleanQuery();
               try {
  
  
  
  1.3       +1 -1      jakarta-lucene/src/java/org/apache/lucene/search/PhraseScorer.java
  
  Index: PhraseScorer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/PhraseScorer.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PhraseScorer.java	29 Jul 2002 19:11:15 -0000	1.2
  +++ PhraseScorer.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -100,7 +100,7 @@
       }
     }
   
  -  abstract protected float phraseFreq() throws IOException;
  +  protected abstract float phraseFreq() throws IOException;
   
     protected final void pqToList() {
       last = first = null;
  
  
  
  1.7       +2 -2      jakarta-lucene/src/java/org/apache/lucene/search/Query.java
  
  Index: Query.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Query.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Query.java	2 Jul 2002 15:16:55 -0000	1.6
  +++ Query.java	7 Nov 2002 05:55:40 -0000	1.7
  @@ -76,7 +76,7 @@
       <li>{@link org.apache.lucene.queryParser.QueryParser QueryParser}
       </ul>
   */
  -abstract public class Query implements java.io.Serializable
  +public abstract class Query implements java.io.Serializable
   {
       // query boost factor
       protected float boost = 1.0f;
  @@ -122,5 +122,5 @@
        * (although, if the query was created by the parser, the printed
        * representation may not be exactly what was parsed).
        */
  -    abstract public String toString(String field);
  +    public abstract String toString(String field);
   }
  
  
  
  1.6       +11 -0     jakarta-lucene/src/java/org/apache/lucene/search/Searcher.java
  
  Index: Searcher.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Searcher.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Searcher.java	17 Jul 2002 22:11:33 -0000	1.5
  +++ Searcher.java	7 Nov 2002 05:55:40 -0000	1.6
  @@ -64,6 +64,8 @@
    */
   public abstract class Searcher implements Searchable {
   
  +  protected Similarity similarity;
  +
     /** Returns the documents matching <code>query</code>. */
     public final Hits search(Query query) throws IOException {
       return search(query, (Filter)null);
  @@ -88,4 +90,13 @@
       throws IOException {
       search(query, (Filter)null, results);
     }    
  +
  +  /**
  +   * Sets the <code>Similarity</code> implementation to use.
  +   *
  +   * @param sim an instance of a class that implements  <code>Similarity</code
  +   */
  +  public void setSimilarity(Similarity sim) {
  +    similarity = sim;
  +  }
   }
  
  
  
  1.3       +15 -3     jakarta-lucene/src/java/org/apache/lucene/search/Similarity.java
  
  Index: Similarity.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/Similarity.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- Similarity.java	29 Jul 2002 19:11:15 -0000	1.2
  +++ Similarity.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -61,14 +61,26 @@
   /** Internal class used for scoring.
    * <p>Public only so that the indexing code can compute and store the
    * normalization byte for each document. */
  -public final class Similarity {
  -  private Similarity() {}			  // no public constructor
  +public abstract class Similarity {
   
  -  static final float[] NORM_TABLE = new float[256];
  +  private static final float[] NORM_TABLE = new float[256];
   
     static {
       for (int i = 0; i < 256; i++)
         NORM_TABLE[i] = byteToFloat((byte)i);
  +  }
  +
  +  private static Similarity similarity;
  +
  +  private Similarity() {}			  // no public constructor
  +
  +  /**
  +   * Sets the <code>Similarity</code> implementation to use.
  +   *
  +   * @param sim an instance of a class that implements  <code>Similarity</code
  +   */
  +  public static void setDefaultSimilarity(Similarity sim) {
  +    similarity = sim;
     }
   
     /** Computes the normalization value for a document given the total number of
  
  
  
  1.3       +3 -3      jakarta-lucene/src/java/org/apache/lucene/search/WildcardTermEnum.java
  
  Index: WildcardTermEnum.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/WildcardTermEnum.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- WildcardTermEnum.java	10 Apr 2002 04:05:38 -0000	1.2
  +++ WildcardTermEnum.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -94,7 +94,7 @@
         setEnum(reader.terms(new Term(searchTerm.field(), pre)));
     }
   
  -  final protected boolean termCompare(Term term) {
  +  protected final boolean termCompare(Term term) {
         if (field == term.field()) {
             String searchText = term.text();
             if (searchText.startsWith(pre)) {
  @@ -105,11 +105,11 @@
         return false;
     }
   
  -  final public float difference() {
  +  public final float difference() {
       return 1.0f;
     }
   
  -  final public boolean endEnum() {
  +  public final boolean endEnum() {
       return endEnum;
     }
   
  
  
  
  1.5       +24 -24    jakarta-lucene/src/java/org/apache/lucene/store/Directory.java
  
  Index: Directory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Directory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Directory.java	8 Aug 2002 17:56:19 -0000	1.4
  +++ Directory.java	7 Nov 2002 05:55:40 -0000	1.5
  @@ -61,7 +61,7 @@
    * deleted.  Random access is permitted both when reading and writing.
    *
    * <p> Java's i/o APIs not used directly, but rather all i/o is
  - * through this API.  This permits things such as: <ul> 
  + * through this API.  This permits things such as: <ul>
    * <li> implementation of RAM-based indices;
    * <li> implementation indices stored in a database, via JDBC;
    * <li> implementation of an index as a single file;
  @@ -69,52 +69,52 @@
    *
    * @author Doug Cutting
    */
  -abstract public class Directory {
  +public abstract class Directory {
     /** Returns an array of strings, one for each file in the directory. */
  -  abstract public String[] list()
  -       throws IOException, SecurityException;
  -       
  +  public abstract String[] list()
  +       throws IOException;
  +
     /** Returns true iff a file with the given name exists. */
  -  abstract public boolean fileExists(String name)
  -       throws IOException, SecurityException;
  +  public abstract boolean fileExists(String name)
  +       throws IOException;
   
     /** Returns the time the named file was last modified. */
  -  abstract public long fileModified(String name)
  -       throws IOException, SecurityException;
  +  public abstract long fileModified(String name)
  +       throws IOException;
   
     /** Set the modified time of an existing file to now. */
  -  abstract public void touchFile(String name)
  -       throws IOException, SecurityException;
  +  public abstract void touchFile(String name)
  +       throws IOException;
   
     /** Removes an existing file in the directory. */
  -  abstract public void deleteFile(String name)
  -       throws IOException, SecurityException;
  +  public abstract void deleteFile(String name)
  +       throws IOException;
   
     /** Renames an existing file in the directory.
       If a file already exists with the new name, then it is replaced.
       This replacement should be atomic. */
  -  abstract public void renameFile(String from, String to)
  -       throws IOException, SecurityException;
  +  public abstract void renameFile(String from, String to)
  +       throws IOException;
   
     /** Returns the length of a file in the directory. */
  -  abstract public long fileLength(String name)
  -       throws IOException, SecurityException;
  +  public abstract long fileLength(String name)
  +       throws IOException;
   
     /** Creates a new, empty file in the directory with the given name.
         Returns a stream writing this file. */
  -  abstract public OutputStream createFile(String name)
  -       throws IOException, SecurityException;
  +  public abstract OutputStream createFile(String name)
  +       throws IOException;
   
     /** Returns a stream reading an existing file. */
  -  abstract public InputStream openFile(String name)
  -       throws IOException, SecurityException;
  +  public abstract InputStream openFile(String name)
  +       throws IOException;
   
     /** Construct a {@link Lock}.
      * @param name the name of the lock file
      */
  -  abstract public Lock makeLock(String name);
  +  public abstract Lock makeLock(String name);
   
     /** Closes the store. */
  -  abstract public void close()
  -       throws IOException, SecurityException;
  +  public abstract void close()
  +       throws IOException;
   }
  
  
  
  1.12      +2 -2      jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java
  
  Index: FSDirectory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/FSDirectory.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FSDirectory.java	8 Aug 2002 17:56:19 -0000	1.11
  +++ FSDirectory.java	7 Nov 2002 05:55:40 -0000	1.12
  @@ -71,7 +71,7 @@
    * @author Doug Cutting
    */
   
  -final public class FSDirectory extends Directory {
  +public final class FSDirectory extends Directory {
     /** This cache of directories ensures that there is a unique Directory
      * instance per path, so that synchronization on the Directory can be used to
      * synchronize access between readers and writers.
  @@ -176,7 +176,7 @@
     }
   
     /** Set the modified time of an existing file to now. */
  -  public void touchFile(String name) throws IOException, SecurityException {
  +  public void touchFile(String name) throws IOException {
       File file = new File(directory, name);
       file.setLastModified(System.currentTimeMillis());
     }
  
  
  
  1.3       +6 -6      jakarta-lucene/src/java/org/apache/lucene/store/InputStream.java
  
  Index: InputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/InputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- InputStream.java	31 Jul 2002 17:47:14 -0000	1.2
  +++ InputStream.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -61,8 +61,8 @@
    * @see Directory
    * @see OutputStream
    */
  -abstract public class InputStream implements Cloneable {
  -  final static int BUFFER_SIZE = OutputStream.BUFFER_SIZE;
  +public abstract class InputStream implements Cloneable {
  +  static final int BUFFER_SIZE = OutputStream.BUFFER_SIZE;
   
     private byte[] buffer;
     private char[] chars;
  @@ -174,7 +174,7 @@
         else if ((b & 0xE0) != 0xE0) {
   	buffer[i] = (char)(((b & 0x1F) << 6)
   		 | (readByte() & 0x3F));
  -      } else 
  +      } else
   	buffer[i] = (char)(((b & 0x0F) << 12)
   		| ((readByte() & 0x3F) << 6)
   	        |  (readByte() & 0x3F));
  @@ -205,11 +205,11 @@
      * @param offset the offset in the array to start storing bytes
      * @param length the number of bytes to read
      */
  -  abstract protected void readInternal(byte[] b, int offset, int length)
  +  protected abstract void readInternal(byte[] b, int offset, int length)
          throws IOException;
   
     /** Closes the stream to futher operations. */
  -  abstract public void close() throws IOException;
  +  public abstract void close() throws IOException;
   
     /** Returns the current position in this file, where the next read will
      * occur.
  @@ -237,7 +237,7 @@
      * next {@link #readInternal(byte[],int,int)} will occur.
      * @see #readInternal(byte[],int,int)
      */
  -  abstract protected void seekInternal(long pos) throws IOException;
  +  protected abstract void seekInternal(long pos) throws IOException;
   
     /** The number of bytes in the file. */
     public final long length() {
  
  
  
  1.3       +5 -5      jakarta-lucene/src/java/org/apache/lucene/store/OutputStream.java
  
  Index: OutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/OutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- OutputStream.java	31 Jul 2002 17:47:14 -0000	1.2
  +++ OutputStream.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -60,9 +60,9 @@
    * stream.  Used for all Lucene index output operations.
    * @see Directory
    * @see InputStream
  - */ 
  -abstract public class OutputStream {
  -  final static int BUFFER_SIZE = 1024;
  + */
  +public abstract class OutputStream {
  +  static final int BUFFER_SIZE = 1024;
   
     private final byte[] buffer = new byte[BUFFER_SIZE];
     private long bufferStart = 0;			  // position in file of buffer
  @@ -176,7 +176,7 @@
      * @param b the bytes to write
      * @param len the number of bytes to write
      */
  -  abstract protected void flushBuffer(byte[] b, int len) throws IOException;
  +  protected abstract void flushBuffer(byte[] b, int len) throws IOException;
   
     /** Closes this stream to further operations. */
     public void close() throws IOException {
  @@ -200,7 +200,7 @@
     }
   
     /** The number of bytes in the file. */
  -  abstract public long length() throws IOException;
  +  public abstract long length() throws IOException;
   
   
   }
  
  
  
  1.6       +31 -3     jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java
  
  Index: RAMDirectory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RAMDirectory.java	8 Aug 2002 17:56:19 -0000	1.5
  +++ RAMDirectory.java	7 Nov 2002 05:55:40 -0000	1.6
  @@ -64,13 +64,41 @@
   import org.apache.lucene.store.OutputStream;
   
   /** A memory-resident {@link Directory} implementation. */
  -final public class RAMDirectory extends Directory {
  +public final class RAMDirectory extends Directory {
     Hashtable files = new Hashtable();
   
     /** Constructs an empty {@link Directory}. */
     public RAMDirectory() {
     }
   
  +  /**
  +   * Creates a new <code>RAMDirectory</code> instance from a different
  +   * <code>Directory</code> implementation.  This can be used to load
  +   * a disk-based index into memory.
  +   * <P>
  +   * This should be used only with indices that can fit into memory.
  +   *
  +   * @param d a <code>Directory</code> value
  +   * @exception IOException if an error occurs
  +   */
  +  public RAMDirectory(Directory d) throws IOException {
  +    final String[] ar = d.list();
  +    for (int i = 0; i < ar.length; i++) {
  +      // make place on ram disk
  +      OutputStream os = createFile(ar[i]);
  +      // read current file
  +      InputStream is = d.openFile(ar[i]);
  +      // and copy to ram disk
  +      int len = (int) is.length();
  +      byte[] buf = new byte[len];
  +      is.readBytes(buf, 0, len);
  +      os.writeBytes(buf, len);
  +      // graceful cleanup
  +      is.close();
  +      os.close();
  +    }
  +  }
  +
     /** Returns an array of strings, one for each file in the directory. */
     public final String[] list() {
       String[] result = new String[files.size()];
  @@ -80,7 +108,7 @@
         result[i++] = (String)names.nextElement();
       return result;
     }
  -       
  +
     /** Returns true iff the named file exists in this directory. */
     public final boolean fileExists(String name) {
       RAMFile file = (RAMFile)files.get(name);
  @@ -94,7 +122,7 @@
     }
   
     /** Set the modified time of an existing file to now. */
  -  public void touchFile(String name) throws IOException, SecurityException {
  +  public void touchFile(String name) throws IOException {
       RAMFile file = (RAMFile)files.get(name);
       file.lastModified = System.currentTimeMillis();
     }
  
  
  
  1.3       +1 -1      jakarta-lucene/src/java/org/apache/lucene/util/PriorityQueue.java
  
  Index: PriorityQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/util/PriorityQueue.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- PriorityQueue.java	5 Jun 2002 01:46:39 -0000	1.2
  +++ PriorityQueue.java	7 Nov 2002 05:55:40 -0000	1.3
  @@ -63,7 +63,7 @@
   
     /** Determines the ordering of objects in this priority queue.  Subclasses
       must define this one method. */
  -  abstract protected boolean lessThan(Object a, Object b);
  +  protected abstract boolean lessThan(Object a, Object b);
   
     /** Subclass constructors must call this. */
     protected final void initialize(int maxSize) {
  
  
  

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


Mime
View raw message