They should be reused if the impl. allows for it.

Besides reducing GC cost, it can also be a sizable performance gain
since these enums can have quite a bit of state that otherwise must be
re-initialized.

If you really don't want to reuse them (force a new enum every time), pass null.

Mike McCandless

http://blog.mikemccandless.com


On Fri, Dec 5, 2014 at 8:14 PM, Darin Amos <dari...@gmail.com> wrote:
> Hi All,
>
> I have been working on a custom query and I am going off of samples in the 
> lucene join library (4.3.0) and I am a little unclear about a couple lines.
>
> 1) When getting a TermsEnum in 
> TermsIncludingScoreQuery.createWeight(…).scorer()… A previous TermsEnum is 
> used like the following:
>
> segmentTermsEnum = terms.iterator(segmentTermsEnum);
>
> 2) When getting a DocsEnum SVInOrderScorer.fillDocsAndScores:
>
>  for (int i = 0; i < terms.size(); i++) {
>         if (termsEnum.seekExact(terms.get(ords[i], spare), true)) {
>           docsEnum = termsEnum.docs(acceptDocs, docsEnum, DocsEnum.FLAG_NONE);
>
> My assumption is that the previous enum values are not reused, but this is a 
> tuning mechanism for garbage collection, is the correct assumption?
>
> Thanks!
>
> Darin

Reply via email to