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/store RAMDirectory.java
Date Tue, 14 Jan 2003 03:41:05 GMT
otis        2003/01/13 19:41:05

  Modified:    .        CHANGES.txt
               src/java/org/apache/lucene/store RAMDirectory.java
  Log:
  Added convenience RAMDirectory constructors taking File and String
  arguments, for easy FSDirectory to RAMDirectory conversion.
  
  Revision  Changes    Path
  1.40      +7 -3      jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- CHANGES.txt	13 Jan 2003 23:50:33 -0000	1.39
  +++ CHANGES.txt	14 Jan 2003 03:41:05 -0000	1.40
  @@ -95,13 +95,14 @@
   
    18. Added a public, extensible scoring API.  For details, see the
        javadoc for org.apache.lucene.search.Similarity.
  - 
  +
    19. Fixed return of Hits.id() from float to int. (Terry Steichen via Peter).
   
    20. Added getFieldNames() to IndexReader and Segment(s)Reader classes.
        (Peter Mularien via otis)
   
    21. Added getFields(String) and getValues(String) methods.
  +     Contributed by Rasik Pandey on 2002-10-09
        (Rasik Pandey via otis)
   
    22. Revised internal search APIs.  Changes include:
  @@ -142,9 +143,12 @@
   
        Caution: These are extensive changes and they have not yet been
        tested extensively.  Bug reports are appreciated.
  +     (cutting)
  +
  + 23. Added convenience RAMDirectory constructors taking File and String
  +     arguments, for easy FSDirectory to RAMDirectory conversion.
   
   
  -  Contributed by Rasik Pandey on 2002-10-09
   1.2 RC6
   
    1. Changed QueryParser.jj to have "?" be a special character which
  
  
  
  1.7       +28 -5     jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java
  
  Index: RAMDirectory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/RAMDirectory.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RAMDirectory.java	7 Nov 2002 05:55:40 -0000	1.6
  +++ RAMDirectory.java	14 Jan 2003 03:41:05 -0000	1.7
  @@ -55,6 +55,7 @@
    */
   
   import java.io.IOException;
  +import java.io.File;
   import java.util.Vector;
   import java.util.Hashtable;
   import java.util.Enumeration;
  @@ -63,7 +64,11 @@
   import org.apache.lucene.store.InputStream;
   import org.apache.lucene.store.OutputStream;
   
  -/** A memory-resident {@link Directory} implementation. */
  +/**
  + * A memory-resident {@link Directory} implementation.
  + *
  + * @version $Id$
  + */
   public final class RAMDirectory extends Directory {
     Hashtable files = new Hashtable();
   
  @@ -78,16 +83,16 @@
      * <P>
      * This should be used only with indices that can fit into memory.
      *
  -   * @param d a <code>Directory</code> value
  +   * @param dir a <code>Directory</code> value
      * @exception IOException if an error occurs
      */
  -  public RAMDirectory(Directory d) throws IOException {
  -    final String[] ar = d.list();
  +  public RAMDirectory(Directory dir) throws IOException {
  +    final String[] ar = dir.list();
       for (int i = 0; i < ar.length; i++) {
         // make place on ram disk
         OutputStream os = createFile(ar[i]);
         // read current file
  -      InputStream is = d.openFile(ar[i]);
  +      InputStream is = dir.openFile(ar[i]);
         // and copy to ram disk
         int len = (int) is.length();
         byte[] buf = new byte[len];
  @@ -97,6 +102,24 @@
         is.close();
         os.close();
       }
  +  }
  +
  +  /**
  +   * Creates a new <code>RAMDirectory</code> instance from the {@link FSDirectory}.
  +   *
  +   * @param dir a <code>File</code> specifying the index directory
  +   */
  +  public RAMDirectory(File dir) throws IOException {
  +    this(FSDirectory.getDirectory(dir, false));
  +  }
  +
  +  /**
  +   * Creates a new <code>RAMDirectory</code> instance from the {@link FSDirectory}.
  +   *
  +   * @param dir a <code>String</code> specifying the full index directory path
  +   */
  +  public RAMDirectory(String dir) throws IOException {
  +    this(FSDirectory.getDirectory(dir, false));
     }
   
     /** Returns an array of strings, one for each file in the directory. */
  
  
  

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


Mime
View raw message