lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Causse <>
Subject Payload instance and byte buffer instance re-use
Date Wed, 14 Dec 2011 11:29:59 GMT

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

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message