lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mikemcc...@apache.org
Subject svn commit: r793037 - in /lucene/java/branches/lucene_2_4_back_compat_tests/src: java/org/apache/lucene/index/SegmentReader.java test/org/apache/lucene/index/TestDocumentWriter.java test/org/apache/lucene/index/TestLazyProxSkipping.java
Date Fri, 10 Jul 2009 17:01:11 GMT
Author: mikemccand
Date: Fri Jul 10 17:01:11 2009
New Revision: 793037

URL: http://svn.apache.org/viewvc?rev=793037&view=rev
Log:
LUCENE-1726: move unchanged readers to private CoreReaders class that's shared across cloned
SegmentReaders

Modified:
    lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/SegmentReader.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestDocumentWriter.java
    lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestLazyProxSkipping.java

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/SegmentReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/SegmentReader.java?rev=793037&r1=793036&r2=793037&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/SegmentReader.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/java/org/apache/lucene/index/SegmentReader.java
Fri Jul 10 17:01:11 2009
@@ -78,7 +78,27 @@
   // indicates the SegmentReader with which the resources are being shared,
   // in case this is a re-opened reader
   private SegmentReader referencedSegmentReader = null;
-  
+
+  // stub
+  static final class CoreReaders {
+    // Counts how many other reader share the core objects
+    // (freqStream, proxStream, tis, etc.) of this reader;
+    // when coreRef drops to 0, these core objects may be
+    // closed.  A given insance of SegmentReader may be
+    // closed, even those it shares core objects with other
+    // SegmentReaders:
+    FieldsReader fieldsReaderOrig;
+    TermVectorsReader termVectorsReaderOrig;
+    CompoundFileReader cfsReader;
+    CompoundFileReader storeCFSReader;
+    TermInfosReader tis;
+    IndexInput freqStream;
+    IndexInput proxStream;
+    FieldInfos fieldInfos;
+  }
+
+  CoreReaders core;
+
   private class Norm {
     volatile int refCount;
     boolean useSingleNormStream;

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestDocumentWriter.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestDocumentWriter.java?rev=793037&r1=793036&r2=793037&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestDocumentWriter.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestDocumentWriter.java
Fri Jul 10 17:01:11 2009
@@ -94,8 +94,8 @@
 
     // test that the norms are not present in the segment if
     // omitNorms is true
-    for (int i = 0; i < reader.fieldInfos.size(); i++) {
-      FieldInfo fi = reader.fieldInfos.fieldInfo(i);
+    for (int i = 0; i < reader.core.fieldInfos.size(); i++) {
+      FieldInfo fi = reader.core.fieldInfos.fieldInfo(i);
       if (fi.isIndexed) {
         assertTrue(fi.omitNorms == !reader.hasNorms(fi.name));
       }

Modified: lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestLazyProxSkipping.java?rev=793037&r1=793036&r2=793037&view=diff
==============================================================================
--- lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
(original)
+++ lucene/java/branches/lucene_2_4_back_compat_tests/src/test/org/apache/lucene/index/TestLazyProxSkipping.java
Fri Jul 10 17:01:11 2009
@@ -44,11 +44,22 @@
     private String term2 = "yy";
     private String term3 = "zz";
     
+    private class SeekCountingDirectory extends RAMDirectory {
+      public IndexInput openInput(String name) throws IOException {
+        IndexInput ii = super.openInput(name);
+        if (name.endsWith(".prx")) {
+          // we decorate the proxStream with a wrapper class that allows to count the number
of calls of seek()
+          ii = new SeeksCountingStream(ii);
+        }
+        return ii;
+      }
+    }
     private void createIndex(int numHits) throws IOException {
         int numDocs = 500;
         
-        Directory directory = new RAMDirectory();
+        Directory directory = new SeekCountingDirectory();
         IndexWriter writer = new IndexWriter(directory, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.LIMITED);
+        writer.setUseCompoundFile(false);
         writer.setMaxBufferedDocs(10);
         for (int i = 0; i < numDocs; i++) {
             Document doc = new Document();
@@ -74,9 +85,6 @@
         
         SegmentReader reader = SegmentReader.getOnlySegmentReader(directory);
 
-        // we decorate the proxStream with a wrapper class that allows to count the number
of calls of seek()
-        reader.proxStream = new SeeksCountingStream(reader.proxStream);
-        
         this.searcher = new IndexSearcher(reader);        
     }
     
@@ -96,6 +104,7 @@
         assertEquals(numHits, hits.length);
         
         // check if the number of calls of seek() does not exceed the number of hits
+        assertTrue(this.seeksCounter > 0);
         assertTrue(this.seeksCounter <= numHits + 1);
     }
     



Mime
View raw message