public void build(InputIterator iter) throws IOException {synchronized (searcherMgrLock) {if (searcherMgr != null) {searcherMgr.close();searcherMgr = null;}if (writer != null) {writer.close();writer = null;}boolean success = false;try {writer = new IndexWriter(dir,getIndexWriterConfig(getGramAnalyzer(), IndexWriterConfig.OpenMode.CREATE));BytesRef text;while ((text = iter.next()) != null) {BytesRef payload;if (iter.hasPayloads()) {payload = iter.payload();} else {payload = null;}add(text, iter.contexts(), iter.weight(), payload);}if (commitOnBuild || closeIndexWriterOnBuild) {commit();}searcherMgr = new SearcherManager(writer, null);success = true;} finally {if (success) {if (closeIndexWriterOnBuild) {writer.close();writer = null;}} else {  if (writer != null) {writer.rollback();writer = null;}}}}}
public override void Build(IInputIterator iter){if (m_searcherMgr != null){m_searcherMgr.Dispose();m_searcherMgr = null;}if (writer != null){writer.Dispose();writer = null;}AtomicReader r = null;bool success = false;try{writer = new IndexWriter(dir, GetIndexWriterConfig(matchVersion, GramAnalyzer, OpenMode.CREATE));BytesRef text;while ((text = iter.Next()) != null){BytesRef payload;if (iter.HasPayloads){payload = iter.Payload;}else{payload = null;}Add(text, iter.Contexts, iter.Weight, payload);}m_searcherMgr = new SearcherManager(writer, true, null);success = true;}finally{if (success){IOUtils.Dispose(r);}else{IOUtils.DisposeWhileHandlingException(writer, r);writer = null;}}}