Update of /cvsroot/nutch/nutch/src/java/net/nutch/searcher
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12441

Modified Files:
        FetchedSegments.java 
Log Message:
Open segment files lazily, so that if they're not used they're not required.


Index: FetchedSegments.java
===================================================================
RCS file: /cvsroot/nutch/nutch/src/java/net/nutch/searcher/FetchedSegments.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** FetchedSegments.java        7 Oct 2004 04:24:53 -0000       1.9
--- FetchedSegments.java        1 Nov 2004 20:21:59 -0000       1.10
***************
*** 23,26 ****
--- 23,29 ----
  
    private static class Segment {
+     private NutchFileSystem nfs;
+     private File segmentDir;
+ 
      private ArrayFile.Reader fetcher;
      private ArrayFile.Reader content;
***************
*** 29,43 ****
  
      public Segment(NutchFileSystem nfs, File segmentDir) throws IOException {
!       this.fetcher = new ArrayFile.Reader
!         (nfs, new File(segmentDir, FetcherOutput.DIR_NAME).toString());
!       this.content = new ArrayFile.Reader
!         (nfs, new File(segmentDir, Content.DIR_NAME).toString());
!       this.text = new ArrayFile.Reader
!         (nfs, new File(segmentDir, ParseText.DIR_NAME).toString());
!       this.parsedata = new ArrayFile.Reader
!         (nfs, new File(segmentDir, ParseData.DIR_NAME).toString());
      }
  
      public FetcherOutput getFetcherOutput(int docNo) throws IOException {
        FetcherOutput entry = new FetcherOutput();
        fetcher.get(docNo, entry);
--- 32,45 ----
  
      public Segment(NutchFileSystem nfs, File segmentDir) throws IOException {
!       this.nfs = nfs;
!       this.segmentDir = segmentDir;
      }
  
      public FetcherOutput getFetcherOutput(int docNo) throws IOException {
+       if (fetcher == null) { 
+         this.fetcher = new ArrayFile.Reader
+           (nfs, new File(segmentDir, FetcherOutput.DIR_NAME).toString());
+       }
+ 
        FetcherOutput entry = new FetcherOutput();
        fetcher.get(docNo, entry);
***************
*** 46,49 ****
--- 48,56 ----
  
      public byte[] getContent(int docNo) throws IOException {
+       if (content == null) {
+         this.content = new ArrayFile.Reader
+           (nfs, new File(segmentDir, Content.DIR_NAME).toString());
+       }
+ 
        Content entry = new Content();
        content.get(docNo, entry);
***************
*** 52,66 ****
  
      public ParseData getParseData(int docNo) throws IOException {
!         ParseData entry = new ParseData();
!         parsedata.get(docNo, entry);
!         return entry;
        }
  
      public ParseText getParseText(int docNo) throws IOException {
!         ParseText entry = new ParseText();
!         text.get(docNo, entry);
!         return entry;
        }
  
    }
  
--- 59,83 ----
  
      public ParseData getParseData(int docNo) throws IOException {
!       if (parsedata == null) {
!         this.parsedata = new ArrayFile.Reader
!           (nfs, new File(segmentDir, ParseData.DIR_NAME).toString());
        }
+       
+       ParseData entry = new ParseData();
+       parsedata.get(docNo, entry);
+       return entry;
+     }
  
      public ParseText getParseText(int docNo) throws IOException {
!       if (text == null) {
!         this.text = new ArrayFile.Reader
!           (nfs, new File(segmentDir, ParseText.DIR_NAME).toString());
        }
  
+       ParseText entry = new ParseText();
+       text.get(docNo, entry);
+       return entry;
+     }
+     
    }
  
***************
*** 99,102 ****
--- 116,124 ----
    }
  
+   public long getFetchDate(HitDetails details) throws IOException {
+     return getSegment(details).getFetcherOutput(getDocNo(details))
+       .getFetchDate();
+   }
+ 
    public ParseText getParseText(HitDetails details) throws IOException {
      return getSegment(details).getParseText(getDocNo(details));



-------------------------------------------------------
This SF.Net email is sponsored by:
Sybase ASE Linux Express Edition - download now for FREE
LinuxWorld Reader's Choice Award Winner for best database on Linux.
http://ads.osdn.com/?ad_id=5588&alloc_id=12065&op=click
_______________________________________________
Nutch-cvs mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nutch-cvs

Reply via email to