예제 #1
0
        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);
        }
예제 #2
0
 /// <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;
         }
     }
 }
예제 #3
0
        /// <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);
        }