Beispiel #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);
        }
Beispiel #2
0
 /// <summary>Used by Analyzers that implement reusableTokenStream
 /// to save a TokenStream for later re-use by the same
 /// thread.
 /// </summary>
 protected internal virtual void  SetPreviousTokenStream(System.Object obj)
 {
     try
     {
         tokenStreams.Set(obj);
     }
     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);
        }