public override void Run() { try { Document doc = new Document(); DirectoryReader r = DirectoryReader.Open(Dir); Field f = NewStringField("f", "", Field.Store.NO); doc.Add(f); int count = 0; do { if (Failed) { break; } for (int j = 0; j < 10; j++) { string s = FinalI + "_" + Convert.ToString(count++); f.SetStringValue(s); w.AddDocument(doc); w.Commit(); DirectoryReader r2 = DirectoryReader.OpenIfChanged(r); Assert.IsNotNull(r2); Assert.IsTrue(!r2.Equals(r)); r.Dispose(); r = r2; Assert.AreEqual(1, r.DocFreq(new Term("f", s)), "term=f:" + s + "; r=" + r); } } while (Environment.TickCount < EndTime); r.Dispose(); } catch (Exception t) { Failed.Value = (true); throw new Exception(t.Message, t); } }
public override void Run() { try { Document doc = new Document(); DirectoryReader r = DirectoryReader.Open(dir); Field f = newStringField("f", "", Field.Store.NO); doc.Add(f); int count = 0; do { if (failed) { break; } for (int j = 0; j < 10; j++) { string s = finalI + "_" + Convert.ToString(count++); f.SetStringValue(s); w.AddDocument(doc); w.Commit(); DirectoryReader r2 = DirectoryReader.OpenIfChanged(r); Assert.IsNotNull(r2); Assert.IsTrue(!r2.Equals(r)); r.Dispose(); r = r2; Assert.AreEqual(1, r.DocFreq(new Term("f", s)), "term=f:" + s + "; r=" + r); } } while ((J2N.Time.NanoTime() / J2N.Time.MillisecondsPerNanosecond) < endTime); // LUCENENET: Use NanoTime() rather than CurrentTimeMilliseconds() for more accurate/reliable results r.Dispose(); } catch (Exception t) when(t.IsThrowable()) { failed.Value = (true); throw RuntimeException.Create(t); } }