public long record(IndexSearcher searcher) throws IOException {ensureOpen();final long version = ((DirectoryReader) searcher.getIndexReader()).getVersion();SearcherTracker tracker = searchers.get(version);if (tracker == null) {tracker = new SearcherTracker(searcher);if (searchers.putIfAbsent(version, tracker) != null) {tracker.close();}} else if (tracker.searcher != searcher) {throw new IllegalArgumentException("the provided searcher has the same underlying reader version yet the searcher instance differs from before (new=" + searcher + " vs old=" + tracker.searcher);}return version;}

public virtual long Record(IndexSearcher searcher){EnsureOpen();var version = ((DirectoryReader)searcher.IndexReader).Version;var factoryMethodCalled = false;var tracker = _searchers.GetOrAdd(version, l => new Lazy<SearcherTracker>(() => { factoryMethodCalled = true; return new SearcherTracker(searcher); })).Value;if (!factoryMethodCalled && tracker.Searcher != searcher){throw new ArgumentException("the provided searcher has the same underlying reader version yet the searcher instance differs from before (new=" + searcher + " vs old=" + tracker.Searcher);}return version;}
