private ThreadResources GetThreadResources() { ThreadResources resources = (ThreadResources)threadResources.Get(); if (resources == null) { resources = new ThreadResources(); resources.termEnum = Terms(); // Cache does not have to be thread-safe, it is only used by one thread at the same time resources.termInfoCache = new SimpleLRUCache(DEFAULT_CACHE_SIZE); threadResources.Set(resources); } return(resources); }
/// <summary>Used by Analyzers that implement reusableTokenStream /// to retrieve previously saved TokenStreams for re-use /// by the same thread. /// </summary> protected internal virtual System.Object GetPreviousTokenStream() { try { return(tokenStreams.Get()); } catch (System.NullReferenceException npe) { if (tokenStreams == null) { throw new AlreadyClosedException("this Analyzer is closed"); } else { throw npe; } } }
/// <summary> Create a clone from the initial TermVectorsReader and store it in the ThreadLocal.</summary> /// <returns> TermVectorsReader /// </returns> private TermVectorsReader GetTermVectorsReader() { System.Diagnostics.Debug.Assert(termVectorsReaderOrig != null); TermVectorsReader tvReader = (TermVectorsReader)termVectorsLocal.Get(); if (tvReader == null) { try { tvReader = (TermVectorsReader)termVectorsReaderOrig.Clone(); } catch (System.Exception) { return(null); } termVectorsLocal.Set(tvReader); } return(tvReader); }