lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ehatc...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/index TermInfosTest.java
Date Tue, 12 Aug 2003 09:17:53 GMT
ehatcher    2003/08/12 02:17:53

  Modified:    src/java/org/apache/lucene/index SegmentReader.java
                        TermInfosReader.java
               src/java/org/apache/lucene/search DateFilter.java
                        MultiTermQuery.java PrefixQuery.java
                        RangeQuery.java
               src/test/org/apache/lucene/index TermInfosTest.java
  Log:
  #22344 - changed enum to enumerator
  
  Revision  Changes    Path
  1.9       +5 -5      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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- SegmentReader.java	1 May 2003 01:09:15 -0000	1.8
  +++ SegmentReader.java	12 Aug 2003 09:17:53 -0000	1.9
  @@ -235,7 +235,7 @@
       }
       return fieldSet;
     }
  -    
  +
     /**
      * @see IndexReader#getFieldNames(boolean)
      */
  @@ -285,7 +285,7 @@
     private final void openNorms() throws IOException {
       for (int i = 0; i < fieldInfos.size(); i++) {
         FieldInfo fi = fieldInfos.fieldInfo(i);
  -      if (fi.isIndexed) 
  +      if (fi.isIndexed)
   	norms.put(fi.name,
   		  new Norm(directory.openFile(segment + ".f" + fi.number)));
       }
  @@ -293,9 +293,9 @@
   
     private final void closeNorms() throws IOException {
       synchronized (norms) {
  -      Enumeration enum  = norms.elements();
  -      while (enum.hasMoreElements()) {
  -	Norm norm = (Norm)enum.nextElement();
  +      Enumeration enumerator  = norms.elements();
  +      while (enumerator.hasMoreElements()) {
  +	Norm norm = (Norm)enumerator.nextElement();
   	norm.in.close();
         }
       }
  
  
  
  1.3       +29 -29    jakarta-lucene/src/java/org/apache/lucene/index/TermInfosReader.java
  
  Index: TermInfosReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermInfosReader.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TermInfosReader.java	29 Jan 2003 17:18:54 -0000	1.2
  +++ TermInfosReader.java	12 Aug 2003 09:17:53 -0000	1.3
  @@ -67,7 +67,7 @@
     private String segment;
     private FieldInfos fieldInfos;
   
  -  private SegmentTermEnum enum;
  +  private SegmentTermEnum enumerator;
     private int size;
   
     TermInfosReader(Directory dir, String seg, FieldInfos fis)
  @@ -76,15 +76,15 @@
       segment = seg;
       fieldInfos = fis;
   
  -    enum = new SegmentTermEnum(directory.openFile(segment + ".tis"),
  +    enumerator = new SegmentTermEnum(directory.openFile(segment + ".tis"),
   			       fieldInfos, false);
  -    size = enum.size;
  +    size = enumerator.size;
       readIndex();
     }
   
     final void close() throws IOException {
  -    if (enum != null)
  -      enum.close();
  +    if (enumerator != null)
  +      enumerator.close();
     }
   
     /** Returns the number of term/value pairs in the set. */
  @@ -136,7 +136,7 @@
     }
   
     private final void seekEnum(int indexOffset) throws IOException {
  -    enum.seek(indexPointers[indexOffset],
  +    enumerator.seek(indexPointers[indexOffset],
   	      (indexOffset * TermInfosWriter.INDEX_INTERVAL) - 1,
   	      indexTerms[indexOffset], indexInfos[indexOffset]);
     }
  @@ -144,27 +144,27 @@
     /** Returns the TermInfo for a Term in the set, or null. */
     final synchronized TermInfo get(Term term) throws IOException {
       if (size == 0) return null;
  -    
  -    // optimize sequential access: first try scanning cached enum w/o seeking
  -    if (enum.term() != null			  // term is at or past current
  -	&& ((enum.prev != null && term.compareTo(enum.prev) > 0)
  -	    || term.compareTo(enum.term()) >= 0)) { 
  -      int enumOffset = (enum.position/TermInfosWriter.INDEX_INTERVAL)+1;
  +
  +    // optimize sequential access: first try scanning cached enumerator w/o seeking
  +    if (enumerator.term() != null			  // term is at or past current
  +	&& ((enumerator.prev != null && term.compareTo(enumerator.prev) > 0)
  +	    || term.compareTo(enumerator.term()) >= 0)) {
  +      int enumOffset = (enumerator.position/TermInfosWriter.INDEX_INTERVAL)+1;
         if (indexTerms.length == enumOffset	  // but before end of block
   	  || term.compareTo(indexTerms[enumOffset]) < 0)
   	return scanEnum(term);			  // no need to seek
       }
  -    
  +
       // random-access: must seek
       seekEnum(getIndexOffset(term));
       return scanEnum(term);
     }
  -  
  +
     /** Scans within block for matching term. */
     private final TermInfo scanEnum(Term term) throws IOException {
  -    while (term.compareTo(enum.term()) > 0 && enum.next()) {}
  -    if (enum.term() != null && term.compareTo(enum.term()) == 0)
  -      return enum.termInfo();
  +    while (term.compareTo(enumerator.term()) > 0 && enumerator.next()) {}
  +    if (enumerator.term() != null && term.compareTo(enumerator.term()) == 0)
  +      return enumerator.termInfo();
       else
         return null;
     }
  @@ -173,8 +173,8 @@
     final synchronized Term get(int position) throws IOException {
       if (size == 0) return null;
   
  -    if (enum != null && enum.term() != null && position >= enum.position
&&
  -	position < (enum.position + TermInfosWriter.INDEX_INTERVAL))
  +    if (enumerator != null && enumerator.term() != null && position >=
enumerator.position &&
  +	position < (enumerator.position + TermInfosWriter.INDEX_INTERVAL))
         return scanEnum(position);		  // can avoid seek
   
       seekEnum(position / TermInfosWriter.INDEX_INTERVAL); // must seek
  @@ -182,11 +182,11 @@
     }
   
     private final Term scanEnum(int position) throws IOException {
  -    while(enum.position < position)
  -      if (!enum.next())
  +    while(enumerator.position < position)
  +      if (!enumerator.next())
   	return null;
   
  -    return enum.term();
  +    return enumerator.term();
     }
   
     /** Returns the position of a Term in the set or -1. */
  @@ -196,25 +196,25 @@
       int indexOffset = getIndexOffset(term);
       seekEnum(indexOffset);
   
  -    while(term.compareTo(enum.term()) > 0 && enum.next()) {}
  +    while(term.compareTo(enumerator.term()) > 0 && enumerator.next()) {}
   
  -    if (term.compareTo(enum.term()) == 0)
  -      return enum.position;
  +    if (term.compareTo(enumerator.term()) == 0)
  +      return enumerator.position;
       else
         return -1;
     }
   
     /** Returns an enumeration of all the Terms and TermInfos in the set. */
     final synchronized SegmentTermEnum terms() throws IOException {
  -    if (enum.position != -1)			  // if not at start
  +    if (enumerator.position != -1)			  // if not at start
         seekEnum(0);				  // reset to start
  -    return (SegmentTermEnum)enum.clone();
  +    return (SegmentTermEnum)enumerator.clone();
     }
   
     /** Returns an enumeration of terms starting at or after the named term. */
     final synchronized SegmentTermEnum terms(Term term) throws IOException {
  -    get(term);					  // seek enum to term
  -    return (SegmentTermEnum)enum.clone();
  +    get(term);					  // seek enumerator to term
  +    return (SegmentTermEnum)enumerator.clone();
     }
   
   
  
  
  
  1.6       +6 -6      jakarta-lucene/src/java/org/apache/lucene/search/DateFilter.java
  
  Index: DateFilter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/DateFilter.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- DateFilter.java	17 Jul 2002 17:38:04 -0000	1.5
  +++ DateFilter.java	12 Aug 2003 09:17:53 -0000	1.6
  @@ -128,27 +128,27 @@
       search results, and false for those that should not. */
     public BitSet bits(IndexReader reader) throws IOException {
       BitSet bits = new BitSet(reader.maxDoc());
  -    TermEnum enum = reader.terms(new Term(field, start));
  +    TermEnum enumerator = reader.terms(new Term(field, start));
       TermDocs termDocs = reader.termDocs();
  -    if (enum.term() == null)
  +    if (enumerator.term() == null)
   	return bits;
   
       try {
         Term stop = new Term(field, end);
  -      while (enum.term().compareTo(stop) <= 0) {
  -	termDocs.seek(enum.term());
  +      while (enumerator.term().compareTo(stop) <= 0) {
  +	termDocs.seek(enumerator.term());
   	try {
   	  while (termDocs.next())
   	    bits.set(termDocs.doc());
   	} finally {
   	  termDocs.close();
   	}
  -	if (!enum.next()) {
  +	if (!enumerator.next()) {
   	  break;
   	}
         }
       } finally {
  -      enum.close();
  +      enumerator.close();
       }
       return bits;
     }
  
  
  
  1.10      +9 -9      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.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- MultiTermQuery.java	29 Jan 2003 17:18:54 -0000	1.9
  +++ MultiTermQuery.java	12 Aug 2003 09:17:53 -0000	1.10
  @@ -74,37 +74,37 @@
    */
   public abstract class MultiTermQuery extends Query {
       private Term term;
  -    
  +
       /** Constructs a query for terms matching <code>term</code>. */
       public MultiTermQuery(Term term) {
           this.term = term;
       }
  -    
  +
       /** Returns the pattern term. */
       public Term getTerm() { return term; }
   
       /** Construct the enumeration to be used, expanding the pattern term. */
       protected abstract FilteredTermEnum getEnum(IndexReader reader)
         throws IOException;
  -    
  +
       public Query rewrite(IndexReader reader) throws IOException {
  -      FilteredTermEnum enum = getEnum(reader);
  +      FilteredTermEnum enumerator = getEnum(reader);
         BooleanQuery query = new BooleanQuery();
         try {
           do {
  -          Term t = enum.term();
  +          Term t = enumerator.term();
             if (t != null) {
               TermQuery tq = new TermQuery(t);      // found a match
  -            tq.setBoost(getBoost() * enum.difference()); // set the boost
  +            tq.setBoost(getBoost() * enumerator.difference()); // set the boost
               query.add(tq, false, false);          // add to query
             }
  -        } while (enum.next());
  +        } while (enumerator.next());
         } finally {
  -        enum.close();
  +        enumerator.close();
         }
         return query;
       }
  -    
  +
       public Query combine(Query[] queries) {
         return Query.mergeBooleanQueries(queries);
       }
  
  
  
  1.7       +4 -4      jakarta-lucene/src/java/org/apache/lucene/search/PrefixQuery.java
  
  Index: PrefixQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/PrefixQuery.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- PrefixQuery.java	29 Jan 2003 17:18:55 -0000	1.6
  +++ PrefixQuery.java	12 Aug 2003 09:17:53 -0000	1.7
  @@ -71,12 +71,12 @@
   
     public Query rewrite(IndexReader reader) throws IOException {
       BooleanQuery query = new BooleanQuery();
  -    TermEnum enum = reader.terms(prefix);
  +    TermEnum enumerator = reader.terms(prefix);
       try {
         String prefixText = prefix.text();
         String prefixField = prefix.field();
         do {
  -        Term term = enum.term();
  +        Term term = enumerator.term();
           if (term != null &&
               term.text().startsWith(prefixText) &&
               term.field() == prefixField) {
  @@ -87,9 +87,9 @@
           } else {
             break;
           }
  -      } while (enum.next());
  +      } while (enumerator.next());
       } finally {
  -      enum.close();
  +      enumerator.close();
       }
       return query;
     }
  
  
  
  1.9       +10 -10    jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java
  
  Index: RangeQuery.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/search/RangeQuery.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RangeQuery.java	29 Apr 2003 01:34:00 -0000	1.8
  +++ RangeQuery.java	12 Aug 2003 09:17:53 -0000	1.9
  @@ -66,11 +66,11 @@
       private Term lowerTerm;
       private Term upperTerm;
       private boolean inclusive;
  -    
  -    /** Constructs a query selecting all terms greater than 
  +
  +    /** Constructs a query selecting all terms greater than
        * <code>lowerTerm</code> but less than <code>upperTerm</code>.
        * There must be at least one term and either term may be null--
  -     * in which case there is no bound on that side, but if there are 
  +     * in which case there is no bound on that side, but if there are
        * two term, both terms <b>must</b> be for the same field.
        */
       public RangeQuery(Term lowerTerm, Term upperTerm, boolean inclusive)
  @@ -92,7 +92,7 @@
         BooleanQuery query = new BooleanQuery();
         // if we have a lowerTerm, start there. otherwise, start at beginning
         if (lowerTerm == null) lowerTerm = new Term(getField(), "");
  -      TermEnum enum = reader.terms(lowerTerm);
  +      TermEnum enumerator = reader.terms(lowerTerm);
         try {
           String lowerText = null;
           String field;
  @@ -110,7 +110,7 @@
             }
             String testField = getField();
             do {
  -            Term term = enum.term();
  +            Term term = enumerator.term();
               if (term != null && term.field() == testField) {
                 if (!checkLower || term.text().compareTo(lowerText) > 0) {
                   checkLower = false;
  @@ -124,18 +124,18 @@
                   tq.setBoost(getBoost());          // set the boost
                   query.add(tq, false, false); // add to query
                 }
  -            } 
  +            }
               else {
                 break;
               }
             }
  -          while (enum.next());
  +          while (enumerator.next());
         } finally {
  -        enum.close();
  +        enumerator.close();
         }
         return query;
       }
  -    
  +
       public Query combine(Query[] queries) {
         return Query.mergeBooleanQueries(queries);
       }
  @@ -144,7 +144,7 @@
       {
           return (lowerTerm != null ? lowerTerm.field() : upperTerm.field());
       }
  -    
  +
       /** Prints a user-readable version of this query. */
       public String toString(String field)
       {
  
  
  
  1.4       +5 -5      jakarta-lucene/src/test/org/apache/lucene/index/TermInfosTest.java
  
  Index: TermInfosTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TermInfosTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- TermInfosTest.java	29 Jan 2003 17:43:13 -0000	1.3
  +++ TermInfosTest.java	12 Aug 2003 09:17:53 -0000	1.4
  @@ -152,15 +152,15 @@
   
       start = new Date();
   
  -    SegmentTermEnum enum = (SegmentTermEnum)reader.terms();
  +    SegmentTermEnum enumerator = reader.terms();
       for (int i = 0; i < keys.size(); i++) {
  -      enum.next();
  +      enumerator.next();
         Term key = (Term)keys.elementAt(i);
  -      if (!key.equals(enum.term()))
  -	throw new Exception("wrong term: " + enum.term()
  +      if (!key.equals(enumerator.term()))
  +	throw new Exception("wrong term: " + enumerator.term()
   			    + ", expected: " + key
   			    + " at " + i);
  -      TermInfo ti = enum.termInfo();
  +      TermInfo ti = enumerator.termInfo();
         if (ti.docFreq != docFreqs[i])
   	throw
   	  new Exception("wrong value: " + Long.toString(ti.docFreq, 16)
  
  
  

Mime
View raw message