public static IndexCommit findIndexCommit(Directory dir, String userData) throws IOException {Collection<IndexCommit> commits = DirectoryReader.listCommits(dir);for (final IndexCommit ic : commits) {Map<String,String> map = ic.getUserData();String ud = null;if (map != null) {ud = map.get(USER_DATA);}if (ud != null && ud.equals(userData)) {return ic;}}throw new IOException("index does not contain commit with userData: " + userData);}
public static IndexCommit FindIndexCommit(Store.Directory dir, string userData){IList<IndexCommit> commits = DirectoryReader.ListCommits(dir);foreach (IndexCommit ic in commits){IDictionary<string, string> map = ic.UserData;string ud = null;if (map != null){map.TryGetValue(USER_DATA, out ud);}if (ud != null && ud.Equals(userData, StringComparison.Ordinal)){return ic;}}throw new IOException("index does not contain commit with userData: " + userData);}