You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Adrien Grand (Jira)" <ji...@apache.org> on 2022/07/12 15:18:00 UTC

[jira] [Resolved] (LUCENE-10619) Optimize the writeBytes in TermsHashPerField

     [ https://issues.apache.org/jira/browse/LUCENE-10619?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Adrien Grand resolved LUCENE-10619.
-----------------------------------
    Fix Version/s: 9.3
       Resolution: Fixed

> Optimize the writeBytes in TermsHashPerField
> --------------------------------------------
>
>                 Key: LUCENE-10619
>                 URL: https://issues.apache.org/jira/browse/LUCENE-10619
>             Project: Lucene - Core
>          Issue Type: Improvement
>          Components: core/index
>    Affects Versions: 9.2
>            Reporter: tang donghai
>            Priority: Major
>             Fix For: 9.3
>
>          Time Spent: 1.5h
>  Remaining Estimate: 0h
>
> Because we don't know the length of slice, writeBytes will always write byte one after another instead of writing a block of bytes.
> May be we could return both offset and length in ByteBlockPool#allocSlice?
> 1. BYTE_BLOCK_SIZE is 32768, offset is at most 15 bits.
> 2. slice size is at most 200, so it could fit in 8 bits.
> So we could put them together into an int -------- offset | length
> There are only two places where this function is used,the cost of change it is relatively small.
> When allocSlice could return the offset and length of new Slice, we could change writeBytes like below
> {code:java}
> // write block of bytes each time
> while(remaining > 0 ) {
>    int offsetAndLength = allocSlice(bytes, offset);
>    length = min(remaining, (offsetAndLength & 0xff) - 1);
>    offset = offsetAndLength >> 8;
>    System.arraycopy(src, srcPos, bytePool.buffer, offset, length);
>    remaining -= length;
>    offset    += (length + 1);
> }
> {code}
> If it could work, I'd like to raise a pr.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org