text: 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;}