public int doLogic() throws Exception {final PerfRunData runData = getRunData();IndexWriter w = runData.getIndexWriter();if (w == null) {throw new RuntimeException("please open the writer before invoking NearRealtimeReader");}if (runData.getIndexReader() != null) {throw new RuntimeException("please close the existing reader before invoking NearRealtimeReader");}long t = System.currentTimeMillis();DirectoryReader r = DirectoryReader.open(w);runData.setIndexReader(r);r.decRef();reopenCount = 0;while(!stopNow) {long waitForMsec = (pauseMSec - (System.currentTimeMillis() - t));if (waitForMsec > 0) {Thread.sleep(waitForMsec);}t = System.currentTimeMillis();final DirectoryReader newReader = DirectoryReader.openIfChanged(r);if (newReader != null) {final int delay = (int) (System.currentTimeMillis()-t);if (reopenTimes.length == reopenCount) {reopenTimes = ArrayUtil.grow(reopenTimes, 1+reopenCount);}reopenTimes[reopenCount++] = delay;runData.setIndexReader(newReader);newReader.decRef();r = newReader;}}stopNow = false;return reopenCount;}
public override int DoLogic(){PerfRunData runData = RunData;IndexWriter w = runData.IndexWriter;if (w == null){throw new Exception("please open the writer before invoking NearRealtimeReader");}if (runData.GetIndexReader() != null){throw new Exception("please close the existing reader before invoking NearRealtimeReader");}long t = J2N.Time.CurrentTimeMilliseconds();DirectoryReader r = DirectoryReader.Open(w, true);runData.SetIndexReader(r);r.DecRef();reopenCount = 0;while (!Stop){long waitForMsec = (pauseMSec - (J2N.Time.CurrentTimeMilliseconds() - t));if (waitForMsec > 0){Thread.Sleep((int)waitForMsec);}t = J2N.Time.CurrentTimeMilliseconds();DirectoryReader newReader = DirectoryReader.OpenIfChanged(r);if (newReader != null){int delay = (int)(J2N.Time.CurrentTimeMilliseconds() - t);if (reopenTimes.Length == reopenCount){reopenTimes = ArrayUtil.Grow(reopenTimes, 1 + reopenCount);}reopenTimes[reopenCount++] = delay;runData.SetIndexReader(newReader);newReader.DecRef();r = newReader;}}Stop = false;return reopenCount;}