[ http://issues.apache.org/jira/browse/LUCENE-435?page=all ]

Lukas Zapletal updated LUCENE-435:
----------------------------------

    Attachment: fastWrite.patch

Hello,

I have done what you requested (sorry for the late delay - too busy). I also 
found a bug in RAMOutputStream - the implementation of flushBuffer method was 
not able to write any buffers longer than 2*BUFFER_LENGTH. My fast writeBytes 
patch now handle all various situation and uses the fastest methods to write 
data.

In my opinion its not good to make BUFFER_LENGTH constant public. Consider 
making it private since this can lead to nontrivial "dependency" (as I have 
described above). Its not good to have one buffer length for input, output and 
RAM* objects (which should have independant buffer length at all - it has 
nothing to do with the caching in the abstract methods). Making it private and 
maybe accessible on runtime could help a litte (as I said -- I use the API for 
some index copying and I would like to have larger buffers).

Anyway, this is my contribution, I am looking for more reviews. The patch 
includes StoreTest modification which helps with testing either writeByte 
method or writeBytes methods. Thanks for your attention.

> [PATCH] BufferedIndexOutput - optimized writeBytes() method
> -----------------------------------------------------------
>
>          Key: LUCENE-435
>          URL: http://issues.apache.org/jira/browse/LUCENE-435
>      Project: Lucene - Java
>         Type: Improvement
>   Components: Store
>     Reporter: Lukas Zapletal
>     Priority: Minor
>  Attachments: BufferedIndexOutputWriteBytes.patch, fastWrite.patch, 
> writeBytes.patch
>
> I have created a patch that optimize writeBytes metod:
>   public void writeBytes(byte[] b, int length) throws IOException {
>     if (bufferPosition > 0) // flush buffer
>       flush();
>  
>     if (length < BUFFER_SIZE) {
>       flushBuffer(b, length);
>       bufferStart += length;
>     } else {
>       int pos = 0;
>       int size;
>       while (pos < length) {
>         if (length - pos < BUFFER_SIZE) {
>           size = length - pos;
>         } else {
>           size = BUFFER_SIZE;
>         }
>         System.arraycopy(b, pos, buffer, 0, size);
>         pos += size;
>         flushBuffer(buffer, size);
>         bufferStart += size;
>       }
>     }
>   }
> Its a much more faster now. I know that for indexing this not help much, but 
> for copying files in the IndexStore this is so big improvement. Its about 
> 400% faster that old implementation.
> The patch was tested with 300MB data, "ant test" sucessfuly finished with no 
> errors.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to