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/index IndexReader.java SegmentReader.java SegmentsReader.java
Date Thu, 01 May 2003 01:09:15 GMT
otis        2003/04/30 18:09:15

  Modified:    .        CHANGES.txt
               src/java/org/apache/lucene/index IndexReader.java
                        SegmentReader.java SegmentsReader.java
  Log:
  - Added method getFieldNames(boolean).
  Submitted by:	Julien Nioche
  Reviewed by:	Otis
  
  Revision  Changes    Path
  1.47      +3 -2      jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.46
  retrieving revision 1.47
  diff -u -r1.46 -r1.47
  --- CHANGES.txt	20 Mar 2003 18:38:59 -0000	1.46
  +++ CHANGES.txt	1 May 2003 01:09:15 -0000	1.47
  @@ -4,7 +4,8 @@
   
   1.3 RC2
   
  - 1. 
  + 1. Added getFieldNames(boolean) to IndexReader, SegmentReader, and
  +    SegmentsReader. (Julien Nioche via otis)  
   
   
   1.3 RC1
  
  
  
  1.15      +35 -19    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.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- IndexReader.java	20 Mar 2003 18:28:13 -0000	1.14
  +++ IndexReader.java	1 May 2003 01:09:15 -0000	1.15
  @@ -3,8 +3,8 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  + * Copyright (c) 2001, 2002, 2003 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
  @@ -75,8 +75,8 @@
     <i>document numbers</i>, non-negative integers which each name a unique
     document in the index.  These document numbers are ephemeral--they may change
     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. */
  -
  +  rely on a given document having the same number between sessions.
  +*/
   public abstract class IndexReader {
     protected IndexReader(Directory directory) {
       this.directory = directory;
  @@ -209,7 +209,8 @@
       Term &nbsp;&nbsp; =&gt; &nbsp;&nbsp; &lt;docNum, freq&gt;<sup>*</sup>
       </ul>
       <p>The enumeration is ordered by document number.  Each document number
  -    is greater than all that precede it in the enumeration. */
  +    is greater than all that precede it in the enumeration.
  +  */
     public TermDocs termDocs(Term term) throws IOException {
       TermDocs termDocs = termDocs();
       termDocs.seek(term);
  @@ -233,7 +234,8 @@
       </ul>
       <p> This positional information faciliates phrase and proximity searching.
       <p>The enumeration is ordered by document number.  Each document number is
  -    greater than all that precede it in the enumeration. */
  +    greater than all that precede it in the enumeration.
  +  */
     public TermPositions termPositions(Term term) throws IOException {
       TermPositions termPositions = termPositions();
       termPositions.seek(term);
  @@ -248,7 +250,8 @@
       Attempts to read its field with the {@link #document}
       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.  */
  +    this will be corrected eventually as the index is further modified.
  +  */
     public final synchronized void delete(int docNum) throws IOException {
       if (writeLock == null) {
         Lock writeLock = directory.makeLock("write.lock");
  @@ -258,13 +261,15 @@
       }
       doDelete(docNum);
     }
  +
     abstract void doDelete(int docNum) throws IOException;
   
     /** Deletes all documents containing <code>term</code>.
       This is useful if one uses a document field to hold a unique ID string for
       the document.  Then to delete such a document, one merely constructs a
       term with the appropriate field and the unique ID string as its text and
  -    passes it to this method.  Returns the number of documents deleted. */
  +    passes it to this method.  Returns the number of documents deleted.
  +  */
     public final int delete(Term term) throws IOException {
       TermDocs docs = termDocs(term);
       if ( docs == null ) return 0;
  @@ -304,13 +309,24 @@
       }
     }
   
  -    /**
  -     * Return a list of all unique field names which exist in the index pointed to by
  -     * this IndexReader.
  -     * @return Collection of Strings indicating the names of the fields
  -     * @throws IOException if there is a problem with accessing the index
  -     */
  -    public abstract Collection getFieldNames() throws IOException;
  +  /**
  +   * Returns a list of all unique field names that exist in the index pointed to by
  +   * this IndexReader.
  +   * @return Collection of Strings indicating the names of the fields
  +   * @throws IOException if there is a problem with accessing the index
  +   */
  +  public abstract Collection getFieldNames() throws IOException;
  +
  +  /**
  +   * Returns a list of all unique field names that exist in the index pointed to by
  +   * this IndexReader.  The boolean argument specifies whether the fields returned
  +   * are indexed or not.
  +   * @param indexed <code>true</code> if only indexed fields should be returned;
  +   *                <code>false</code> if only unindexed fields should be returned.
  +   * @return Collection of Strings indicating the names of the fields
  +   * @throws IOException if there is a problem with accessing the index
  +   */
  +   public abstract Collection getFieldNames(boolean indexed) throws IOException;
   
     /**
      * Returns <code>true</code> iff the index in the named directory is
  @@ -319,7 +335,7 @@
      * @throws IOException if there is a problem with accessing the index
      */
       public static boolean isLocked(Directory directory) throws IOException {
  -	return directory.fileExists("write.lock");
  +      return directory.fileExists("write.lock");
       }
   
     /**
  @@ -329,7 +345,7 @@
      * @throws IOException if there is a problem with accessing the index
      */
       public static boolean isLocked(String directory) throws IOException {
  -	return (new File(directory, "write.lock")).exists();
  +      return (new File(directory, "write.lock")).exists();
       }
   
      /**
  @@ -340,7 +356,7 @@
       * currently accessing this index.
       */
       public static void unlock(Directory directory) throws IOException {
  -	directory.deleteFile("write.lock");
  -	directory.deleteFile("commit.lock");
  +      directory.deleteFile("write.lock");
  +      directory.deleteFile("commit.lock");
       }
   }
  
  
  
  1.8       +27 -11    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.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- SegmentReader.java	4 Jan 2003 17:13:39 -0000	1.7
  +++ SegmentReader.java	1 May 2003 01:09:15 -0000	1.8
  @@ -223,6 +223,33 @@
       return fieldsReader.size();
     }
   
  +  /**
  +   * @see IndexReader#getFieldNames()
  +   */
  +  public Collection getFieldNames() throws IOException {
  +    // maintain a unique set of field names
  +    Set fieldSet = new HashSet();
  +    for (int i = 0; i < fieldInfos.size(); i++) {
  +      FieldInfo fi = fieldInfos.fieldInfo(i);
  +      fieldSet.add(fi.name);
  +    }
  +    return fieldSet;
  +  }
  +    
  +  /**
  +   * @see IndexReader#getFieldNames(boolean)
  +   */
  +  public Collection getFieldNames(boolean indexed) throws IOException {
  +    // maintain a unique set of field names
  +    Set fieldSet = new HashSet();
  +    for (int i = 0; i < fieldInfos.size(); i++) {
  +      FieldInfo fi = fieldInfos.fieldInfo(i);
  +      if (fi.isIndexed == indexed)
  +        fieldSet.add(fi.name);
  +      }
  +      return fieldSet;
  +    }
  +
     public final byte[] norms(String field) throws IOException {
       Norm norm = (Norm)norms.get(field);
       if (norm == null)
  @@ -273,15 +300,4 @@
         }
       }
     }
  -
  -    // javadoc inherited
  -    public Collection getFieldNames() throws IOException {
  -        // maintain a unique set of field names
  -        Set fieldSet = new HashSet();
  -        for (int i = 0; i < fieldInfos.size(); i++) {
  -            FieldInfo fi = fieldInfos.fieldInfo(i);
  -            fieldSet.add(fi.name);
  -        }
  -        return fieldSet;
  -    }
   }
  
  
  
  1.11      +32 -16    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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- SegmentsReader.java	4 Jan 2003 17:13:39 -0000	1.10
  +++ SegmentsReader.java	1 May 2003 01:09:15 -0000	1.11
  @@ -3,8 +3,8 @@
   /* ====================================================================
    * The Apache Software License, Version 1.1
    *
  - * Copyright (c) 2001 The Apache Software Foundation.  All rights
  - * reserved.
  + * Copyright (c) 2001, 2002, 2003 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
  @@ -179,21 +179,37 @@
         readers[i].close();
     }
   
  -    // javadoc inherited
  -    public Collection getFieldNames() throws IOException {
  -        // maintain a unique set of field names
  -        Set fieldSet = new HashSet();
  -        for (int i = 0; i < readers.length; i++) {
  -            SegmentReader reader = readers[i];
  -            Collection names = reader.getFieldNames();
  -            // iterate through the field names and add them to the set
  -            for (Iterator iterator = names.iterator(); iterator.hasNext();) {
  -                String s = (String) iterator.next();
  -                fieldSet.add(s);
  -            }
  +  /**
  +   * @see IndexReader#getFieldNames()
  +   */
  +  public Collection getFieldNames() throws IOException {
  +    // maintain a unique set of field names
  +    Set fieldSet = new HashSet();
  +    for (int i = 0; i < readers.length; i++) {
  +        SegmentReader reader = readers[i];
  +        Collection names = reader.getFieldNames();
  +        // iterate through the field names and add them to the set
  +        for (Iterator iterator = names.iterator(); iterator.hasNext();) {
  +            String s = (String) iterator.next();
  +            fieldSet.add(s);
           }
  -        return fieldSet;
       }
  +    return fieldSet;
  +  }
  +
  +  /**
  +   * @see IndexReader#getFieldNames(boolean)
  +   */
  +  public Collection getFieldNames(boolean indexed) throws IOException {
  +    // maintain a unique set of field names
  +    Set fieldSet = new HashSet();
  +    for (int i = 0; i < readers.length; i++) {
  +        SegmentReader reader = readers[i];
  +        Collection names = reader.getFieldNames(indexed);
  +        fieldSet.addAll(names);
  +    }
  +    return fieldSet;
  +  }
   }
   
   class SegmentsTermEnum extends TermEnum {
  
  
  

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


Mime
View raw message