Lucene.Net.Index.TestStressIndexing2.IndexRandom C# (CSharp) Method

IndexRandom() public method

public IndexRandom ( int nThreads, int iterations, int range, Lucene.Net.Store.Directory dir ) : System.Collections.IDictionary
nThreads int
iterations int
range int
dir Lucene.Net.Store.Directory
return System.Collections.IDictionary
		public virtual System.Collections.IDictionary IndexRandom(int nThreads, int iterations, int range, Directory dir)
		{
			System.Collections.IDictionary docs = new System.Collections.Hashtable();
			for (int iter = 0; iter < 3; iter++)
			{
				IndexWriter w = new MockIndexWriter(this, dir, new WhitespaceAnalyzer(), true, IndexWriter.MaxFieldLength.UNLIMITED);
				w.UseCompoundFile = false;
				
				// force many merges
				w.MergeFactor = mergeFactor;
				w.SetRAMBufferSizeMB(.1);
				w.SetMaxBufferedDocs(maxBufferedDocs);
				
				threads = new IndexingThread[nThreads];
				for (int i = 0; i < threads.Length; i++)
				{
					IndexingThread th = new IndexingThread();
					th.w = w;
					th.base_Renamed = 1000000 * i;
					th.range = range;
					th.iterations = iterations;
					threads[i] = th;
				}
				
				for (int i = 0; i < threads.Length; i++)
				{
					threads[i].Start();
				}
				for (int i = 0; i < threads.Length; i++)
				{
					threads[i].Join();
				}
				
				// w.optimize();
				w.Close();
				
				for (int i = 0; i < threads.Length; i++)
				{
					IndexingThread th = threads[i];
					lock (th)
					{
                        System.Collections.IEnumerator e = th.docs.Keys.GetEnumerator();
                        while (e.MoveNext())
                        {
                            docs[e.Current] = th.docs[e.Current];
                        }
					}
				}
			}
			
			_TestUtil.CheckIndex(dir);
			
			return docs;
		}