lucene-java-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r826255 - in /lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs: ./ intblock/ pulsing/ sep/
Date Sat, 17 Oct 2009 14:04:59 GMT
Author: markrmiller
Date: Sat Oct 17 14:04:58 2009
New Revision: 826255

URL: http://svn.apache.org/viewvc?rev=826255&view=rev
Log:
rough stab at cache support for sep codec

Modified:
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsProducer.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/IntIndexInput.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepPositionsReader.java
    lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsProducer.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsProducer.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsProducer.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/DocsProducer.java
Sat Oct 17 14:04:58 2009
@@ -48,7 +48,7 @@
     public abstract DocsEnum docs(Bits deletedDocs) throws IOException;
     
     // nocommit: fooling around with reusable
-    public abstract CacheEntry captureState(CacheEntry reusableState);
+    public abstract CacheEntry captureState(CacheEntry reusableState) throws IOException;
     
     public abstract void setState(CacheEntry state, int docFreq) throws IOException;
     

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/intblock/FixedIntBlockIndexInput.java
Sat Oct 17 14:04:58 2009
@@ -169,5 +169,28 @@
       fp = idx.fp;
       upto = idx.upto;
     }
+    
+    public class State extends IndexState {
+      long fp;
+      int upto;
+    }
+
+    // nocommit handle with set and/or clone?
+    @Override
+    public IndexState captureState() {
+      State state = new State();
+      state.fp = fp;
+      state.upto = upto;
+      return state;
+    }
+
+    // nocommit handle with set and/or clone?
+    @Override
+    public void setState(IndexState state) {
+      State iState = (State) state;
+      this.fp = iState.fp;
+      this.upto = iState.upto;
+      
+    }
   }
 }
\ No newline at end of file

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/pulsing/PulsingDocsReader.java
Sat Oct 17 14:04:58 2009
@@ -297,7 +297,7 @@
     }
 
     @Override
-    public CacheEntry captureState(CacheEntry reusableState) {
+    public CacheEntry captureState(CacheEntry reusableState) throws IOException {
       CacheEntry cacheEntry = wrappedReader.captureState(reusableState);
       cacheEntry.docs = new Document[docs.length];
       for(int i = 0; i < docs.length; i++) {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/IntIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/IntIndexInput.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/IntIndexInput.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/IntIndexInput.java
Sat Oct 17 14:04:58 2009
@@ -31,6 +31,8 @@
   public abstract void close() throws IOException;
 
   public abstract Index index() throws IOException;
+  
+  public class IndexState {};
 
   public abstract static class Index {
 
@@ -43,6 +45,12 @@
     public abstract void seek(IntIndexInput.Reader stream) throws IOException;
 
     public abstract void set(Index other);
+    
+    // nocommit handle with set and/or clone?
+    public abstract IndexState captureState();
+    
+    // nocommit handle with set and/or clone?
+    public abstract void setState(IndexState state);
   }
 
   public static final class BulkReadResult {

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepDocsReader.java
Sat Oct 17 14:04:58 2009
@@ -20,17 +20,20 @@
 import java.io.IOException;
 import java.util.Collection;
 
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.index.codecs.DocsProducer;
-import org.apache.lucene.util.Bits;
-import org.apache.lucene.index.SegmentInfo;
-import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.DocsEnum;
-import org.apache.lucene.index.PositionsEnum;
+import org.apache.lucene.index.FieldInfo;
 import org.apache.lucene.index.IndexFileNames;
+import org.apache.lucene.index.PositionsEnum;
+import org.apache.lucene.index.SegmentInfo;
 import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.index.codecs.DocsProducer;
+import org.apache.lucene.index.codecs.sep.IntIndexInput.IndexState;
 import org.apache.lucene.index.codecs.standard.StandardTermsDictReader.CacheEntry;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IndexInput;
+import org.apache.lucene.util.Bits;
+
+import sun.security.util.PendingException;
 
 /** Concrete class that reads the current doc/freq/skip
  *  postings format */
@@ -60,6 +63,7 @@
 
       // nocommit -- freqIn is null if omitTF?
       final String frqFileName = IndexFileNames.segmentFileName(segmentInfo.name, SepCodec.FREQ_EXTENSION);
+
       freqIn = intFactory.openInput(dir, frqFileName);
 
       final String docFileName = IndexFileNames.segmentFileName(segmentInfo.name, SepCodec.DOC_EXTENSION);
@@ -67,7 +71,7 @@
 
       skipIn = dir.openInput(IndexFileNames.segmentFileName(segmentInfo.name, SepCodec.SKIP_EXTENSION),
readBufferSize);
       if (segmentInfo.getHasProx()) {
-        final String posFileName = IndexFileNames.segmentFileName(segmentInfo.name, SepCodec.POS_EXTENSION);
+        //final String posFileName = IndexFileNames.segmentFileName(segmentInfo.name, SepCodec.POS_EXTENSION);
         posReader = new SepPositionsReader(dir, segmentInfo, readBufferSize, intFactory);
       } else {
         posReader = null;
@@ -87,6 +91,7 @@
     SepPositionsReader.files(segmentInfo, files);
   }
 
+  @Override
   public void start(IndexInput termsIn) throws IOException {
     this.termsIn = termsIn;
 
@@ -100,6 +105,7 @@
     }
   }
 
+  @Override
   public Reader reader(FieldInfo fieldInfo, IndexInput termsIn) throws IOException {
 
     final SepPositionsReader.TermsDictReader posReader2;
@@ -112,6 +118,7 @@
     return new TermsDictReader(fieldInfo, posReader2, termsIn);
   }
 
+  @Override
   public void close() throws IOException {
     try {
       if (freqIn != null)
@@ -167,7 +174,8 @@
         docFreq = 1;
       }
     }
-
+    
+    @Override
     public void readTerm(int docFreq, boolean isIndexTerm) throws IOException {
 
       this.docFreq = docFreq;
@@ -272,6 +280,7 @@
         }
       }
 
+      @Override
       public int next() throws IOException {
 
         if (Codec.DEBUG) {
@@ -419,6 +428,7 @@
         return positions;
       }
 
+      @Override
       public int advance(int target) throws IOException {
 
         // TODO: jump right to next() if target is < X away
@@ -518,16 +528,79 @@
         return doc;
       }
     }
+    
+    public class TermDictsReaderState extends CacheEntry {
+      IndexState freqIndexState;
+      long skipOffset;
+      IndexState posIndexState;
+      
+      long skipInPos;
+      IndexState docIndexState;
+      public long payloadOffset;
+      public long payloadPos;
+      public int posSkipCount;
 
+      
+    }
+
+    // nocommit: rought start
     @Override
-    public CacheEntry captureState(CacheEntry reusableState) {
-      // TODO Auto-generated method stub
-      return null;
+    public CacheEntry captureState(CacheEntry reusableState) throws IOException {
+      TermDictsReaderState state;
+      if (reusableState == null) {
+        state = new TermDictsReaderState();
+      } else {
+        state = (TermDictsReaderState) reusableState;
+      }
+      if (posReader != null) {
+        state.posIndexState = posReader.posIndex.captureState();
+        state.payloadOffset = posReader.payloadOffset;
+        if(posReader.positions != null) {
+          state.posSkipCount = posReader.positions.posSkipCount;
+        }
+      }
+      if(freqIndex != null) {
+        state.freqIndexState = freqIndex.captureState();
+      } else {
+        state.freqIndexState = null;
+      }
+      state.docIndexState = docIndex.captureState();
+      state.skipInPos = skipIn.getFilePointer();
+      state.skipOffset = skipOffset;
+      
+      return state;
     }
 
+    // nocommit: rought start
     @Override
     public void setState(CacheEntry state, int docFreq) throws IOException {
-      // TODO Auto-generated method stub
+      TermDictsReaderState readerState = (TermDictsReaderState) state;
+      skipOffset = readerState.skipOffset;
+
+      this.docFreq = docFreq;
+      
+      if (posReader != null) {
+        SepDocsReader.this.posReader.payloadIn.seek(readerState.payloadPos);
+        posReader.posIndex.setState(readerState.posIndexState);
+        posReader.payloadOffset = readerState.payloadOffset;
+        if (posReader.positions != null) {
+          //nocommit
+          posReader.positions.pendingPosIndex.setState(readerState.posIndexState);
+          //posReader.positions.payloadPending = true;
+          posReader.positions.seekPending = true;
+          posReader.positions.payloadOffset = posReader.payloadOffset;
+        }
+      }
+      if(readerState.freqIndexState != null) {
+        freqIndex.setState(readerState.freqIndexState);
+      }
+      docIndex.setState(readerState.docIndexState);
+      skipIn.seek(readerState.skipInPos);
+    }
+    
+    @Override
+    public boolean canCaptureState() {
+      return true;
     }
   }
 }
@@ -535,15 +608,19 @@
 /** Returned when someone asks for positions() enum on field
  *  with omitTf true */
 class FakePositionsEnum extends PositionsEnum {
+  @Override
   public int next() {
     return 0;
   }
+  @Override
   public int getPayloadLength() {
     return 0;
   }
+  @Override
   public boolean hasPayload() {
     return false;
   }
+  @Override
   public byte[] getPayload(byte[] data, int offset) {
     return null;
   }

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepPositionsReader.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepPositionsReader.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepPositionsReader.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SepPositionsReader.java
Sat Oct 17 14:04:58 2009
@@ -142,7 +142,7 @@
 
       final boolean storePayloads;
 
-      boolean payloadPending;                     // True if we must skip payload beore reading
next position
+      boolean payloadPending;                     // True if we must skip payload before
reading next position
 
       long payloadOffset;
 
@@ -150,7 +150,7 @@
       int payloadLength;
       int posSkipCount;
 
-      private boolean seekPending;
+      boolean seekPending;
 
       SegmentPositionsEnum(IntIndexInput.Index posIndex, long payloadOffset) throws IOException
{
         //posIn = SepPositionsReader.this.posIn.reader();

Modified: lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java
URL: http://svn.apache.org/viewvc/lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java?rev=826255&r1=826254&r2=826255&view=diff
==============================================================================
--- lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java
(original)
+++ lucene/java/branches/flex_1458/src/java/org/apache/lucene/index/codecs/sep/SingleIntIndexInput.java
Sat Oct 17 14:04:58 2009
@@ -17,11 +17,12 @@
  * limitations under the License.
  */
 
-import org.apache.lucene.store.IndexInput;
-import org.apache.lucene.store.Directory;
-import org.apache.lucene.index.codecs.Codec;
 import java.io.IOException;
 
+import org.apache.lucene.index.codecs.Codec;
+import org.apache.lucene.store.Directory;
+import org.apache.lucene.store.IndexInput;
+
 /** Reads IndexInputs written with {@link
  * SingleIntIndexoutput} */
 public class SingleIntIndexInput extends IntIndexInput {
@@ -71,8 +72,13 @@
       return Long.toString(in.getFilePointer());
     }
   }
-
-  private static class Index extends IntIndexInput.Index {
+  
+  class State extends IndexState {
+    long fp;
+    boolean first;
+  }
+  
+  class Index extends IntIndexInput.Index {
     private long fp;
     boolean first = true;
 
@@ -103,6 +109,25 @@
     public String toString() {
       return Long.toString(fp);
     }
+
+    // nocommit handle with set and/or clone?
+    @Override
+    public IndexState captureState() {
+      State state = SingleIntIndexInput.this.new State();
+      state.fp = fp;
+      state.first = first;
+      return state;
+    }
+
+    // nocommit handle with set and/or clone?
+    @Override
+    public void setState(IndexState state) {
+      State iState = (State) state;
+      this.fp = iState.fp;
+      this.first = iState.first;
+      
+    }
+    
   }
 
   public Index index() {



Mime
View raw message