Ejemplo n.º 1
0
        public virtual DocsAndWriter IndexRandomIWReader(int nThreads, int iterations, int range, Directory dir)
        {
            System.Collections.Hashtable docs = new System.Collections.Hashtable();
            IndexWriter w = new MockIndexWriter(this, dir, autoCommit, new WhitespaceAnalyzer(), true);

            w.SetUseCompoundFile(false);

            /***
             * w.setMaxMergeDocs(Integer.MAX_VALUE);
             * w.setMaxFieldLength(10000);
             * w.setRAMBufferSizeMB(1);
             * w.setMergeFactor(10);
             ***/

            // force many merges
            w.SetMergeFactor(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)
                {
                    SupportClass.CollectionsHelper.AddAllIfNotContains(docs, th.docs);
                }
            }

            _TestUtil.CheckIndex(dir);
            DocsAndWriter dw = new DocsAndWriter();

            dw.docs   = docs;
            dw.writer = w;
            return(dw);
        }
Ejemplo n.º 2
0
        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, autoCommit, new WhitespaceAnalyzer(), true);
                w.SetUseCompoundFile(false);

                // force many merges
                w.SetMergeFactor(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);
        }
Ejemplo n.º 3
0
		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, autoCommit, new WhitespaceAnalyzer(), true);
				w.SetUseCompoundFile(false);
				
				// force many merges
				w.SetMergeFactor(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;
		}
Ejemplo n.º 4
0
		public virtual DocsAndWriter IndexRandomIWReader(int nThreads, int iterations, int range, Directory dir)
		{
			System.Collections.Hashtable docs = new System.Collections.Hashtable();
			IndexWriter w = new MockIndexWriter(this, dir, autoCommit, new WhitespaceAnalyzer(), true);
			w.SetUseCompoundFile(false);
			
			/***
			w.setMaxMergeDocs(Integer.MAX_VALUE);
			w.setMaxFieldLength(10000);
			w.setRAMBufferSizeMB(1);
			w.setMergeFactor(10);
			***/
			
			// force many merges
			w.SetMergeFactor(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)
				{
					SupportClass.CollectionsHelper.AddAllIfNotContains(docs, th.docs);
				}
			}
			
			_TestUtil.CheckIndex(dir);
			DocsAndWriter dw = new DocsAndWriter();
			dw.docs = docs;
			dw.writer = w;
			return dw;
		}