Aaaah, I think I get it. TermIndexReader can be shared by multiple threads. Each thread will need access to SegmentTermEnum inside the TIR, but since each of them will search, scan, and seek to a different location, each threads needs its own copy/clone of the original SegmentTermEnum.
ThreadLocal is then used as a simple cache for the clone of the original SegmentTermEnum, so a single thread can get to it without repeating scan/seek stuff, and so that each thread works with its own clone of SegmentTermEnum. Otis ----- Original Message ---- From: Otis Gospodnetic <[EMAIL PROTECTED]> To: java-dev@lucene.apache.org Sent: Wednesday, December 13, 2006 4:53:45 PM Subject: TermInfosReader and clone of SegmentTermEnum Hi, I'm looking at Robert Engels' patches in http://issues.apache.org/jira/browse/LUCENE-436 and looking at TermInfosReader. I think I understand why there is ThreadLocal there in the first place - to act as a per-thread cache for the expensive to compute SegmentTermEnum.... yes? But why is there is need to clone() the (original) SegmentTermEnum? Thanks, Otis --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]