lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yonik Seeley <yo...@lucidimagination.com>
Subject Re: Question about string retrieval with FieldCache in trunk
Date Wed, 18 Aug 2010 16:05:04 GMT
On Wed, Aug 18, 2010 at 12:03 PM, Yonik Seeley
<yonik@lucidimagination.com> wrote:
> On Wed, Aug 18, 2010 at 11:28 AM,  <karl.wright@nokia.com> wrote:
>> If you are correct, the comment is certainly incorrect, since it implies that the
SAME BytesRef is returned as you pass in.
>
> Yes, that's correct.  BytesRef is mutable.  You pass in an instance,
> and the value is set and the same BytesRef is normally returned to
> you.  I guess the fact that it's returned at all is to allow a
> flexible implementation to possibly return a BytesRef from somewhere
> else.
>
> So:
>  BytesRef reuse = new BytesRef();
>  for (;;) {
>    BytesRef val = docTerms.getTerm(id, reuse);
>    // use val, but make a copy
>  }

comment got truncated... it should read:
// use val, but make a copy if you need to retain it beyond one loop
iteration (since it will be overwritten)

-Yonik
http://www.lucidimagination.com

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


Mime
View raw message