Hi,

Is it safe to reuse a Payload instance within a TokenStream/Filter? I think about something like this :

public final boolean incrementToken() throws IOException {
    [...]
    if(payloadAttribute.getPayload() == null) {
        payloadAttribute.setPayload(new Payload());
    }
payloadAttribute.getPayload().setData(myWorkingBuffer, 0, myWorkingBufferLength);
    return true;
}

Before, I always passed a new Payload instance with a fresh byte[] copy, I'm testing this optimization and my first tests are successful. As I'm not aware of all indexing scenarios I'm afraid of some cases where payload instance or data could be buffered and then overwritten by myself while building the next token.

Thanks for your help.

--
David Causse
Spotter
http://www.spotter.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscr...@lucene.apache.org
For additional commands, e-mail: java-user-h...@lucene.apache.org

Reply via email to