lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From David Causse <dcau...@spotter.com>
Subject Payload instance and byte buffer instance re-use
Date Wed, 14 Dec 2011 11:29:59 GMT
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-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message