lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yonik Seeley (JIRA)" <j...@apache.org>
Subject [jira] Commented: (LUCENE-435) [PATCH] BufferedIndexOutput - optimized writeBytes() method
Date Fri, 21 Oct 2005 14:45:37 GMT
    [ http://issues.apache.org/jira/browse/LUCENE-435?page=comments#action_12332714 ] 

Yonik Seeley commented on LUCENE-435:
-------------------------------------

I just breifly looked at writeBytes(), and I think there is further room for optimization.
Specifically, Doug's suggestion: "If the new data is larger than a buffer, then the buffer
should be flushed and the new data written directly, without ever copying it into the buffer."

Even if everything were already peftect, committers need time to review it.

> [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, 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: java-dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-dev-help@lucene.apache.org


Mime
View raw message