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 SegmentReader.java
Date Mon, 13 Oct 2003 14:25:55 GMT
otis        2003/10/13 07:25:55

  Modified:    src/java/org/apache/lucene/index SegmentReader.java
  Log:
  - Changed code to use IndexWriter.WRITE_LOCK_NAME.
  - Cleaned up indentation a bit.
  
  Revision  Changes    Path
  1.12      +28 -22    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.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- SegmentReader.java	25 Sep 2003 22:01:51 -0000	1.11
  +++ SegmentReader.java	13 Oct 2003 14:25:54 -0000	1.12
  @@ -68,6 +68,11 @@
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.util.BitVector;
   
  +/**
  + * FIXME: Describe class <code>SegmentReader</code> here.
  + *
  + * @version $Id$
  + */
   final class SegmentReader extends IndexReader {
     private boolean closeDirectory = false;
     private String segment;
  @@ -82,7 +87,7 @@
   
     InputStream freqStream;
     InputStream proxStream;
  -  
  +
     // Compound File Reader when based on a compound file segment
     CompoundFileReader cfsReader;
   
  @@ -94,21 +99,21 @@
     private Hashtable norms = new Hashtable();
   
     SegmentReader(SegmentInfo si, boolean closeDir)
  -       throws IOException {
  +    throws IOException {
       this(si);
       closeDirectory = closeDir;
     }
   
     SegmentReader(SegmentInfo si)
  -       throws IOException {
  +    throws IOException {
       super(si.dir);
       segment = si.name;
   
       // Use compound file directory for some files, if it exists
       Directory cfsDir = directory;
       if (directory.fileExists(segment + ".cfs")) {
  -        cfsReader = new CompoundFileReader(directory, segment + ".cfs");
  -        cfsDir = cfsReader;
  +      cfsReader = new CompoundFileReader(directory, segment + ".cfs");
  +      cfsDir = cfsReader;
       }
   
       // No compound file exists - use the multi-file format
  @@ -128,18 +133,19 @@
       openNorms(cfsDir);
     }
   
  -  
  +
     final synchronized void doClose() throws IOException {
       if (deletedDocsDirty) {
         synchronized (directory) {		  // in- & inter-process sync
  -        new Lock.With(directory.makeLock("commit.lock"), IndexWriter.COMMIT_LOCK_TIMEOUT)
{
  -            public Object doBody() throws IOException {
  -              deletedDocs.write(directory, segment + ".tmp");
  -              directory.renameFile(segment + ".tmp", segment + ".del");
  -              directory.touchFile("segments");
  -              return null;
  -            }
  -          }.run();
  +        new Lock.With(directory.makeLock("IndexWriter.COMMIT_LOCK_NAME"),
  +          IndexWriter.COMMIT_LOCK_TIMEOUT) {
  +          public Object doBody() throws IOException {
  +            deletedDocs.write(directory, segment + ".tmp");
  +            directory.renameFile(segment + ".tmp", segment + ".del");
  +            directory.touchFile("segments");
  +            return null;
  +          }
  +        }.run();
         }
         deletedDocsDirty = false;
       }
  @@ -153,7 +159,7 @@
         proxStream.close();
   
       closeNorms();
  -    
  +
       if (cfsReader != null)
         cfsReader.close();
   
  @@ -168,7 +174,7 @@
     static final boolean usesCompoundFile(SegmentInfo si) throws IOException {
       return si.dir.fileExists(si.name + ".cfs");
     }
  -  
  +
     final synchronized void doDelete(int docNum) throws IOException {
       if (deletedDocs == null)
         deletedDocs = new BitVector(maxDoc());
  @@ -179,15 +185,15 @@
     final Vector files() throws IOException {
       Vector files = new Vector(16);
       final String ext[] = new String[] {
  -        "cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del"
  +      "cfs", "fnm", "fdx", "fdt", "tii", "tis", "frq", "prx", "del"
       };
  -    
  +
       for (int i=0; i<ext.length; i++) {
  -        String name = segment + "." + ext[i];
  -        if (directory.fileExists(name)) 
  -            files.addElement(name);
  +      String name = segment + "." + ext[i];
  +      if (directory.fileExists(name))
  +        files.addElement(name);
       }
  -    
  +
       for (int i = 0; i < fieldInfos.size(); i++) {
         FieldInfo fi = fieldInfos.fieldInfo(i);
         if (fi.isIndexed)
  
  
  

---------------------------------------------------------------------
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