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); }
public virtual DocsAndWriter IndexRandomIWReader(int nThreads, int iterations, int range, Directory dir) { IDictionary <string, Document> docs = new Dictionary <string, Document>(); IndexWriter w = RandomIndexWriter.MockIndexWriter(dir, NewIndexWriterConfig(TEST_VERSION_CURRENT, new MockAnalyzer(Random)).SetOpenMode(OpenMode.CREATE).SetRAMBufferSizeMB(0.1).SetMaxBufferedDocs(maxBufferedDocs).SetMergePolicy(NewLogMergePolicy()), new YieldTestPoint(this)); w.Commit(); LogMergePolicy lmp = (LogMergePolicy)w.Config.MergePolicy; lmp.NoCFSRatio = 0.0; lmp.MergeFactor = mergeFactor; /* * /// w.setMaxMergeDocs(Integer.MAX_VALUE); * /// w.setMaxFieldLength(10000); * /// w.SetRAMBufferSizeMB(1); * /// w.setMergeFactor(10); */ threads = new IndexingThread[nThreads]; for (int i = 0; i < threads.Length; i++) { IndexingThread th = new IndexingThread(this); th.w = w; th.@base = 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.ForceMerge(1); //w.Dispose(); for (int i = 0; i < threads.Length; i++) { IndexingThread th = threads[i]; lock (th) { docs.PutAll(th.docs); } } TestUtil.CheckIndex(dir); DocsAndWriter dw = new DocsAndWriter(); dw.docs = docs; dw.writer = w; return(dw); }
public virtual void TestRandomIWReader() { Directory dir = NewDirectory(); // TODO: verify equals using IW.getReader DocsAndWriter dw = IndexRandomIWReader(5, 3, 100, dir); DirectoryReader reader = dw.writer.GetReader(); dw.writer.Commit(); VerifyEquals(Random, reader, dir, "id"); reader.Dispose(); dw.writer.Dispose(); dir.Dispose(); }
public virtual void TestRandomIWReader() { this.r = NewRandom(); Directory dir = new MockRAMDirectory(); // TODO: verify equals using IW.getReader DocsAndWriter dw = IndexRandomIWReader(10, 100, 100, dir); IndexReader r = dw.writer.GetReader(); dw.writer.Commit(); VerifyEquals(r, dir, "id"); r.Close(); dw.writer.Close(); dir.Close(); }
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; }