lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject cvs commit: jakarta-lucene/src/test/org/apache/lucene/index TestCompoundFile.java TestDoc.java TestFieldInfos.java
Date Tue, 28 Sep 2004 18:15:52 GMT
cutting     2004/09/28 11:15:52

  Modified:    .        CHANGES.txt
               src/java/org/apache/lucene/index CompoundFileReader.java
                        CompoundFileWriter.java DocumentWriter.java
                        FieldInfos.java FieldsWriter.java IndexWriter.java
                        SegmentInfos.java SegmentMerger.java
                        SegmentReader.java TermInfosWriter.java
                        TermVectorsWriter.java
               src/java/org/apache/lucene/store BufferedIndexInput.java
                        Directory.java IndexInput.java OutputStream.java
                        RAMOutputStream.java
               src/java/org/apache/lucene/util BitVector.java
               src/test/org/apache/lucene StoreTest.java
               src/test/org/apache/lucene/index TestCompoundFile.java
                        TestDoc.java TestFieldInfos.java
  Added:       src/java/org/apache/lucene/store BufferedIndexOutput.java
                        IndexOutput.java
  Log:
  Replace OutputStream with IndexOutput and BufferedIndexOutput to permit unbuffered Directory
implementations.
  
  Revision  Changes    Path
  1.112     +4 -3      jakarta-lucene/CHANGES.txt
  
  Index: CHANGES.txt
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/CHANGES.txt,v
  retrieving revision 1.111
  retrieving revision 1.112
  diff -u -r1.111 -r1.112
  --- CHANGES.txt	20 Sep 2004 18:14:25 -0000	1.111
  +++ CHANGES.txt	28 Sep 2004 18:15:52 -0000	1.112
  @@ -58,8 +58,9 @@
          
   12. Permit unbuffered Directory implementations (e.g., using mmap).
       InputStream is replaced by the new classes IndexInput and
  -    BufferedIndexInput.  InputStream is now deprecated and FSDirectory
  -    is now subclassable. (cutting)
  +    BufferedIndexInput.  OutputStream is replaced by the new classes
  +    IndexOutput and BufferedIndexOutput.  InputStream and OutputStream
  +    are now deprecated and FSDirectory is now subclassable. (cutting)
   
   13. Fixed bug #31241: Sorting could lead to incorrect results (documents
       missing, others duplicated) if the sort keys were not unique and there
  
  
  
  1.14      +3 -3      jakarta-lucene/src/java/org/apache/lucene/index/CompoundFileReader.java
  
  Index: CompoundFileReader.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/CompoundFileReader.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- CompoundFileReader.java	16 Sep 2004 21:13:37 -0000	1.13
  +++ CompoundFileReader.java	28 Sep 2004 18:15:52 -0000	1.14
  @@ -19,7 +19,7 @@
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.store.IndexInput;
   import org.apache.lucene.store.BufferedIndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.Lock;
   import java.util.HashMap;
   import java.io.IOException;
  @@ -171,7 +171,7 @@
   
       /** Not implemented
        * @throws UnsupportedOperationException */
  -    public OutputStream createFile(String name)
  +    public IndexOutput createOutput(String name)
       {
           throw new UnsupportedOperationException();
       }
  
  
  
  1.8       +6 -6      jakarta-lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java
  
  Index: CompoundFileWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/CompoundFileWriter.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- CompoundFileWriter.java	16 Sep 2004 21:13:37 -0000	1.7
  +++ CompoundFileWriter.java	28 Sep 2004 18:15:52 -0000	1.8
  @@ -17,7 +17,7 @@
    */
   
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.IndexInput;
   import java.util.LinkedList;
   import java.util.HashSet;
  @@ -140,9 +140,9 @@
           merged = true;
   
           // open the compound stream
  -        OutputStream os = null;
  +        IndexOutput os = null;
           try {
  -            os = directory.createFile(fileName);
  +            os = directory.createOutput(fileName);
   
               // Write the number of entries
               os.writeVInt(entries.size());
  @@ -180,7 +180,7 @@
               // close so that if an exception occurs during the close, the
               // finally clause below will not attempt to close the stream
               // the second time.
  -            OutputStream tmp = os;
  +            IndexOutput tmp = os;
               os = null;
               tmp.close();
   
  @@ -193,7 +193,7 @@
        *  provided output stream. Use the provided buffer for moving data
        *  to reduce memory allocation.
        */
  -    private void copyFile(FileEntry source, OutputStream os, byte buffer[])
  +    private void copyFile(FileEntry source, IndexOutput os, byte buffer[])
       throws IOException
       {
           IndexInput is = null;
  
  
  
  1.13      +5 -5      jakarta-lucene/src/java/org/apache/lucene/index/DocumentWriter.java
  
  Index: DocumentWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/DocumentWriter.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- DocumentWriter.java	10 Jul 2004 06:19:01 -0000	1.12
  +++ DocumentWriter.java	28 Sep 2004 18:15:52 -0000	1.13
  @@ -29,7 +29,7 @@
   import org.apache.lucene.analysis.TokenStream;
   import org.apache.lucene.analysis.Token;
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.search.Similarity;
   
   final class DocumentWriter {
  @@ -247,13 +247,13 @@
   
     private final void writePostings(Posting[] postings, String segment)
             throws IOException {
  -    OutputStream freq = null, prox = null;
  +    IndexOutput freq = null, prox = null;
       TermInfosWriter tis = null;
       TermVectorsWriter termVectorWriter = null;
       try {
         //open files for inverse index storage
  -      freq = directory.createFile(segment + ".frq");
  -      prox = directory.createFile(segment + ".prx");
  +      freq = directory.createOutput(segment + ".frq");
  +      prox = directory.createOutput(segment + ".prx");
         tis = new TermInfosWriter(directory, segment, fieldInfos);
         TermInfo ti = new TermInfo();
         String currentField = null;
  @@ -321,7 +321,7 @@
         FieldInfo fi = fieldInfos.fieldInfo(n);
         if(fi.isIndexed){
           float norm = fieldBoosts[n] * similarity.lengthNorm(fi.name, fieldLengths[n]);
  -        OutputStream norms = directory.createFile(segment + ".f" + n);
  +        IndexOutput norms = directory.createOutput(segment + ".f" + n);
           try {
             norms.writeByte(Similarity.encodeNorm(norm));
           } finally {
  
  
  
  1.12      +3 -3      jakarta-lucene/src/java/org/apache/lucene/index/FieldInfos.java
  
  Index: FieldInfos.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/FieldInfos.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- FieldInfos.java	16 Sep 2004 21:13:37 -0000	1.11
  +++ FieldInfos.java	28 Sep 2004 18:15:52 -0000	1.12
  @@ -23,7 +23,7 @@
   import org.apache.lucene.document.Field;
   
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.IndexInput;
   
   /** Access to the Field Info file that describes document fields and whether or
  @@ -167,7 +167,7 @@
     }
   
     public void write(Directory d, String name) throws IOException {
  -    OutputStream output = d.createFile(name);
  +    IndexOutput output = d.createOutput(name);
       try {
         write(output);
       } finally {
  @@ -175,7 +175,7 @@
       }
     }
   
  -  public void write(OutputStream output) throws IOException {
  +  public void write(IndexOutput output) throws IOException {
       output.writeVInt(size());
       for (int i = 0; i < size(); i++) {
         FieldInfo fi = fieldInfo(i);
  
  
  
  1.5       +6 -6      jakarta-lucene/src/java/org/apache/lucene/index/FieldsWriter.java
  
  Index: FieldsWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/FieldsWriter.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- FieldsWriter.java	15 Sep 2004 12:50:22 -0000	1.4
  +++ FieldsWriter.java	28 Sep 2004 18:15:52 -0000	1.5
  @@ -22,20 +22,20 @@
   import org.apache.lucene.document.Document;
   import org.apache.lucene.document.Field;
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   
   final class FieldsWriter
   {
       private FieldInfos fieldInfos;
   
  -    private OutputStream fieldsStream;
  +    private IndexOutput fieldsStream;
   
  -    private OutputStream indexStream;
  +    private IndexOutput indexStream;
   
       FieldsWriter(Directory d, String segment, FieldInfos fn) throws IOException {
           fieldInfos = fn;
  -        fieldsStream = d.createFile(segment + ".fdt");
  -        indexStream = d.createFile(segment + ".fdx");
  +        fieldsStream = d.createOutput(segment + ".fdt");
  +        indexStream = d.createOutput(segment + ".fdx");
       }
   
       final void close() throws IOException {
  @@ -80,4 +80,4 @@
           }
       }
   
  -}
  \ No newline at end of file
  +}
  
  
  
  1.40      +2 -2      jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java
  
  Index: IndexWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/IndexWriter.java,v
  retrieving revision 1.39
  retrieving revision 1.40
  diff -u -r1.39 -r1.40
  --- IndexWriter.java	22 Sep 2004 18:32:26 -0000	1.39
  +++ IndexWriter.java	28 Sep 2004 18:15:52 -0000	1.40
  @@ -26,7 +26,7 @@
   import org.apache.lucene.store.FSDirectory;
   import org.apache.lucene.store.Lock;
   import org.apache.lucene.store.IndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.search.Similarity;
   import org.apache.lucene.document.Document;
   import org.apache.lucene.analysis.Analyzer;
  @@ -617,7 +617,7 @@
     }
   
     private final void writeDeleteableFiles(Vector files) throws IOException {
  -    OutputStream output = directory.createFile("deleteable.new");
  +    IndexOutput output = directory.createOutput("deleteable.new");
       try {
         output.writeInt(files.size());
         for (int i = 0; i < files.size(); i++)
  
  
  
  1.7       +2 -2      jakarta-lucene/src/java/org/apache/lucene/index/SegmentInfos.java
  
  Index: SegmentInfos.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentInfos.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- SegmentInfos.java	16 Sep 2004 21:13:37 -0000	1.6
  +++ SegmentInfos.java	28 Sep 2004 18:15:52 -0000	1.7
  @@ -20,7 +20,7 @@
   import java.io.IOException;
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.store.IndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   
   final class SegmentInfos extends Vector {
     
  @@ -70,7 +70,7 @@
     }
   
     public final void write(Directory directory) throws IOException {
  -    OutputStream output = directory.createFile("segments.new");
  +    IndexOutput output = directory.createOutput("segments.new");
       try {
         output.writeInt(FORMAT); // write FORMAT
         output.writeLong(++version); // every write changes the index
  
  
  
  1.15      +6 -6      jakarta-lucene/src/java/org/apache/lucene/index/SegmentMerger.java
  
  Index: SegmentMerger.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/SegmentMerger.java,v
  retrieving revision 1.14
  retrieving revision 1.15
  diff -u -r1.14 -r1.15
  --- SegmentMerger.java	15 Aug 2004 11:26:05 -0000	1.14
  +++ SegmentMerger.java	28 Sep 2004 18:15:52 -0000	1.15
  @@ -21,7 +21,7 @@
   import java.io.IOException;
   
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.RAMOutputStream;
   
   /**
  @@ -225,16 +225,16 @@
       }
     }
   
  -  private OutputStream freqOutput = null;
  -  private OutputStream proxOutput = null;
  +  private IndexOutput freqOutput = null;
  +  private IndexOutput proxOutput = null;
     private TermInfosWriter termInfosWriter = null;
     private int skipInterval;
     private SegmentMergeQueue queue = null;
   
     private final void mergeTerms() throws IOException {
       try {
  -      freqOutput = directory.createFile(segment + ".frq");
  -      proxOutput = directory.createFile(segment + ".prx");
  +      freqOutput = directory.createOutput(segment + ".frq");
  +      proxOutput = directory.createOutput(segment + ".prx");
         termInfosWriter =
                 new TermInfosWriter(directory, segment, fieldInfos);
         skipInterval = termInfosWriter.skipInterval;
  @@ -404,7 +404,7 @@
       for (int i = 0; i < fieldInfos.size(); i++) {
         FieldInfo fi = fieldInfos.fieldInfo(i);
         if (fi.isIndexed) {
  -        OutputStream output = directory.createFile(segment + ".f" + i);
  +        IndexOutput output = directory.createOutput(segment + ".f" + i);
           try {
             for (int j = 0; j < readers.size(); j++) {
               IndexReader reader = (IndexReader) readers.elementAt(j);
  
  
  
  1.29      +3 -3      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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- SegmentReader.java	22 Sep 2004 18:32:26 -0000	1.28
  +++ SegmentReader.java	28 Sep 2004 18:15:52 -0000	1.29
  @@ -26,7 +26,7 @@
   
   import org.apache.lucene.document.Document;
   import org.apache.lucene.store.IndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.util.BitVector;
   
  @@ -69,7 +69,7 @@
   
       private void reWrite() throws IOException {
         // NOTE: norms are re-written in regular directory, not cfs
  -      OutputStream out = directory().createFile(segment + ".tmp");
  +      IndexOutput out = directory().createOutput(segment + ".tmp");
         try {
           out.writeBytes(bytes, maxDoc());
         } finally {
  
  
  
  1.7       +3 -3      jakarta-lucene/src/java/org/apache/lucene/index/TermInfosWriter.java
  
  Index: TermInfosWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermInfosWriter.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TermInfosWriter.java	20 Apr 2004 13:47:58 -0000	1.6
  +++ TermInfosWriter.java	28 Sep 2004 18:15:52 -0000	1.7
  @@ -18,7 +18,7 @@
   
   
   import java.io.IOException;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.util.StringHelper;
   
  @@ -30,7 +30,7 @@
     public static final int FORMAT = -2;
   
     private FieldInfos fieldInfos;
  -  private OutputStream output;
  +  private IndexOutput output;
     private Term lastTerm = new Term("", "");
     private TermInfo lastTi = new TermInfo();
     private long size = 0;
  @@ -77,7 +77,7 @@
            boolean isi) throws IOException {
       fieldInfos = fis;
       isIndex = isi;
  -    output = directory.createFile(segment + (isIndex ? ".tii" : ".tis"));
  +    output = directory.createOutput(segment + (isIndex ? ".tii" : ".tis"));
       output.writeInt(FORMAT);                      // write format
       output.writeLong(0);                          // leave space for size
       output.writeInt(indexInterval);             // write indexInterval
  
  
  
  1.3       +6 -6      jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsWriter.java
  
  Index: TermVectorsWriter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/index/TermVectorsWriter.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TermVectorsWriter.java	17 Aug 2004 20:53:16 -0000	1.2
  +++ TermVectorsWriter.java	28 Sep 2004 18:15:52 -0000	1.3
  @@ -17,7 +17,7 @@
    */
   
   import org.apache.lucene.store.Directory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.util.StringHelper;
   
   import java.io.IOException;
  @@ -58,7 +58,7 @@
     public static final String TVX_EXTENSION = ".tvx";
     public static final String TVD_EXTENSION = ".tvd";
     public static final String TVF_EXTENSION = ".tvf";
  -  private OutputStream tvx = null, tvd = null, tvf = null;
  +  private IndexOutput tvx = null, tvd = null, tvf = null;
     private Vector fields = null;
     private Vector terms = null;
     private FieldInfos fieldInfos;
  @@ -77,11 +77,11 @@
                              FieldInfos fieldInfos)
       throws IOException {
       // Open files for TermVector storage
  -    tvx = directory.createFile(segment + TVX_EXTENSION);
  +    tvx = directory.createOutput(segment + TVX_EXTENSION);
       tvx.writeInt(FORMAT_VERSION);
  -    tvd = directory.createFile(segment + TVD_EXTENSION);
  +    tvd = directory.createOutput(segment + TVD_EXTENSION);
       tvd.writeInt(FORMAT_VERSION);
  -    tvf = directory.createFile(segment + TVF_EXTENSION);
  +    tvf = directory.createOutput(segment + TVF_EXTENSION);
       tvf.writeInt(FORMAT_VERSION);
   
       this.fieldInfos = fieldInfos;
  
  
  
  1.2       +1 -1      jakarta-lucene/src/java/org/apache/lucene/store/BufferedIndexInput.java
  
  Index: BufferedIndexInput.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/BufferedIndexInput.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- BufferedIndexInput.java	16 Sep 2004 21:13:37 -0000	1.1
  +++ BufferedIndexInput.java	28 Sep 2004 18:15:52 -0000	1.2
  @@ -20,7 +20,7 @@
   
   /** Base implementation class for buffered {@link IndexInput}. */
   public abstract class BufferedIndexInput extends IndexInput {
  -  static final int BUFFER_SIZE = OutputStream.BUFFER_SIZE;
  +  static final int BUFFER_SIZE = BufferedIndexOutput.BUFFER_SIZE;
   
     private byte[] buffer;
   
  
  
  
  1.9       +10 -2     jakarta-lucene/src/java/org/apache/lucene/store/Directory.java
  
  Index: Directory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/Directory.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- Directory.java	17 Sep 2004 19:15:28 -0000	1.8
  +++ Directory.java	28 Sep 2004 18:15:52 -0000	1.9
  @@ -62,10 +62,18 @@
     public abstract long fileLength(String name)
          throws IOException;
   
  +  /** @deprecated use {@link #createOutput(String)} */
  +  public OutputStream createFile(String name) throws IOException {
  +    return (OutputStream)createOutput(name);
  +  }
  +
     /** Creates a new, empty file in the directory with the given name.
         Returns a stream writing this file. */
  -  public abstract OutputStream createFile(String name)
  -       throws IOException;
  +  public IndexOutput createOutput(String name) throws IOException {
  +    // default implementation for back compatibility
  +    // this method should be abstract
  +    return (IndexOutput)createFile(name);
  +  }
   
     /** @deprecated use {@link #openInput(String)} */
     public InputStream openFile(String name) throws IOException {
  
  
  
  1.2       +7 -7      jakarta-lucene/src/java/org/apache/lucene/store/IndexInput.java
  
  Index: IndexInput.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/IndexInput.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IndexInput.java	16 Sep 2004 21:13:37 -0000	1.1
  +++ IndexInput.java	28 Sep 2004 18:15:52 -0000	1.2
  @@ -26,7 +26,7 @@
     private char[] chars;                           // used by readString()
   
     /** Reads and returns a single byte.
  -   * @see OutputStream#writeByte(byte)
  +   * @see IndexOutput#writeByte(byte)
      */
     public abstract byte readByte() throws IOException;
   
  @@ -34,13 +34,13 @@
      * @param b the array to read bytes into
      * @param offset the offset in the array to start storing bytes
      * @param len the number of bytes to read
  -   * @see OutputStream#writeBytes(byte[],int)
  +   * @see IndexOutput#writeBytes(byte[],int)
      */
     public abstract void readBytes(byte[] b, int offset, int len)
       throws IOException;
   
     /** Reads four bytes and returns an int.
  -   * @see OutputStream#writeInt(int)
  +   * @see IndexOutput#writeInt(int)
      */
     public int readInt() throws IOException {
       return ((readByte() & 0xFF) << 24) | ((readByte() & 0xFF) << 16)
  @@ -50,7 +50,7 @@
     /** Reads an int stored in variable-length format.  Reads between one and
      * five bytes.  Smaller values take fewer bytes.  Negative numbers are not
      * supported.
  -   * @see OutputStream#writeVInt(int)
  +   * @see IndexOutput#writeVInt(int)
      */
     public int readVInt() throws IOException {
       byte b = readByte();
  @@ -63,7 +63,7 @@
     }
   
     /** Reads eight bytes and returns a long.
  -   * @see OutputStream#writeLong(long)
  +   * @see IndexOutput#writeLong(long)
      */
     public long readLong() throws IOException {
       return (((long)readInt()) << 32) | (readInt() & 0xFFFFFFFFL);
  @@ -83,7 +83,7 @@
     }
   
     /** Reads a string.
  -   * @see OutputStream#writeString(String)
  +   * @see IndexOutput#writeString(String)
      */
     public String readString() throws IOException {
       int length = readVInt();
  @@ -97,7 +97,7 @@
      * @param buffer the array to read characters into
      * @param start the offset in the array to start storing characters
      * @param length the number of characters to read
  -   * @see OutputStream#writeChars(String,int,int)
  +   * @see IndexOutput#writeChars(String,int,int)
      */
     public void readChars(char[] buffer, int start, int length)
          throws IOException {
  
  
  
  1.6       +3 -147    jakarta-lucene/src/java/org/apache/lucene/store/OutputStream.java
  
  Index: OutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/OutputStream.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- OutputStream.java	7 Aug 2004 11:19:29 -0000	1.5
  +++ OutputStream.java	28 Sep 2004 18:15:52 -0000	1.6
  @@ -18,151 +18,7 @@
   
   import java.io.IOException;
   
  -/** Abstract class for output to a file in a Directory.  A random-access output
  - * stream.  Used for all Lucene index output operations.
  - * @see Directory
  - * @see InputStream
  - */
  -public abstract class OutputStream {
  -  static final int BUFFER_SIZE = 1024;
  -
  -  private final byte[] buffer = new byte[BUFFER_SIZE];
  -  private long bufferStart = 0;			  // position in file of buffer
  -  private int bufferPosition = 0;		  // position in buffer
  -
  -  /** Writes a single byte.
  -   * @see InputStream#readByte()
  -   */
  -  public final void writeByte(byte b) throws IOException {
  -    if (bufferPosition >= BUFFER_SIZE)
  -      flush();
  -    buffer[bufferPosition++] = b;
  -  }
  -
  -  /** Writes an array of bytes.
  -   * @param b the bytes to write
  -   * @param length the number of bytes to write
  -   * @see InputStream#readBytes(byte[],int,int)
  -   */
  -  public final void writeBytes(byte[] b, int length) throws IOException {
  -    for (int i = 0; i < length; i++)
  -      writeByte(b[i]);
  -  }
  -
  -  /** Writes an int as four bytes.
  -   * @see InputStream#readInt()
  -   */
  -  public final void writeInt(int i) throws IOException {
  -    writeByte((byte)(i >> 24));
  -    writeByte((byte)(i >> 16));
  -    writeByte((byte)(i >>  8));
  -    writeByte((byte) i);
  -  }
  -
  -  /** Writes an int in a variable-length format.  Writes between one and
  -   * five bytes.  Smaller values take fewer bytes.  Negative numbers are not
  -   * supported.
  -   * @see InputStream#readVInt()
  -   */
  -  public final void writeVInt(int i) throws IOException {
  -    while ((i & ~0x7F) != 0) {
  -      writeByte((byte)((i & 0x7f) | 0x80));
  -      i >>>= 7;
  -    }
  -    writeByte((byte)i);
  -  }
  -
  -  /** Writes a long as eight bytes.
  -   * @see InputStream#readLong()
  -   */
  -  public final void writeLong(long i) throws IOException {
  -    writeInt((int) (i >> 32));
  -    writeInt((int) i);
  -  }
  -
  -  /** Writes an long in a variable-length format.  Writes between one and five
  -   * bytes.  Smaller values take fewer bytes.  Negative numbers are not
  -   * supported.
  -   * @see InputStream#readVLong()
  -   */
  -  public final void writeVLong(long i) throws IOException {
  -    while ((i & ~0x7F) != 0) {
  -      writeByte((byte)((i & 0x7f) | 0x80));
  -      i >>>= 7;
  -    }
  -    writeByte((byte)i);
  -  }
  -
  -  /** Writes a string.
  -   * @see InputStream#readString()
  -   */
  -  public final void writeString(String s) throws IOException {
  -    int length = s.length();
  -    writeVInt(length);
  -    writeChars(s, 0, length);
  -  }
  -
  -  /** Writes a sequence of UTF-8 encoded characters from a string.
  -   * @param s the source of the characters
  -   * @param start the first character in the sequence
  -   * @param length the number of characters in the sequence
  -   * @see InputStream#readChars(char[],int,int)
  -   */
  -  public final void writeChars(String s, int start, int length)
  -       throws IOException {
  -    final int end = start + length;
  -    for (int i = start; i < end; i++) {
  -      final int code = (int)s.charAt(i);
  -      if (code >= 0x01 && code <= 0x7F)
  -	writeByte((byte)code);
  -      else if (((code >= 0x80) && (code <= 0x7FF)) || code == 0) {
  -	writeByte((byte)(0xC0 | (code >> 6)));
  -	writeByte((byte)(0x80 | (code & 0x3F)));
  -      } else {
  -	writeByte((byte)(0xE0 | (code >>> 12)));
  -	writeByte((byte)(0x80 | ((code >> 6) & 0x3F)));
  -	writeByte((byte)(0x80 | (code & 0x3F)));
  -      }
  -    }
  -  }
  -
  -  /** Forces any buffered output to be written. */
  -  protected final void flush() throws IOException {
  -    flushBuffer(buffer, bufferPosition);
  -    bufferStart += bufferPosition;
  -    bufferPosition = 0;
  -  }
  -
  -  /** Expert: implements buffer write.  Writes bytes at the current position in
  -   * the output.
  -   * @param b the bytes to write
  -   * @param len the number of bytes to write
  -   */
  -  protected abstract void flushBuffer(byte[] b, int len) throws IOException;
  -
  -  /** Closes this stream to further operations. */
  -  public void close() throws IOException {
  -    flush();
  -  }
  -
  -  /** Returns the current position in this file, where the next write will
  -   * occur.
  -   * @see #seek(long)
  -   */
  -  public final long getFilePointer() {
  -    return bufferStart + bufferPosition;
  -  }
  -
  -  /** Sets current position in this file, where the next write will occur.
  -   * @see #getFilePointer()
  -   */
  -  public void seek(long pos) throws IOException {
  -    flush();
  -    bufferStart = pos;
  -  }
  -
  -  /** The number of bytes in the file. */
  -  public abstract long length() throws IOException;
  -
  -
  +/** @deprecated Use {@link IndexOutput} or {@link BufferedIndexOutput}
  + * instead.*/
  +public abstract class OutputStream extends BufferedIndexOutput {
   }
  
  
  
  1.3       +3 -3      jakarta-lucene/src/java/org/apache/lucene/store/RAMOutputStream.java
  
  Index: RAMOutputStream.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/store/RAMOutputStream.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RAMOutputStream.java	29 Mar 2004 22:48:05 -0000	1.2
  +++ RAMOutputStream.java	28 Sep 2004 18:15:52 -0000	1.3
  @@ -19,7 +19,7 @@
   import java.io.IOException;
   
   /**
  - * A memory-resident {@link OutputStream} implementation.
  + * A memory-resident {@link IndexOutput} implementation.
    *
    * @version $Id$
    */
  @@ -38,7 +38,7 @@
     }
   
     /** Copy the current contents of this buffer to the named output. */
  -  public void writeTo(OutputStream out) throws IOException {
  +  public void writeTo(IndexOutput out) throws IOException {
       flush();
       final long end = file.length;
       long pos = 0;
  
  
  
  1.1                  jakarta-lucene/src/java/org/apache/lucene/store/BufferedIndexOutput.java
  
  Index: BufferedIndexOutput.java
  ===================================================================
  package org.apache.lucene.store;
  
  /**
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.io.IOException;
  
  /** Base implementation class for buffered {@link IndexOutput}. */
  public abstract class BufferedIndexOutput extends IndexOutput {
    static final int BUFFER_SIZE = 1024;
  
    private final byte[] buffer = new byte[BUFFER_SIZE];
    private long bufferStart = 0;			  // position in file of buffer
    private int bufferPosition = 0;		  // position in buffer
  
    /** Writes a single byte.
     * @see InputStream#readByte()
     */
    public void writeByte(byte b) throws IOException {
      if (bufferPosition >= BUFFER_SIZE)
        flush();
      buffer[bufferPosition++] = b;
    }
  
    /** Writes an array of bytes.
     * @param b the bytes to write
     * @param length the number of bytes to write
     * @see InputStream#readBytes(byte[],int,int)
     */
    public void writeBytes(byte[] b, int length) throws IOException {
      for (int i = 0; i < length; i++)
        writeByte(b[i]);
    }
  
    /** Forces any buffered output to be written. */
    public void flush() throws IOException {
      flushBuffer(buffer, bufferPosition);
      bufferStart += bufferPosition;
      bufferPosition = 0;
    }
  
    /** Expert: implements buffer write.  Writes bytes at the current position in
     * the output.
     * @param b the bytes to write
     * @param len the number of bytes to write
     */
    protected abstract void flushBuffer(byte[] b, int len) throws IOException;
  
    /** Closes this stream to further operations. */
    public void close() throws IOException {
      flush();
    }
  
    /** Returns the current position in this file, where the next write will
     * occur.
     * @see #seek(long)
     */
    public long getFilePointer() {
      return bufferStart + bufferPosition;
    }
  
    /** Sets current position in this file, where the next write will occur.
     * @see #getFilePointer()
     */
    public void seek(long pos) throws IOException {
      flush();
      bufferStart = pos;
    }
  
    /** The number of bytes in the file. */
    public abstract long length() throws IOException;
  
  
  }
  
  
  
  1.1                  jakarta-lucene/src/java/org/apache/lucene/store/IndexOutput.java
  
  Index: IndexOutput.java
  ===================================================================
  package org.apache.lucene.store;
  
  /**
   * Copyright 2004 The Apache Software Foundation
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  
  import java.io.IOException;
  
  /** Abstract base class for output to a file in a Directory.  A random-access
   * output stream.  Used for all Lucene index output operations.
   * @see Directory
   * @see InputStream
   */
  public abstract class IndexOutput {
  
    /** Writes a single byte.
     * @see InputStream#readByte()
     */
    public abstract void writeByte(byte b) throws IOException;
  
    /** Writes an array of bytes.
     * @param b the bytes to write
     * @param length the number of bytes to write
     * @see InputStream#readBytes(byte[],int,int)
     */
    public abstract void writeBytes(byte[] b, int length) throws IOException;
  
    /** Writes an int as four bytes.
     * @see InputStream#readInt()
     */
    public void writeInt(int i) throws IOException {
      writeByte((byte)(i >> 24));
      writeByte((byte)(i >> 16));
      writeByte((byte)(i >>  8));
      writeByte((byte) i);
    }
  
    /** Writes an int in a variable-length format.  Writes between one and
     * five bytes.  Smaller values take fewer bytes.  Negative numbers are not
     * supported.
     * @see InputStream#readVInt()
     */
    public void writeVInt(int i) throws IOException {
      while ((i & ~0x7F) != 0) {
        writeByte((byte)((i & 0x7f) | 0x80));
        i >>>= 7;
      }
      writeByte((byte)i);
    }
  
    /** Writes a long as eight bytes.
     * @see InputStream#readLong()
     */
    public void writeLong(long i) throws IOException {
      writeInt((int) (i >> 32));
      writeInt((int) i);
    }
  
    /** Writes an long in a variable-length format.  Writes between one and five
     * bytes.  Smaller values take fewer bytes.  Negative numbers are not
     * supported.
     * @see InputStream#readVLong()
     */
    public void writeVLong(long i) throws IOException {
      while ((i & ~0x7F) != 0) {
        writeByte((byte)((i & 0x7f) | 0x80));
        i >>>= 7;
      }
      writeByte((byte)i);
    }
  
    /** Writes a string.
     * @see InputStream#readString()
     */
    public void writeString(String s) throws IOException {
      int length = s.length();
      writeVInt(length);
      writeChars(s, 0, length);
    }
  
    /** Writes a sequence of UTF-8 encoded characters from a string.
     * @param s the source of the characters
     * @param start the first character in the sequence
     * @param length the number of characters in the sequence
     * @see InputStream#readChars(char[],int,int)
     */
    public void writeChars(String s, int start, int length)
         throws IOException {
      final int end = start + length;
      for (int i = start; i < end; i++) {
        final int code = (int)s.charAt(i);
        if (code >= 0x01 && code <= 0x7F)
  	writeByte((byte)code);
        else if (((code >= 0x80) && (code <= 0x7FF)) || code == 0) {
  	writeByte((byte)(0xC0 | (code >> 6)));
  	writeByte((byte)(0x80 | (code & 0x3F)));
        } else {
  	writeByte((byte)(0xE0 | (code >>> 12)));
  	writeByte((byte)(0x80 | ((code >> 6) & 0x3F)));
  	writeByte((byte)(0x80 | (code & 0x3F)));
        }
      }
    }
  
    /** Forces any buffered output to be written. */
    public abstract void flush() throws IOException;
  
    /** Closes this stream to further operations. */
    public abstract void close() throws IOException;
  
    /** Returns the current position in this file, where the next write will
     * occur.
     * @see #seek(long)
     */
    public abstract long getFilePointer();
  
    /** Sets current position in this file, where the next write will occur.
     * @see #getFilePointer()
     */
    public abstract void seek(long pos) throws IOException;
  
    /** The number of bytes in the file. */
    public abstract long length() throws IOException;
  
  
  }
  
  
  
  1.6       +3 -3      jakarta-lucene/src/java/org/apache/lucene/util/BitVector.java
  
  Index: BitVector.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/java/org/apache/lucene/util/BitVector.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- BitVector.java	16 Sep 2004 21:13:37 -0000	1.5
  +++ BitVector.java	28 Sep 2004 18:15:52 -0000	1.6
  @@ -20,7 +20,7 @@
   
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.store.IndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   
   /** Optimized implementation of a vector of bits.  This is more-or-less like
     java.util.BitSet, but also includes the following:
  @@ -108,7 +108,7 @@
       <code>d</code>, in a format that can be read by the constructor {@link
       #BitVector(Directory, String)}.  */
     public final void write(Directory d, String name) throws IOException {
  -    OutputStream output = d.createFile(name);
  +    IndexOutput output = d.createOutput(name);
       try {
         output.writeInt(size());			  // write size
         output.writeInt(count());			  // write count
  
  
  
  1.6       +2 -2      jakarta-lucene/src/test/org/apache/lucene/StoreTest.java
  
  Index: StoreTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/StoreTest.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- StoreTest.java	16 Sep 2004 21:13:37 -0000	1.5
  +++ StoreTest.java	28 Sep 2004 18:15:52 -0000	1.6
  @@ -18,7 +18,7 @@
   
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.store.IndexInput;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.FSDirectory;
   import org.apache.lucene.store.RAMDirectory;
   
  @@ -57,7 +57,7 @@
         byte b = (byte)(gen.nextInt() & 0x7F);
         //System.out.println("filling " + name + " with " + length + " of " + b);
   
  -      OutputStream file = store.createFile(name);
  +      IndexOutput file = store.createOutput(name);
   
         for (int j = 0; j < length; j++)
   	file.writeByte(b);
  
  
  
  1.8       +5 -5      jakarta-lucene/src/test/org/apache/lucene/index/TestCompoundFile.java
  
  Index: TestCompoundFile.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TestCompoundFile.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- TestCompoundFile.java	16 Sep 2004 21:13:37 -0000	1.7
  +++ TestCompoundFile.java	28 Sep 2004 18:15:52 -0000	1.8
  @@ -22,7 +22,7 @@
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
   import junit.textui.TestRunner;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   import org.apache.lucene.store.Directory;
   import org.apache.lucene.store.IndexInput;
   import org.apache.lucene.store.FSDirectory;
  @@ -66,7 +66,7 @@
       private void createRandomFile(Directory dir, String name, int size)
       throws IOException
       {
  -        OutputStream os = dir.createFile(name);
  +        IndexOutput os = dir.createOutput(name);
           for (int i=0; i<size; i++) {
               byte b = (byte) (Math.random() * 256);
               os.writeByte(b);
  @@ -84,7 +84,7 @@
                                       int size)
       throws IOException
       {
  -        OutputStream os = dir.createFile(name);
  +        IndexOutput os = dir.createOutput(name);
           for (int i=0; i < size; i++) {
               os.writeByte(start);
               start ++;
  @@ -313,7 +313,7 @@
       throws IOException
       {
           // Setup the test file - we need more than 1024 bytes
  -        OutputStream os = fsdir.createFile(file);
  +        IndexOutput os = fsdir.createOutput(file);
           for(int i=0; i<2000; i++) {
               os.writeByte((byte) i);
           }
  
  
  
  1.9       +4 -4      jakarta-lucene/src/test/org/apache/lucene/index/TestDoc.java
  
  Index: TestDoc.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TestDoc.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TestDoc.java	22 Sep 2004 18:32:27 -0000	1.8
  +++ TestDoc.java	28 Sep 2004 18:15:52 -0000	1.9
  @@ -63,16 +63,16 @@
           directory.close();
   
           files = new LinkedList();
  -        files.add(createFile("test.txt",
  +        files.add(createOutput("test.txt",
               "This is the first test file"
           ));
   
  -        files.add(createFile("test2.txt",
  +        files.add(createOutput("test2.txt",
               "This is the second test file"
           ));
       }
   
  -    private File createFile(String name, String text) throws IOException {
  +    private File createOutput(String name, String text) throws IOException {
           FileWriter fw = null;
           PrintWriter pw = null;
   
  
  
  
  1.3       +3 -3      jakarta-lucene/src/test/org/apache/lucene/index/TestFieldInfos.java
  
  Index: TestFieldInfos.java
  ===================================================================
  RCS file: /home/cvs/jakarta-lucene/src/test/org/apache/lucene/index/TestFieldInfos.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TestFieldInfos.java	25 Aug 2004 12:01:39 -0000	1.2
  +++ TestFieldInfos.java	28 Sep 2004 18:15:52 -0000	1.3
  @@ -4,7 +4,7 @@
   import junit.framework.TestCase;
   import org.apache.lucene.document.Document;
   import org.apache.lucene.store.RAMDirectory;
  -import org.apache.lucene.store.OutputStream;
  +import org.apache.lucene.store.IndexOutput;
   
   import java.io.IOException;
   
  @@ -25,7 +25,7 @@
     protected void tearDown() {
     }
   
  -  public void test() {
  +  public void test() throws IOException {
       //Positive test of FieldInfos
       assertTrue(testDoc != null);
       FieldInfos fieldInfos = new FieldInfos();
  @@ -34,7 +34,7 @@
       assertTrue(fieldInfos.size() == 7); //this is 7 b/c we are using the no-arg constructor
       RAMDirectory dir = new RAMDirectory();
       String name = "testFile";
  -    OutputStream output = dir.createFile(name);
  +    IndexOutput output = dir.createOutput(name);
       assertTrue(output != null);
       //Use a RAMOutputStream
       
  
  
  

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